sborenst
2018-09-06 febf59bde588523e1a1bf7f654116eb6e1b301ec
commit | author | age
694262 1 # vim: set ft=ansible:
0850ad 2 ---
0c3c12 3 - name: Step 005 - Post Software deployment
0850ad 4   hosts: localhost
S 5   connection: local
6   become: false
7   vars_files:
8     - "./env_vars.yml"
9     - "./env_secret_vars.yml"
10   tags:
6e59c8 11     - step005
0850ad 12   tasks:
df45d6 13     - name: Generate /etc/ansible/hosts file with lab inv template
8e69a5 14       template:
694262 15         src: "{{ ANSIBLE_REPO_PATH }}/configs/{{ env_type }}/files/labs_hosts_template.{{ osrelease }}.j2"
c6075f 16         dest: "{{ ANSIBLE_REPO_PATH }}/workdir/labs_hosts-{{ env_type }}-{{ guid }}"
694262 17
JM 18 - name: Run openshift host provision on the bastion
19   gather_facts: False
20   become: yes
21   hosts:
22     - bastions
23   vars_files:
24     - "{{ ANSIBLE_REPO_PATH }}/configs/{{ env_type }}/env_vars.yml"
25   roles:
26     - role: "{{ ANSIBLE_REPO_PATH }}/roles/host-ocp-provisioner"
6e59c8 27
bd0e20 28 - name: Configure NFS host for user-vols if required
S 29   hosts: support
30   gather_facts: False
31   become: yes
32   vars_files:
33     - "{{ ANSIBLE_REPO_PATH }}/configs/{{ env_type }}/env_vars.yml"
34   tasks:
35     - name: Create user vols
36       shell: "mkdir -p /srv/nfs/user-vols/vol{1..{{user_vols}}}"
37       tags:
38         - openshift_nfs_config
39     - name: chmod the user vols
40       shell: "chmod -R 777 /srv/nfs/user-vols"
41       tags:
42         - openshift_nfs_config
43
c919e1 44 - name: Step lab post software deployment
b192b2 45   hosts: bastions
6e59c8 46   gather_facts: False
S 47   become: yes
3b64e5 48   tags:
S 49     - opentlc_bastion_tasks
6e59c8 50   vars_files:
c6075f 51     - "{{ ANSIBLE_REPO_PATH }}/configs/{{ env_type }}/env_vars.yml"
6e59c8 52   tasks:
e2b977 53     - name: Copy complete inventory file to bastion /var/preserve/hosts
694262 54       copy:
JM 55         src: "{{ ANSIBLE_REPO_PATH }}/workdir/hosts-{{ env_type }}-{{ guid }}"
56         dest: /var/preserve/hosts
b4edbc 57       tags: preserve_complete_ansible_inventory
JM 58
e2b977 59     - name: copy prometheus rules file to bastion
JM 60       copy:
61         src: "{{ ANSIBLE_REPO_PATH }}/configs/{{ env_type }}/files/prometheus_alerts_labs.yml"
62         dest: /root/prometheus_alerts_labs.yml
63
36724b 64     - name: Copy over ansible hosts file, lab version
8e69a5 65       copy:
1cdd78 66         backup: no
c6075f 67         src: "{{ ANSIBLE_REPO_PATH }}/workdir/labs_hosts-{{ env_type }}-{{ guid }}"
8e69a5 68         dest: /etc/ansible/hosts
3b64e5 69       tags:
S 70         - overwrite_hosts_with_lab_hosts
dca013 71
694262 72     ## Create PV objects for uservols if required
5002c7 73     - name: get nfs Hostname
S 74       set_fact:
75         nfs_host: "{{ groups['support']|sort|first }}"
76       tags:
77         - openshift_nfs_config
78     - set_fact:
79         pv_size: '10Gi'
80         pv_list: "{{ ocp_pvs }}"
81         persistentVolumeReclaimPolicy: Retain
82       tags:
83         - openshift_nfs_config
84     - name: Generate PV file
85       template:
86         src: "{{ ANSIBLE_REPO_PATH }}/configs/{{ env_type }}/files/pvs.j2"
87         dest: "/root/pvs-{{ env_type }}-{{ guid }}.yml"
88       tags: [ gen_pv_file ]
89       when: pv_list.0 is defined
90       tags:
91         - openshift_nfs_config
92     - set_fact:
93         pv_size: "{{user_vols_size}}"
94         persistentVolumeReclaimPolicy: Recycle
95       tags:
96         - openshift_nfs_config
97       notify: restart nfs services
98       run_once: True
dca013 99
5002c7 100     - name: Generate user vol PV file
S 101       template:
102         src: "{{ ANSIBLE_REPO_PATH }}/configs/{{ env_type }}/files/userpvs.j2"
103         dest: "/root/userpvs-{{ env_type }}-{{ guid }}.yml"
104       tags:
105         - gen_user_vol_pv
106         - openshift_nfs_config
107
108     - shell: 'oc create -f /root/pvs-{{ env_type }}-{{ guid }}.yml || oc replace -f /root/pvs-{{ env_type }}-{{ guid }}.yml'
109       tags:
110         - create_user_pv
111       when: pv_list.0 is defined
112       tags:
113         - openshift_nfs_config
114
115     - shell: 'oc create -f /root/userpvs-{{ env_type }}-{{ guid }}.yml || oc replace -f /root/userpvs-{{ env_type }}-{{ guid }}.yml'
116       tags:
117         - create_user_pv
118         - openshift_nfs_config
119
42a979 120     - import_role:
GC 121         name: "{{ ANSIBLE_REPO_PATH }}/roles/bastion-opentlc-ipa"
122       when: install_ipa_client|bool
123
5002c7 124 # - name: include post nfs config
S 125 #   include: "{{ ANSIBLE_REPO_PATH }}/configs/{{ env_type }}/post_ocp_nfs_config.yml"
126 #   tags:
127 #     - openshift_nfs_config
128
dca013 129 - name: PostSoftware flight-check
S 130   hosts: localhost
131   connection: local
132   gather_facts: false
133   become: false
134   vars_files:
135     - "{{ ANSIBLE_REPO_PATH }}/configs/{{ env_type }}/env_vars.yml"
136     - "{{ ANSIBLE_REPO_PATH }}/configs/{{ env_type }}/env_secret_vars.yml"
137   tags:
138     - post_flight_check
139   tasks:
140     - debug:
4a3fbf 141         msg: "Post-Software checks completed successfully"