bm onboard fix
[ta/caas-lcm.git] / su / roles / su_prepare / tasks / main.yml
1 ---
2 # Copyright 2019 Nokia
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 - set_fact:
17     start_time: "{{ lookup('pipe', 'date +%Y%m%d-%H:%M:%S') }}"
18
19 - file:
20     path: "/var/log/sw_package_load.log"
21     state: absent
22   become: true
23
24
25 - lineinfile:
26     dest: "/var/log/sw_package_load.log"
27     create: yes
28     line: "start_time: {{ start_time }}"
29   become: true
30
31 - block:
32     - name: Compose the device path of swift volume on BareMetal
33       set_fact:
34         swift_dev: "{{ swift_image_path }}"
35
36     - name: Run what_is_the_filesystem.yml
37       include_role:
38         name: common_tasks
39         tasks_from: what_is_the_filesystem.yml
40       vars:
41         device: "{{swift_dev}}"
42
43     - name: Mount the device
44       mount:
45         name: /srv/node/swift-update/
46         src: "{{swift_dev}}"
47         fstype: "{{ filesystem_type.stdout | lower | default('ext4') }}"
48         state: mounted
49       become: true
50   when: swift_image_path is defined and swift_image_path != ""
51
52 - name: Prepare mount dir
53   file:
54     path: /srv/node/swift-update/
55     state: directory
56     mode: 0755
57     owner: 146
58     group: 146
59     recurse: yes
60   become: true
61
62 - block:
63     - include: tasks/start_vnfc.yml
64       vars:
65         vnfcs:
66           - swift_update
67           - swift_update_service
68           - docker-registry-update
69           - update_registry_service
70
71     - include: tasks/wait_pod_start.yml
72       vars:
73         name: swift-update
74         ccount: 1
75
76     - name: wait for container service - swift-update
77       wait_for:
78         host: "{{ groups.caas_master[0] }}"
79         port: "{{ caas.update_swift_port }}"
80         state: started
81         timeout: 300
82
83     - include: tasks/wait_pod_start.yml
84       vars:
85         name: registry-update
86         ccount: 1
87
88     - name: wait for registry-update kubernetes service to start
89       wait_for:
90         host: "{{ caas.update_registry_url }}"
91         port: "{{ caas.update_registry_port }}"
92         state: started
93         timeout: 60
94
95
96     - name: wait for swift-update kubernetes service to start
97       wait_for:
98         host: "{{ caas.swift_update_url }}"
99         port: "{{ caas.update_swift_port }}"
100         state: started
101         timeout: 60
102
103     - include: merge-charts.yml
104     - include: merge-images.yml
105
106   rescue:
107     - debug:
108         msg: Something went wrong during merge.
109
110   always:
111     - name: clean after charts upload
112       file:
113         state: absent
114         path: /tmp/su_chart
115
116     - name: Delete the registry and swift for su
117       shell: kubectl delete -f {{ manifests_directory }}/{{item}}
118       with_items:
119         - update_registry_service.yml
120         - docker-registry-update.yml
121         - swift_update_service.yml
122         - swift_update.yml
123
124     - name: Wait for registry and swift deleted
125       shell: kubectl get pods --all-namespaces | grep -c {{item}}
126       register: ret_rc
127       until: ret_rc.stdout == "0"
128       failed_when: ret_rc.stdout == ""
129       retries: 60
130       delay: 5
131       with_items:
132         - swift-update
133         - registry-update
134
135     - name: Umount the device of the new swift volume
136       mount:
137         name: /srv/node/swift-update/
138         src: "{{swift_dev}}"
139         state: unmounted
140       become: true
141
142     - name: Make sure the fstab entry is removed
143       mount:
144         name: /srv/node/swift-update/
145         src: "{{swift_dev}}"
146         state: absent
147       become: true
148
149     - lineinfile:
150         dest: "/var/log/sw_package_load.log"
151         state: present
152         line: "end_time: {{ lookup('pipe', 'date +%Y%m%d-%H:%M:%S') }}"
153       become: true
154