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