summaryrefslogtreecommitdiffstats
path: root/roles/openshift_manageiq/tasks/main.yaml
blob: a7214482f493df9139ce99d89344b5a377aabdb7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
---
- fail:
    msg: "The openshift_manageiq role requires OpenShift Enterprise 3.1 or Origin 1.1."
  when: not openshift.common.version_gte_3_1_or_1_1 | bool

- name: Copy Configuration to temporary conf
  command: >
    cp {{ openshift.common.config_base }}/master/admin.kubeconfig {{manage_iq_tmp_conf}}
  changed_when: false

- name: Add Management Infrastructure project
  command: >
    {{ openshift.common.client_binary }} adm new-project
    management-infra
    --description="Management Infrastructure"
    --config={{manage_iq_tmp_conf}}
  register: osmiq_create_mi_project
  failed_when: "'already exists' not in osmiq_create_mi_project.stderr and osmiq_create_mi_project.rc != 0"
  changed_when: osmiq_create_mi_project.rc == 0

- name: Create Admin Service Account
  shell: >
    echo {{ manageiq_service_account | to_json | quote }} |
    {{ openshift.common.client_binary }} create
    -n management-infra
    --config={{manage_iq_tmp_conf}}
    -f -
  register: osmiq_create_service_account
  failed_when: "'already exists' not in osmiq_create_service_account.stderr and osmiq_create_service_account.rc != 0"
  changed_when: osmiq_create_service_account.rc == 0

- name: Create Image Inspector Service Account
  shell: >
    echo {{ manageiq_image_inspector_service_account | to_json | quote }} |
    {{ openshift.common.client_binary }} create
    -n management-infra
    --config={{manage_iq_tmp_conf}}
    -f -
  register: osmiq_create_service_account
  failed_when: "'already exists' not in osmiq_create_service_account.stderr and osmiq_create_service_account.rc != 0"
  changed_when: osmiq_create_service_account.rc == 0

- name: Create Cluster Role
  shell: >
    echo {{ manageiq_cluster_role | to_json | quote }} |
    {{ openshift.common.client_binary }} create
    --config={{manage_iq_tmp_conf}}
    -f -
  register: osmiq_create_cluster_role
  failed_when: "'already exists' not in osmiq_create_cluster_role.stderr and osmiq_create_cluster_role.rc != 0"
  changed_when: osmiq_create_cluster_role.rc == 0

- name: Create Hawkular Metrics Admin Cluster Role
  shell: >
    echo {{ manageiq_metrics_admin_clusterrole | to_json | quote }} |
    {{ openshift.common.client_binary }}
    --config={{manage_iq_tmp_conf}}
    create -f -
  register: oshawkular_create_cluster_role
  failed_when: "'already exists' not in oshawkular_create_cluster_role.stderr and oshawkular_create_cluster_role.rc != 0"
  changed_when: oshawkular_create_cluster_role.rc == 0

- name: Configure role/user permissions
  command: >
    {{ openshift.common.client_binary }} adm {{item}}
    --config={{manage_iq_tmp_conf}}
  with_items: "{{manage_iq_tasks}}"
  register: osmiq_perm_task
  failed_when: "'already exists' not in osmiq_perm_task.stderr and osmiq_perm_task.rc != 0"
  changed_when: osmiq_perm_task.rc == 0

- name: Configure 3_2 role/user permissions
  command: >
    {{ openshift.common.client_binary }} adm {{item}}
    --config={{manage_iq_tmp_conf}}
  with_items: "{{manage_iq_openshift_3_2_tasks}}"
  register: osmiq_perm_3_2_task
  failed_when: osmiq_perm_3_2_task.rc != 0
  changed_when: osmiq_perm_3_2_task.rc == 0
  when: openshift.common.version_gte_3_2_or_1_2 | bool

- name: Clean temporary configuration file
  file: path={{manage_iq_tmp_conf}} state=absent