Zack Williams | 41513bf | 2018-07-07 20:08:35 -0700 | [diff] [blame] | 1 | # 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 Slobodrian | ba9cbd8 | 2017-06-22 11:45:49 -0400 | [diff] [blame] | 14 | # 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 Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 21 | path: "{{ target_voltha_home }}/.ssh" |
Sergio Slobodrian | ba9cbd8 | 2017-06-22 11:45:49 -0400 | [diff] [blame] | 22 | 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 Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 29 | path: "{{ target_voltha_home }}/.ssh/known_hosts" |
Sergio Slobodrian | ba9cbd8 | 2017-06-22 11:45:49 -0400 | [diff] [blame] | 30 | state: absent |
| 31 | tags: [cluster_host] |
| 32 | |
| 33 | - name: Known host checking is disabled |
| 34 | copy: |
| 35 | src: files/ssh_config |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 36 | dest: "{{ target_voltha_home }}/.ssh/config" |
Sergio Slobodrian | ba9cbd8 | 2017-06-22 11:45:49 -0400 | [diff] [blame] | 37 | 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 Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 45 | dest: "{{ target_voltha_home }}" |
Sergio Slobodrian | ba9cbd8 | 2017-06-22 11:45:49 -0400 | [diff] [blame] | 46 | owner: voltha |
| 47 | group: voltha |
| 48 | mode: 0600 |
| 49 | tags: [cluster_host] |
| 50 | |
| 51 | #- name: Required configuration directories are copied |
| 52 | # copy: |
Stephane Barbarie | bcea2f4 | 2018-03-02 18:46:32 -0500 | [diff] [blame] | 53 | # src: "{{ install_source }}/{{ item }}" |
Sergio Slobodrian | ba9cbd8 | 2017-06-22 11:45:49 -0400 | [diff] [blame] | 54 | # 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 Barbarie | bcea2f4 | 2018-03-02 18:46:32 -0500 | [diff] [blame] | 66 | src: "{{ install_source }}/{{ item }}" |
Sergio Slobodrian | ba9cbd8 | 2017-06-22 11:45:49 -0400 | [diff] [blame] | 67 | 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 Slobodrian | 8684370 | 2017-09-05 23:22:39 -0400 | [diff] [blame] | 79 | - name: Required configuration scripts are copied |
| 80 | synchronize: |
Stephane Barbarie | bcea2f4 | 2018-03-02 18:46:32 -0500 | [diff] [blame] | 81 | src: "{{ install_source }}/{{ item }}" |
Sergio Slobodrian | 8684370 | 2017-09-05 23:22:39 -0400 | [diff] [blame] | 82 | 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 Slobodrian | ba9cbd8 | 2017-06-22 11:45:49 -0400 | [diff] [blame] | 104 | - name: apt lists are up-to-date |
Sergio Slobodrian | 5727e98 | 2017-06-28 21:02:27 -0400 | [diff] [blame] | 105 | synchronize: |
Sergio Slobodrian | ba9cbd8 | 2017-06-22 11:45:49 -0400 | [diff] [blame] | 106 | src: "/var/lib/apt/lists" |
Sergio Slobodrian | 5727e98 | 2017-06-28 21:02:27 -0400 | [diff] [blame] | 107 | 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 Slobodrian | ba9cbd8 | 2017-06-22 11:45:49 -0400 | [diff] [blame] | 116 | tags: [cluster_host] |
| 117 | |
Sergio Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 118 | #- name: upstart barrier filesystem loop mount script is installed |
| 119 | # copy: |
Stephane Barbarie | bcea2f4 | 2018-03-02 18:46:32 -0500 | [diff] [blame] | 120 | # src: "{{ install_source }}/losetup.conf" |
Sergio Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 121 | # dest: /etc/init |
| 122 | # owner: root |
| 123 | # group: root |
| 124 | # mode: 0644 |
| 125 | # when: target == "cluster" |
| 126 | # tags: [cluster_host] |
| 127 | |
Sergio Slobodrian | 7c5e885 | 2017-07-31 20:17:14 -0400 | [diff] [blame] | 128 | #- 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] |
sathishg | 11fe23b | 2017-08-07 23:11:17 +0530 | [diff] [blame] | 136 | - name: A voltha directory under /var/log for voltha logs exists |
sathishg | b5d1c18 | 2017-07-13 14:20:19 +0530 | [diff] [blame] | 137 | file: |
sathishg | 11fe23b | 2017-08-07 23:11:17 +0530 | [diff] [blame] | 138 | path: "/var/log/voltha" |
sathishg | b5d1c18 | 2017-07-13 14:20:19 +0530 | [diff] [blame] | 139 | state: directory |
| 140 | tags: [cluster_host] |
| 141 | |
Sergio Slobodrian | f74fa07 | 2017-06-28 09:33:24 -0400 | [diff] [blame] | 142 | - name: Dependent software is installed (this can take about 10 Min, DONT'T PANIC, go for coffee instead) |
Sergio Slobodrian | 8684370 | 2017-09-05 23:22:39 -0400 | [diff] [blame] | 143 | command: "{{ target_voltha_home }}/install_packages.sh" |
| 144 | # command: dpkg -R -i "{{ target_voltha_home }}/deb_files" |
Sergio Slobodrian | ba9cbd8 | 2017-06-22 11:45:49 -0400 | [diff] [blame] | 145 | 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 Slobodrian | 8684370 | 2017-09-05 23:22:39 -0400 | [diff] [blame] | 161 | # To debug package installation, comment this out so review temporary interim |
| 162 | # files. |
| 163 | - name: Configuration directories and files are deleted |
Sergio Slobodrian | ba9cbd8 | 2017-06-22 11:45:49 -0400 | [diff] [blame] | 164 | file: |
| 165 | path: "{{ target_voltha_home }}/{{ item }}" |
| 166 | state: absent |
| 167 | with_items: |
| 168 | - docker-py |
| 169 | - netifaces |
Sergio Slobodrian | 8684370 | 2017-09-05 23:22:39 -0400 | [diff] [blame] | 170 | - sort_packages.sh |
| 171 | - sort_packages.py |
| 172 | - install_packages.sh |
| 173 | - deb_files1 |
| 174 | - deb_files2 |
Sergio Slobodrian | ba9cbd8 | 2017-06-22 11:45:49 -0400 | [diff] [blame] | 175 | when: target == "cluster" |
| 176 | tags: [cluster_host] |
| 177 | |
Sergio Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 178 | - name: Logging barrier file is created |
Sergio Slobodrian | c359b11 | 2017-08-30 16:45:43 -0400 | [diff] [blame] | 179 | command: "fallocate -l {{ logger_volume_size }}G {{ barrier_fs_dir }}/.logger-barrier-file" |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 180 | when: target == "cluster" |
| 181 | tags: [cluster_host] |
| 182 | |
Sergio Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 183 | - name: Registry barrier file is created |
Sergio Slobodrian | c359b11 | 2017-08-30 16:45:43 -0400 | [diff] [blame] | 184 | command: "fallocate -l {{ registry_volume_size }}G {{ barrier_fs_dir }}/.registry-barrier-file" |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 185 | when: target == "cluster" |
| 186 | tags: [cluster_host] |
| 187 | |
Sergio Slobodrian | c359b11 | 2017-08-30 16:45:43 -0400 | [diff] [blame] | 188 | #- 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 Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 192 | |
| 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 Slobodrian | c359b11 | 2017-08-30 16:45:43 -0400 | [diff] [blame] | 203 | #- 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 Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 207 | |
| 208 | - name: The xfs filesystem is created on the replicated barrier file systems |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 209 | filesystem: |
| 210 | fstype: xfs |
Sergio Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 211 | dev: "{{ item }}" |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 212 | opts: -i size=512 |
Sergio Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 213 | with_items: |
| 214 | - /dev/loop0 |
| 215 | - /dev/loop1 |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 216 | when: target == "cluster" |
| 217 | tags: [cluster_host] |
| 218 | |
Sergio Slobodrian | c359b11 | 2017-08-30 16:45:43 -0400 | [diff] [blame] | 219 | #- 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 Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 225 | |
| 226 | - name: The loop devices that are no longer needed are removed |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 227 | command: "losetup -D" |
| 228 | when: target == "cluster" |
| 229 | tags: [cluster_host] |
| 230 | |
Sergio Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 231 | - name: The barrier fileystem files are owned by voltha |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 232 | file: |
Sergio Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 233 | path: "{{ barrier_fs_dir }}/{{ item }}" |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 234 | mode: 0755 |
| 235 | owner: voltha |
| 236 | group: voltha |
Sergio Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 237 | with_items: |
| 238 | - ".registry-barrier-file" |
| 239 | - ".logger-barrier-file" |
Sergio Slobodrian | c359b11 | 2017-08-30 16:45:43 -0400 | [diff] [blame] | 240 | # - ".consul-barrier-file" |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 241 | when: target == "cluster" |
| 242 | tags: [cluster_host] |
| 243 | |
Sergio Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 244 | - name: A mountpoint for the glusterfs registry brick is created |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 245 | file: |
Sergio Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 246 | path: "{{ barrier_fs_dir }}/reg_brick1" |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 247 | state: directory |
| 248 | mode: 0755 |
| 249 | owner: voltha |
| 250 | group: voltha |
| 251 | when: target == "cluster" |
| 252 | tags: [cluster_host] |
| 253 | |
Sergio Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 254 | - 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 Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 265 | mount: |
Sergio Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 266 | path: "{{ barrier_fs_dir }}/reg_brick1" |
| 267 | src: "{{ barrier_fs_dir }}/.registry-barrier-file" |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 268 | fstype: xfs |
| 269 | opts: loop |
| 270 | state: mounted |
| 271 | when: target == "cluster" |
| 272 | tags: [cluster_host] |
| 273 | |
Sergio Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 274 | - 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 Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 285 | file: |
Sergio Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 286 | 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 Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 297 | state: directory |
| 298 | mode: 0755 |
| 299 | owner: voltha |
| 300 | group: voltha |
| 301 | when: target == "cluster" |
| 302 | tags: [cluster_host] |
| 303 | |
Sergio Slobodrian | d49da36 | 2017-08-24 16:54:53 -0400 | [diff] [blame] | 304 | - name: Directories for voltha processes are created |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 305 | file: |
Sergio Slobodrian | d49da36 | 2017-08-24 16:54:53 -0400 | [diff] [blame] | 306 | path: "{{ target_voltha_dir }}/{{ item }}" |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 307 | state: directory |
| 308 | mode: 0755 |
| 309 | owner: voltha |
| 310 | group: voltha |
Sergio Slobodrian | d49da36 | 2017-08-24 16:54:53 -0400 | [diff] [blame] | 311 | with_items: |
| 312 | - registry_data |
| 313 | - consul/data |
| 314 | - consul/config |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 315 | when: target == "cluster" |
| 316 | tags: [cluster_host] |
| 317 | |
Sergio Slobodrian | c359b11 | 2017-08-30 16:45:43 -0400 | [diff] [blame] | 318 | #- 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 Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 327 | |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 328 | - name: The glusterfs service is started |
| 329 | service: |
Stephane Barbarie | 2cbffca | 2018-03-26 16:20:03 -0400 | [diff] [blame] | 330 | name: glusterd |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 331 | enabled: yes |
| 332 | state: started |
| 333 | when: target == "cluster" |
| 334 | tags: [cluster_host] |
| 335 | |
Sergio Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 336 | - name: The replicated registry filesystem is mounted on boot |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 337 | 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 Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 345 | |
| 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] |