sborenst
2018-09-06 febf59bde588523e1a1bf7f654116eb6e1b301ec
commit | author | age
a2f44a 1 ---
WK 2 - name: Step 00xxxxx post software
3   hosts: bastions
4   become: yes
5   gather_facts: False
6   vars_files:
7   - "{{ ANSIBLE_REPO_PATH }}/configs/{{ env_type }}/env_vars.yml"
8   tasks:
9   - debug:
10     msg: "Post-Software Steps starting"
11
12   - name: Set hostname fact
13     set_fact:
14       hostname: "{{ ansible_hostname}}.{{subdomain_base}}"
15   - name: Set hostname
16     hostname:
17       name: "{{ hostname }}"
18   - name: Make hostname permanent
19     command: "echo {{ hostname }} > /etc/hostname"
20   - name: Ensure software is installed
21     yum:
22       name: "{{ item }}"
23       state: latest
24     with_items:
25     - git
26     - vim
27     - ansible
28     - docker
29   - name: Copy docker registries.conf file
30     copy:
31       src: ./files/registries.conf
32       dest: /etc/containers/registries.conf
33       mode: 0644
34       owner: root
35       group: root
36   - name: Restart docker
37     systemd:
38       name: docker
39       state: restarted
40   - name: Install AAD
41     git:
42       repo: https://github.com/sborenst/ansible_agnostic_deployer
43       clone: yes
44       dest: "/root/ansible_agnostic_deployer"
45       version: "development"
25666e 46
WK 47   - name: Set OpenShift root config directory
48     set_fact:
49       ocp_root: "/var/lib/openshift"
50
811e58 51   - name: Ensure OpenShift config directory exists
25666e 52     file:
WK 53       path: "{{ ocp_root }}"
54       state: directory
55       owner: root
56       group: root
57       mode: 0775
811e58 58
WK 59   - name: Ensure OpenShift config subdirectories exists for OCP 3.9
60     file:
61       path: "{{ item }}"
62       state: directory
63       owner: root
64       group: root
65       mode: 0775
66     with_items:
67     - "{{ ocp_root }}/config"
68     - "{{ ocp_root }}/data"
69     - "{{ ocp_root }}/pv"
70     - "{{ ocp_root }}/volumes"
71     when:
72     - osrelease is version_compare("3.10", "<")
a2f44a 73
WK 74   - name: Create oc_cluster system service
75     template:
76       src: ./files/oc-cluster.service.j2
77       dest: "/usr/lib/systemd/system/oc-cluster.service"
78
79   - name: Enable and start oc-cluster system service
80     systemd:
338c9e 81       name: oc-cluster
a2f44a 82       enabled: yes
WK 83       state: started
0e3a36 84     register: r_systemd
GC 85     ignore_errors: yes
86
87   # there is a bug that happens sometimes (1/100),
88   # the service is in fail state. Reboot fixes the issue.
811e58 89   - name: Restart VM in case of Service Start failure
WK 90     when: r_systemd is failed
0e3a36 91     block:
GC 92       - name: Reboot VM
93         command: shutdown -r now
0e1aa0 94         ignore_errors: yes
0e3a36 95
GC 96       - name: wait for linux host to be available (retry)
97         wait_for_connection:
98           delay: 60
99           timeout: 200
100
101       - ping:
102         register: rping
103         retries: 3
104         delay: 10
105         until: rping is succeeded
106
107       - name: Retry to enable and start oc-cluster system service
108         systemd:
109           name: oc-cluster
110           enabled: yes
111           state: started
112
a2f44a 113   - name: Wait for oc-cluster to be up and running
WK 114     wait_for:
115       host: "{{ hostname }}"
116       port: 8443
117       sleep: 2
118   - name: Check if cluster is already set up
119     stat:
120       path: /root/.setupcomplete
121     register: occluster_setup
122   - name: Setup and configure oc cluster
123     when: not occluster_setup.stat.exists
124     block:
125     - name: Login as system:admin
126       shell: "oc login -u system:admin"
127     - name: Deploy workloads into cluster
25666e 128       shell: 'ansible-playbook -i localhost, -c local /root/ansible_agnostic_deployer/ansible/configs/ocp-workloads/ocp-workload.yml -e"ANSIBLE_REPO_PATH=/root/ansible_agnostic_deployer/ansible" -e"ocp_username=developer" -e"ocp_workload={{ item }}" -e"guid=a1001" -e"ocp_user_needs_quota=false" -e"ocp_domain=https://{{ hostname }}:8443"  -e"ACTION=create"'
a2f44a 129       chdir: /root/ansible_agnostic_deployer
WK 130       with_items: "{{ student_workloads.split(',')|list }}"
131     - name: Touch setup file
132       command: touch /root/.setupcomplete
133
134 - name: PostSoftware flight-check
135   hosts: localhost
136   connection: local
137   gather_facts: false
138   become: false
139   vars_files:
140   - "{{ ANSIBLE_REPO_PATH }}/configs/{{ env_type }}/env_vars.yml"
141   - "{{ ANSIBLE_REPO_PATH }}/configs/{{ env_type }}/env_secret_vars.yml"
142   tags:
143   - post_flight_check
144   tasks:
145   - debug:
146       msg: "Post-Software checks completed successfully"