blob: ac1e2e2165c271793db3b857b27bb71de44e3706 [file] [log] [blame]
Sergio Slobodrianba9cbd82017-06-22 11:45:49 -04001# Note: When the target == "cluster" the installer
2# is running to install voltha in the cluster hosts.
3# Whe the target == "installer" the installer is being
4# created.
5- name: A .ssh directory for the voltha user exists
6 file:
7 #path: "{{ ansible_env['HOME'] }}/.ssh"
Sergio Slobodrian523ee782017-08-22 16:44:21 -04008 path: "{{ target_voltha_home }}/.ssh"
Sergio Slobodrianba9cbd82017-06-22 11:45:49 -04009 state: directory
10 owner: voltha
11 group: voltha
12 tags: [cluster_host]
13
14- name: known_hosts file is absent for the voltha user
15 file:
Sergio Slobodrian523ee782017-08-22 16:44:21 -040016 path: "{{ target_voltha_home }}/.ssh/known_hosts"
Sergio Slobodrianba9cbd82017-06-22 11:45:49 -040017 state: absent
18 tags: [cluster_host]
19
20- name: Known host checking is disabled
21 copy:
22 src: files/ssh_config
Sergio Slobodrian523ee782017-08-22 16:44:21 -040023 dest: "{{ target_voltha_home }}/.ssh/config"
Sergio Slobodrianba9cbd82017-06-22 11:45:49 -040024 owner: voltha
25 group: voltha
26 mode: 0600
27 tags: [cluster_host]
28
29- name: Cluster host keys are propagated to all hosts in the cluster
30 copy:
31 src: files/.keys
Sergio Slobodrian523ee782017-08-22 16:44:21 -040032 dest: "{{ target_voltha_home }}"
Sergio Slobodrianba9cbd82017-06-22 11:45:49 -040033 owner: voltha
34 group: voltha
35 mode: 0600
36 tags: [cluster_host]
37
38#- name: Required configuration directories are copied
39# copy:
40# src: "/home/vinstall/{{ item }}"
41# dest: "{{ target_voltha_home }}"
42# owner: voltha
43# group: voltha
44# with_items:
45# - docker-py
46# - netifaces
47# - deb_files
48# when: target == "cluster"
49# tags: [cluster_host]
50
51- name: Required configuration directories are copied
52 synchronize:
53 src: "/home/vinstall/{{ item }}"
54 dest: "{{ target_voltha_home }}"
55 archive: no
56 owner: no
57 perms: no
58 recursive: yes
59 links: yes
60 with_items:
61 - docker-py
62 - netifaces
63 - deb_files
64 tags: [cluster-host]
65
66- name: apt lists are up-to-date
Sergio Slobodrian5727e982017-06-28 21:02:27 -040067 synchronize:
Sergio Slobodrianba9cbd82017-06-22 11:45:49 -040068 src: "/var/lib/apt/lists"
Sergio Slobodrian5727e982017-06-28 21:02:27 -040069 dest: "/var/lib/apt/lists"
70 archive: no
71 owner: no
72 perms: no
73 rsync_opts:
74 - "--exclude=lock"
75 - "--exclude=partial"
76 recursive: yes
77 links: yes
Sergio Slobodrianba9cbd82017-06-22 11:45:49 -040078 tags: [cluster_host]
79
Sergio Slobodrian7c5e8852017-07-31 20:17:14 -040080#- name: pre-emptive strike to avoid errors during package installation
81# apt:
82# name: "{{ item }}"
83# state: absent
84# with_items:
85# - ubuntu-core-launcher
86# - snapd
87# tags: [cluster_host]
sathishg11fe23b2017-08-07 23:11:17 +053088- name: A voltha directory under /var/log for voltha logs exists
sathishgb5d1c182017-07-13 14:20:19 +053089 file:
sathishg11fe23b2017-08-07 23:11:17 +053090 path: "/var/log/voltha"
sathishgb5d1c182017-07-13 14:20:19 +053091 state: directory
92 tags: [cluster_host]
93
Sergio Slobodrianf74fa072017-06-28 09:33:24 -040094- name: Dependent software is installed (this can take about 10 Min, DONT'T PANIC, go for coffee instead)
Sergio Slobodrianba9cbd82017-06-22 11:45:49 -040095 command: dpkg -R -i "{{ target_voltha_home }}/deb_files"
96# ignore_errors: true
97 when: target == "cluster"
98 tags: [cluster_host]
99
100#- name: Dependent software is initialized
101# command: apt-get -y -f install
102# when: target == "cluster"
103# tags: [cluster_host]
104
105- name: Python packages are installed
106 command: pip install {{ item }} --no-index --find-links "file://{{ target_voltha_home }}/{{ item }}"
107 with_items:
108 - docker-py
109 - netifaces
110 when: target == "cluster"
111 tags: [cluster_host]
112
113- name: Configuration directories are deleted
114 file:
115 path: "{{ target_voltha_home }}/{{ item }}"
116 state: absent
117 with_items:
118 - docker-py
119 - netifaces
120 - deb_files
121 when: target == "cluster"
122 tags: [cluster_host]
123
Sergio Slobodrian523ee782017-08-22 16:44:21 -0400124- name: Replicated filesystem file is created
125 command: "dd if=/dev/zero of={{ replicated_fs_dir }}/.cluster-fs-file bs=100M count=100"
126 when: target == "cluster"
127 tags: [cluster_host]
128
129- name: The loop device is set up for file system creation
130 command: "losetup -f {{ replicated_fs_dir }}/.cluster-fs-file"
131 when: target == "cluster"
132 tags: [cluster_host]
133
134- name: The xfs filesystem is created on the loop device
135 filesystem:
136 fstype: xfs
137 dev: /dev/loop0
138 opts: -i size=512
139 when: target == "cluster"
140 tags: [cluster_host]
141
142- name: The loop device that's no longer needed is removed
143 command: "losetup -D"
144 when: target == "cluster"
145 tags: [cluster_host]
146
147- name: The registry fileystem file is owned by voltha
148 file:
149 path: "{{ replicated_fs_dir }}/.cluster-fs-file"
150 mode: 0755
151 owner: voltha
152 group: voltha
153 when: target == "cluster"
154 tags: [cluster_host]
155
156- name: A brick for a glusterfs mountpoint is created
157 file:
158 path: "{{ replicated_fs_dir }}/brick1"
159 state: directory
160 mode: 0755
161 owner: voltha
162 group: voltha
163 when: target == "cluster"
164 tags: [cluster_host]
165
166- name: The replicated filesystem is mounted on boot
167 mount:
168 path: "{{ replicated_fs_dir }}/brick1"
169 src: "{{ replicated_fs_dir }}/.cluster-fs-file"
170 fstype: xfs
171 opts: loop
172 state: mounted
173 when: target == "cluster"
174 tags: [cluster_host]
175
176- name: A directory for the glusterfs volume is created
177 file:
178 path: "{{ replicated_fs_dir }}/brick1/registry_volume"
179 state: directory
180 mode: 0755
181 owner: voltha
182 group: voltha
183 when: target == "cluster"
184 tags: [cluster_host]
185
186- name: A directory for the insecure registry data is created
187 file:
188 path: "{{ target_voltha_dir }}/registry_data"
189 state: directory
190 mode: 0755
191 owner: voltha
192 group: voltha
193 when: target == "cluster"
194 tags: [cluster_host]
195
196- name: A directory for consul's data is created
197 file:
198 path: "{{ target_voltha_dir }}/consul/data"
199 state: directory
200 mode: 0755
201 owner: voltha
202 group: voltha
203 when: target == "cluster"
204 tags: [cluster_host]
205
206- name: The glusterfs service is started
207 service:
208 name: glusterfs-server
209 enabled: yes
210 state: started
211 when: target == "cluster"
212 tags: [cluster_host]
213
214- name: The replicated filesystem is mounted on boot
215 mount:
216 path: "{{ target_voltha_dir }}/registry_data"
217 src: "{{ inventory_hostname }}:/registry_volume"
218 fstype: glusterfs
219 opts: "defaults,_netdev,noauto,x-systemd.automount"
220 state: present
221 when: target == "cluster"
222 tags: [cluster_host]