blob: ed92190a1d47fb4963c4ef37dbf3e5ea60cf6a57 [file] [log] [blame]
Zack Williams41513bf2018-07-07 20:08:35 -07001# Copyright 2017-present Open Networking Foundation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
Sergio Slobodrianba9cbd82017-06-22 11:45:49 -040014# Note: When the target == "cluster" the installer
15# is running to install voltha in the cluster hosts.
16# Whe the target == "installer" the installer is being
17# created.
18- name: A .ssh directory for the voltha user exists
19 file:
20 #path: "{{ ansible_env['HOME'] }}/.ssh"
Sergio Slobodrian523ee782017-08-22 16:44:21 -040021 path: "{{ target_voltha_home }}/.ssh"
Sergio Slobodrianba9cbd82017-06-22 11:45:49 -040022 state: directory
23 owner: voltha
24 group: voltha
25 tags: [cluster_host]
26
27- name: known_hosts file is absent for the voltha user
28 file:
Sergio Slobodrian523ee782017-08-22 16:44:21 -040029 path: "{{ target_voltha_home }}/.ssh/known_hosts"
Sergio Slobodrianba9cbd82017-06-22 11:45:49 -040030 state: absent
31 tags: [cluster_host]
32
33- name: Known host checking is disabled
34 copy:
35 src: files/ssh_config
Sergio Slobodrian523ee782017-08-22 16:44:21 -040036 dest: "{{ target_voltha_home }}/.ssh/config"
Sergio Slobodrianba9cbd82017-06-22 11:45:49 -040037 owner: voltha
38 group: voltha
39 mode: 0600
40 tags: [cluster_host]
41
42- name: Cluster host keys are propagated to all hosts in the cluster
43 copy:
44 src: files/.keys
Sergio Slobodrian523ee782017-08-22 16:44:21 -040045 dest: "{{ target_voltha_home }}"
Sergio Slobodrianba9cbd82017-06-22 11:45:49 -040046 owner: voltha
47 group: voltha
48 mode: 0600
49 tags: [cluster_host]
50
51#- name: Required configuration directories are copied
52# copy:
Stephane Barbariebcea2f42018-03-02 18:46:32 -050053# src: "{{ install_source }}/{{ item }}"
Sergio Slobodrianba9cbd82017-06-22 11:45:49 -040054# dest: "{{ target_voltha_home }}"
55# owner: voltha
56# group: voltha
57# with_items:
58# - docker-py
59# - netifaces
60# - deb_files
61# when: target == "cluster"
62# tags: [cluster_host]
63
64- name: Required configuration directories are copied
65 synchronize:
Stephane Barbariebcea2f42018-03-02 18:46:32 -050066 src: "{{ install_source }}/{{ item }}"
Sergio Slobodrianba9cbd82017-06-22 11:45:49 -040067 dest: "{{ target_voltha_home }}"
68 archive: no
69 owner: no
70 perms: no
71 recursive: yes
72 links: yes
73 with_items:
74 - docker-py
75 - netifaces
76 - deb_files
77 tags: [cluster-host]
78
Sergio Slobodrian86843702017-09-05 23:22:39 -040079- name: Required configuration scripts are copied
80 synchronize:
Stephane Barbariebcea2f42018-03-02 18:46:32 -050081 src: "{{ install_source }}/{{ item }}"
Sergio Slobodrian86843702017-09-05 23:22:39 -040082 dest: "{{ target_voltha_home }}"
83 archive: no
84 owner: no
85 perms: no
86 recursive: no
87 links: yes
88 with_items:
89 - sort_packages.sh
90 - sort_packages.py
91 - install_packages.sh
92 tags: [cluster-host]
93
94- name: The installer scripts are made executable
95 file:
96 path: "{{target_voltha_home }}/{{ item }}"
97 mode: 0744
98 with_items:
99 - sort_packages.sh
100 - sort_packages.py
101 - install_packages.sh
102 tags: [installer]
103
Sergio Slobodrianba9cbd82017-06-22 11:45:49 -0400104- name: apt lists are up-to-date
Sergio Slobodrian5727e982017-06-28 21:02:27 -0400105 synchronize:
Sergio Slobodrianba9cbd82017-06-22 11:45:49 -0400106 src: "/var/lib/apt/lists"
Sergio Slobodrian5727e982017-06-28 21:02:27 -0400107 dest: "/var/lib/apt/lists"
108 archive: no
109 owner: no
110 perms: no
111 rsync_opts:
112 - "--exclude=lock"
113 - "--exclude=partial"
114 recursive: yes
115 links: yes
Sergio Slobodrianba9cbd82017-06-22 11:45:49 -0400116 tags: [cluster_host]
117
Sergio Slobodrian8725ea82017-08-27 23:47:41 -0400118#- name: upstart barrier filesystem loop mount script is installed
119# copy:
Stephane Barbariebcea2f42018-03-02 18:46:32 -0500120# src: "{{ install_source }}/losetup.conf"
Sergio Slobodrian8725ea82017-08-27 23:47:41 -0400121# dest: /etc/init
122# owner: root
123# group: root
124# mode: 0644
125# when: target == "cluster"
126# tags: [cluster_host]
127
Sergio Slobodrian7c5e8852017-07-31 20:17:14 -0400128#- name: pre-emptive strike to avoid errors during package installation
129# apt:
130# name: "{{ item }}"
131# state: absent
132# with_items:
133# - ubuntu-core-launcher
134# - snapd
135# tags: [cluster_host]
sathishg11fe23b2017-08-07 23:11:17 +0530136- name: A voltha directory under /var/log for voltha logs exists
sathishgb5d1c182017-07-13 14:20:19 +0530137 file:
sathishg11fe23b2017-08-07 23:11:17 +0530138 path: "/var/log/voltha"
sathishgb5d1c182017-07-13 14:20:19 +0530139 state: directory
140 tags: [cluster_host]
141
Sergio Slobodrianf74fa072017-06-28 09:33:24 -0400142- name: Dependent software is installed (this can take about 10 Min, DONT'T PANIC, go for coffee instead)
Sergio Slobodrian86843702017-09-05 23:22:39 -0400143 command: "{{ target_voltha_home }}/install_packages.sh"
144# command: dpkg -R -i "{{ target_voltha_home }}/deb_files"
Sergio Slobodrianba9cbd82017-06-22 11:45:49 -0400145 when: target == "cluster"
146 tags: [cluster_host]
147
148#- name: Dependent software is initialized
149# command: apt-get -y -f install
150# when: target == "cluster"
151# tags: [cluster_host]
152
153- name: Python packages are installed
154 command: pip install {{ item }} --no-index --find-links "file://{{ target_voltha_home }}/{{ item }}"
155 with_items:
156 - docker-py
157 - netifaces
158 when: target == "cluster"
159 tags: [cluster_host]
160
Sergio Slobodrian86843702017-09-05 23:22:39 -0400161# To debug package installation, comment this out so review temporary interim
162# files.
163- name: Configuration directories and files are deleted
Sergio Slobodrianba9cbd82017-06-22 11:45:49 -0400164 file:
165 path: "{{ target_voltha_home }}/{{ item }}"
166 state: absent
167 with_items:
168 - docker-py
169 - netifaces
Sergio Slobodrian86843702017-09-05 23:22:39 -0400170 - sort_packages.sh
171 - sort_packages.py
172 - install_packages.sh
173 - deb_files1
174 - deb_files2
Sergio Slobodrianba9cbd82017-06-22 11:45:49 -0400175 when: target == "cluster"
176 tags: [cluster_host]
177
Sergio Slobodrian8725ea82017-08-27 23:47:41 -0400178- name: Logging barrier file is created
Sergio Slobodrianc359b112017-08-30 16:45:43 -0400179 command: "fallocate -l {{ logger_volume_size }}G {{ barrier_fs_dir }}/.logger-barrier-file"
Sergio Slobodrian523ee782017-08-22 16:44:21 -0400180 when: target == "cluster"
181 tags: [cluster_host]
182
Sergio Slobodrian8725ea82017-08-27 23:47:41 -0400183- name: Registry barrier file is created
Sergio Slobodrianc359b112017-08-30 16:45:43 -0400184 command: "fallocate -l {{ registry_volume_size }}G {{ barrier_fs_dir }}/.registry-barrier-file"
Sergio Slobodrian523ee782017-08-22 16:44:21 -0400185 when: target == "cluster"
186 tags: [cluster_host]
187
Sergio Slobodrianc359b112017-08-30 16:45:43 -0400188#- name: Consul barrier file is created
189# command: "fallocate -l {{ consul_volume_size }}G {{ barrier_fs_dir }}/.consul-barrier-file"
190# when: target == "cluster"
191# tags: [cluster_host]
Sergio Slobodrian8725ea82017-08-27 23:47:41 -0400192
193- name: The logging barrier file is set up as a loop device
194 command: "losetup /dev/loop0 {{ barrier_fs_dir }}/.logger-barrier-file"
195 when: target == "cluster"
196 tags: [cluster_host]
197
198- name: The registry barrier file is set up as a loop device
199 command: "losetup /dev/loop1 {{ barrier_fs_dir }}/.registry-barrier-file"
200 when: target == "cluster"
201 tags: [cluster_host]
202
Sergio Slobodrianc359b112017-08-30 16:45:43 -0400203#- name: The consul barrier file is set up as a loop device
204# command: "losetup /dev/loop2 {{ barrier_fs_dir }}/.consul-barrier-file"
205# when: target == "cluster"
206# tags: [cluster_host]
Sergio Slobodrian8725ea82017-08-27 23:47:41 -0400207
208- name: The xfs filesystem is created on the replicated barrier file systems
Sergio Slobodrian523ee782017-08-22 16:44:21 -0400209 filesystem:
210 fstype: xfs
Sergio Slobodrian8725ea82017-08-27 23:47:41 -0400211 dev: "{{ item }}"
Sergio Slobodrian523ee782017-08-22 16:44:21 -0400212 opts: -i size=512
Sergio Slobodrian8725ea82017-08-27 23:47:41 -0400213 with_items:
214 - /dev/loop0
215 - /dev/loop1
Sergio Slobodrian523ee782017-08-22 16:44:21 -0400216 when: target == "cluster"
217 tags: [cluster_host]
218
Sergio Slobodrianc359b112017-08-30 16:45:43 -0400219#- name: The ext4 filesystem is created on the consul barrier volume
220# filesystem:
221# fstype: ext4
222# dev: /dev/loop2
223# when: target == "cluster"
224# tags: [cluster_host]
Sergio Slobodrian8725ea82017-08-27 23:47:41 -0400225
226- name: The loop devices that are no longer needed are removed
Sergio Slobodrian523ee782017-08-22 16:44:21 -0400227 command: "losetup -D"
228 when: target == "cluster"
229 tags: [cluster_host]
230
Sergio Slobodrian8725ea82017-08-27 23:47:41 -0400231- name: The barrier fileystem files are owned by voltha
Sergio Slobodrian523ee782017-08-22 16:44:21 -0400232 file:
Sergio Slobodrian8725ea82017-08-27 23:47:41 -0400233 path: "{{ barrier_fs_dir }}/{{ item }}"
Sergio Slobodrian523ee782017-08-22 16:44:21 -0400234 mode: 0755
235 owner: voltha
236 group: voltha
Sergio Slobodrian8725ea82017-08-27 23:47:41 -0400237 with_items:
238 - ".registry-barrier-file"
239 - ".logger-barrier-file"
Sergio Slobodrianc359b112017-08-30 16:45:43 -0400240# - ".consul-barrier-file"
Sergio Slobodrian523ee782017-08-22 16:44:21 -0400241 when: target == "cluster"
242 tags: [cluster_host]
243
Sergio Slobodrian8725ea82017-08-27 23:47:41 -0400244- name: A mountpoint for the glusterfs registry brick is created
Sergio Slobodrian523ee782017-08-22 16:44:21 -0400245 file:
Sergio Slobodrian8725ea82017-08-27 23:47:41 -0400246 path: "{{ barrier_fs_dir }}/reg_brick1"
Sergio Slobodrian523ee782017-08-22 16:44:21 -0400247 state: directory
248 mode: 0755
249 owner: voltha
250 group: voltha
251 when: target == "cluster"
252 tags: [cluster_host]
253
Sergio Slobodrian8725ea82017-08-27 23:47:41 -0400254- name: A mountpoint for the glusterfs logging brick is created
255 file:
256 path: "{{ barrier_fs_dir }}/log_brick1"
257 state: directory
258 mode: 0755
259 owner: voltha
260 group: voltha
261 when: target == "cluster"
262 tags: [cluster_host]
263
264- name: The replicated registry filesystem is mounted on boot
Sergio Slobodrian523ee782017-08-22 16:44:21 -0400265 mount:
Sergio Slobodrian8725ea82017-08-27 23:47:41 -0400266 path: "{{ barrier_fs_dir }}/reg_brick1"
267 src: "{{ barrier_fs_dir }}/.registry-barrier-file"
Sergio Slobodrian523ee782017-08-22 16:44:21 -0400268 fstype: xfs
269 opts: loop
270 state: mounted
271 when: target == "cluster"
272 tags: [cluster_host]
273
Sergio Slobodrian8725ea82017-08-27 23:47:41 -0400274- name: The replicated logger filesystem is mounted on boot
275 mount:
276 path: "{{ barrier_fs_dir }}/log_brick1"
277 src: "{{ barrier_fs_dir }}/.logger-barrier-file"
278 fstype: xfs
279 opts: loop
280 state: mounted
281 when: target == "cluster"
282 tags: [cluster_host]
283
284- name: A directory for the registry glusterfs volume is created
Sergio Slobodrian523ee782017-08-22 16:44:21 -0400285 file:
Sergio Slobodrian8725ea82017-08-27 23:47:41 -0400286 path: "{{ barrier_fs_dir }}/reg_brick1/registry_volume"
287 state: directory
288 mode: 0755
289 owner: voltha
290 group: voltha
291 when: target == "cluster"
292 tags: [cluster_host]
293
294- name: A directory for the logging glusterfs volume is created
295 file:
296 path: "{{ barrier_fs_dir }}/log_brick1/logging_volume"
Sergio Slobodrian523ee782017-08-22 16:44:21 -0400297 state: directory
298 mode: 0755
299 owner: voltha
300 group: voltha
301 when: target == "cluster"
302 tags: [cluster_host]
303
Sergio Slobodriand49da362017-08-24 16:54:53 -0400304- name: Directories for voltha processes are created
Sergio Slobodrian523ee782017-08-22 16:44:21 -0400305 file:
Sergio Slobodriand49da362017-08-24 16:54:53 -0400306 path: "{{ target_voltha_dir }}/{{ item }}"
Sergio Slobodrian523ee782017-08-22 16:44:21 -0400307 state: directory
308 mode: 0755
309 owner: voltha
310 group: voltha
Sergio Slobodriand49da362017-08-24 16:54:53 -0400311 with_items:
312 - registry_data
313 - consul/data
314 - consul/config
Sergio Slobodrian523ee782017-08-22 16:44:21 -0400315 when: target == "cluster"
316 tags: [cluster_host]
317
Sergio Slobodrianc359b112017-08-30 16:45:43 -0400318#- name: The consul data filesystem is mounted on boot
319# mount:
320# path: "{{ target_voltha_dir }}/consul/data"
321# src: "{{ barrier_fs_dir }}/.consul-barrier-file"
322# fstype: ext4
323# opts: loop
324# state: mounted
325# when: target == "cluster"
326# tags: [cluster_host]
Sergio Slobodrian8725ea82017-08-27 23:47:41 -0400327
Sergio Slobodrian523ee782017-08-22 16:44:21 -0400328- name: The glusterfs service is started
329 service:
Stephane Barbarie2cbffca2018-03-26 16:20:03 -0400330 name: glusterd
Sergio Slobodrian523ee782017-08-22 16:44:21 -0400331 enabled: yes
332 state: started
333 when: target == "cluster"
334 tags: [cluster_host]
335
Sergio Slobodrian8725ea82017-08-27 23:47:41 -0400336- name: The replicated registry filesystem is mounted on boot
Sergio Slobodrian523ee782017-08-22 16:44:21 -0400337 mount:
338 path: "{{ target_voltha_dir }}/registry_data"
339 src: "{{ inventory_hostname }}:/registry_volume"
340 fstype: glusterfs
341 opts: "defaults,_netdev,noauto,x-systemd.automount"
342 state: present
343 when: target == "cluster"
344 tags: [cluster_host]
Sergio Slobodrian8725ea82017-08-27 23:47:41 -0400345
346- name: The replicated logging filesystem is mounted on boot
347 mount:
348 path: "/var/log/voltha"
349 src: "{{ inventory_hostname }}:/logging_volume"
350 fstype: glusterfs
351 opts: "defaults,_netdev,noauto,x-systemd.automount"
352 state: present
353 when: target == "cluster"
354 tags: [cluster_host]