Sergio Slobodrian | ba9cbd8 | 2017-06-22 11:45:49 -0400 | [diff] [blame] | 1 | # 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 Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 8 | path: "{{ target_voltha_home }}/.ssh" |
Sergio Slobodrian | ba9cbd8 | 2017-06-22 11:45:49 -0400 | [diff] [blame] | 9 | 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 Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 16 | path: "{{ target_voltha_home }}/.ssh/known_hosts" |
Sergio Slobodrian | ba9cbd8 | 2017-06-22 11:45:49 -0400 | [diff] [blame] | 17 | state: absent |
| 18 | tags: [cluster_host] |
| 19 | |
| 20 | - name: Known host checking is disabled |
| 21 | copy: |
| 22 | src: files/ssh_config |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 23 | dest: "{{ target_voltha_home }}/.ssh/config" |
Sergio Slobodrian | ba9cbd8 | 2017-06-22 11:45:49 -0400 | [diff] [blame] | 24 | 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 Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 32 | dest: "{{ target_voltha_home }}" |
Sergio Slobodrian | ba9cbd8 | 2017-06-22 11:45:49 -0400 | [diff] [blame] | 33 | 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 | |
Sergio Slobodrian | 8684370 | 2017-09-05 23:22:39 -0400 | [diff] [blame] | 66 | - name: Required configuration scripts are copied |
| 67 | synchronize: |
| 68 | src: "/home/vinstall/{{ item }}" |
| 69 | dest: "{{ target_voltha_home }}" |
| 70 | archive: no |
| 71 | owner: no |
| 72 | perms: no |
| 73 | recursive: no |
| 74 | links: yes |
| 75 | with_items: |
| 76 | - sort_packages.sh |
| 77 | - sort_packages.py |
| 78 | - install_packages.sh |
| 79 | tags: [cluster-host] |
| 80 | |
| 81 | - name: The installer scripts are made executable |
| 82 | file: |
| 83 | path: "{{target_voltha_home }}/{{ item }}" |
| 84 | mode: 0744 |
| 85 | with_items: |
| 86 | - sort_packages.sh |
| 87 | - sort_packages.py |
| 88 | - install_packages.sh |
| 89 | tags: [installer] |
| 90 | |
Sergio Slobodrian | ba9cbd8 | 2017-06-22 11:45:49 -0400 | [diff] [blame] | 91 | - name: apt lists are up-to-date |
Sergio Slobodrian | 5727e98 | 2017-06-28 21:02:27 -0400 | [diff] [blame] | 92 | synchronize: |
Sergio Slobodrian | ba9cbd8 | 2017-06-22 11:45:49 -0400 | [diff] [blame] | 93 | src: "/var/lib/apt/lists" |
Sergio Slobodrian | 5727e98 | 2017-06-28 21:02:27 -0400 | [diff] [blame] | 94 | dest: "/var/lib/apt/lists" |
| 95 | archive: no |
| 96 | owner: no |
| 97 | perms: no |
| 98 | rsync_opts: |
| 99 | - "--exclude=lock" |
| 100 | - "--exclude=partial" |
| 101 | recursive: yes |
| 102 | links: yes |
Sergio Slobodrian | ba9cbd8 | 2017-06-22 11:45:49 -0400 | [diff] [blame] | 103 | tags: [cluster_host] |
| 104 | |
Sergio Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 105 | #- name: upstart barrier filesystem loop mount script is installed |
| 106 | # copy: |
| 107 | # src: "/home/vinstall/losetup.conf" |
| 108 | # dest: /etc/init |
| 109 | # owner: root |
| 110 | # group: root |
| 111 | # mode: 0644 |
| 112 | # when: target == "cluster" |
| 113 | # tags: [cluster_host] |
| 114 | |
Sergio Slobodrian | 7c5e885 | 2017-07-31 20:17:14 -0400 | [diff] [blame] | 115 | #- name: pre-emptive strike to avoid errors during package installation |
| 116 | # apt: |
| 117 | # name: "{{ item }}" |
| 118 | # state: absent |
| 119 | # with_items: |
| 120 | # - ubuntu-core-launcher |
| 121 | # - snapd |
| 122 | # tags: [cluster_host] |
sathishg | 11fe23b | 2017-08-07 23:11:17 +0530 | [diff] [blame] | 123 | - name: A voltha directory under /var/log for voltha logs exists |
sathishg | b5d1c18 | 2017-07-13 14:20:19 +0530 | [diff] [blame] | 124 | file: |
sathishg | 11fe23b | 2017-08-07 23:11:17 +0530 | [diff] [blame] | 125 | path: "/var/log/voltha" |
sathishg | b5d1c18 | 2017-07-13 14:20:19 +0530 | [diff] [blame] | 126 | state: directory |
| 127 | tags: [cluster_host] |
| 128 | |
Sergio Slobodrian | f74fa07 | 2017-06-28 09:33:24 -0400 | [diff] [blame] | 129 | - 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] | 130 | command: "{{ target_voltha_home }}/install_packages.sh" |
| 131 | # command: dpkg -R -i "{{ target_voltha_home }}/deb_files" |
Sergio Slobodrian | ba9cbd8 | 2017-06-22 11:45:49 -0400 | [diff] [blame] | 132 | when: target == "cluster" |
| 133 | tags: [cluster_host] |
| 134 | |
| 135 | #- name: Dependent software is initialized |
| 136 | # command: apt-get -y -f install |
| 137 | # when: target == "cluster" |
| 138 | # tags: [cluster_host] |
| 139 | |
| 140 | - name: Python packages are installed |
| 141 | command: pip install {{ item }} --no-index --find-links "file://{{ target_voltha_home }}/{{ item }}" |
| 142 | with_items: |
| 143 | - docker-py |
| 144 | - netifaces |
| 145 | when: target == "cluster" |
| 146 | tags: [cluster_host] |
| 147 | |
Sergio Slobodrian | 8684370 | 2017-09-05 23:22:39 -0400 | [diff] [blame] | 148 | # To debug package installation, comment this out so review temporary interim |
| 149 | # files. |
| 150 | - name: Configuration directories and files are deleted |
Sergio Slobodrian | ba9cbd8 | 2017-06-22 11:45:49 -0400 | [diff] [blame] | 151 | file: |
| 152 | path: "{{ target_voltha_home }}/{{ item }}" |
| 153 | state: absent |
| 154 | with_items: |
| 155 | - docker-py |
| 156 | - netifaces |
Sergio Slobodrian | 8684370 | 2017-09-05 23:22:39 -0400 | [diff] [blame] | 157 | - sort_packages.sh |
| 158 | - sort_packages.py |
| 159 | - install_packages.sh |
| 160 | - deb_files1 |
| 161 | - deb_files2 |
Sergio Slobodrian | ba9cbd8 | 2017-06-22 11:45:49 -0400 | [diff] [blame] | 162 | when: target == "cluster" |
| 163 | tags: [cluster_host] |
| 164 | |
Sergio Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 165 | - name: Logging barrier file is created |
Sergio Slobodrian | c359b11 | 2017-08-30 16:45:43 -0400 | [diff] [blame] | 166 | 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] | 167 | when: target == "cluster" |
| 168 | tags: [cluster_host] |
| 169 | |
Sergio Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 170 | - name: Registry barrier file is created |
Sergio Slobodrian | c359b11 | 2017-08-30 16:45:43 -0400 | [diff] [blame] | 171 | 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] | 172 | when: target == "cluster" |
| 173 | tags: [cluster_host] |
| 174 | |
Sergio Slobodrian | c359b11 | 2017-08-30 16:45:43 -0400 | [diff] [blame] | 175 | #- name: Consul barrier file is created |
| 176 | # command: "fallocate -l {{ consul_volume_size }}G {{ barrier_fs_dir }}/.consul-barrier-file" |
| 177 | # when: target == "cluster" |
| 178 | # tags: [cluster_host] |
Sergio Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 179 | |
| 180 | - name: The logging barrier file is set up as a loop device |
| 181 | command: "losetup /dev/loop0 {{ barrier_fs_dir }}/.logger-barrier-file" |
| 182 | when: target == "cluster" |
| 183 | tags: [cluster_host] |
| 184 | |
| 185 | - name: The registry barrier file is set up as a loop device |
| 186 | command: "losetup /dev/loop1 {{ barrier_fs_dir }}/.registry-barrier-file" |
| 187 | when: target == "cluster" |
| 188 | tags: [cluster_host] |
| 189 | |
Sergio Slobodrian | c359b11 | 2017-08-30 16:45:43 -0400 | [diff] [blame] | 190 | #- name: The consul barrier file is set up as a loop device |
| 191 | # command: "losetup /dev/loop2 {{ barrier_fs_dir }}/.consul-barrier-file" |
| 192 | # when: target == "cluster" |
| 193 | # tags: [cluster_host] |
Sergio Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 194 | |
| 195 | - name: The xfs filesystem is created on the replicated barrier file systems |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 196 | filesystem: |
| 197 | fstype: xfs |
Sergio Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 198 | dev: "{{ item }}" |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 199 | opts: -i size=512 |
Sergio Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 200 | with_items: |
| 201 | - /dev/loop0 |
| 202 | - /dev/loop1 |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 203 | when: target == "cluster" |
| 204 | tags: [cluster_host] |
| 205 | |
Sergio Slobodrian | c359b11 | 2017-08-30 16:45:43 -0400 | [diff] [blame] | 206 | #- name: The ext4 filesystem is created on the consul barrier volume |
| 207 | # filesystem: |
| 208 | # fstype: ext4 |
| 209 | # dev: /dev/loop2 |
| 210 | # when: target == "cluster" |
| 211 | # tags: [cluster_host] |
Sergio Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 212 | |
| 213 | - name: The loop devices that are no longer needed are removed |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 214 | command: "losetup -D" |
| 215 | when: target == "cluster" |
| 216 | tags: [cluster_host] |
| 217 | |
Sergio Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 218 | - name: The barrier fileystem files are owned by voltha |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 219 | file: |
Sergio Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 220 | path: "{{ barrier_fs_dir }}/{{ item }}" |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 221 | mode: 0755 |
| 222 | owner: voltha |
| 223 | group: voltha |
Sergio Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 224 | with_items: |
| 225 | - ".registry-barrier-file" |
| 226 | - ".logger-barrier-file" |
Sergio Slobodrian | c359b11 | 2017-08-30 16:45:43 -0400 | [diff] [blame] | 227 | # - ".consul-barrier-file" |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 228 | when: target == "cluster" |
| 229 | tags: [cluster_host] |
| 230 | |
Sergio Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 231 | - name: A mountpoint for the glusterfs registry brick is created |
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 }}/reg_brick1" |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 234 | state: directory |
| 235 | mode: 0755 |
| 236 | owner: voltha |
| 237 | group: voltha |
| 238 | when: target == "cluster" |
| 239 | tags: [cluster_host] |
| 240 | |
Sergio Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 241 | - name: A mountpoint for the glusterfs logging brick is created |
| 242 | file: |
| 243 | path: "{{ barrier_fs_dir }}/log_brick1" |
| 244 | state: directory |
| 245 | mode: 0755 |
| 246 | owner: voltha |
| 247 | group: voltha |
| 248 | when: target == "cluster" |
| 249 | tags: [cluster_host] |
| 250 | |
| 251 | - name: The replicated registry filesystem is mounted on boot |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 252 | mount: |
Sergio Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 253 | path: "{{ barrier_fs_dir }}/reg_brick1" |
| 254 | src: "{{ barrier_fs_dir }}/.registry-barrier-file" |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 255 | fstype: xfs |
| 256 | opts: loop |
| 257 | state: mounted |
| 258 | when: target == "cluster" |
| 259 | tags: [cluster_host] |
| 260 | |
Sergio Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 261 | - name: The replicated logger filesystem is mounted on boot |
| 262 | mount: |
| 263 | path: "{{ barrier_fs_dir }}/log_brick1" |
| 264 | src: "{{ barrier_fs_dir }}/.logger-barrier-file" |
| 265 | fstype: xfs |
| 266 | opts: loop |
| 267 | state: mounted |
| 268 | when: target == "cluster" |
| 269 | tags: [cluster_host] |
| 270 | |
| 271 | - name: A directory for the registry glusterfs volume is created |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 272 | file: |
Sergio Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 273 | path: "{{ barrier_fs_dir }}/reg_brick1/registry_volume" |
| 274 | state: directory |
| 275 | mode: 0755 |
| 276 | owner: voltha |
| 277 | group: voltha |
| 278 | when: target == "cluster" |
| 279 | tags: [cluster_host] |
| 280 | |
| 281 | - name: A directory for the logging glusterfs volume is created |
| 282 | file: |
| 283 | path: "{{ barrier_fs_dir }}/log_brick1/logging_volume" |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 284 | state: directory |
| 285 | mode: 0755 |
| 286 | owner: voltha |
| 287 | group: voltha |
| 288 | when: target == "cluster" |
| 289 | tags: [cluster_host] |
| 290 | |
Sergio Slobodrian | d49da36 | 2017-08-24 16:54:53 -0400 | [diff] [blame] | 291 | - name: Directories for voltha processes are created |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 292 | file: |
Sergio Slobodrian | d49da36 | 2017-08-24 16:54:53 -0400 | [diff] [blame] | 293 | path: "{{ target_voltha_dir }}/{{ item }}" |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 294 | state: directory |
| 295 | mode: 0755 |
| 296 | owner: voltha |
| 297 | group: voltha |
Sergio Slobodrian | d49da36 | 2017-08-24 16:54:53 -0400 | [diff] [blame] | 298 | with_items: |
| 299 | - registry_data |
| 300 | - consul/data |
| 301 | - consul/config |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 302 | when: target == "cluster" |
| 303 | tags: [cluster_host] |
| 304 | |
Sergio Slobodrian | c359b11 | 2017-08-30 16:45:43 -0400 | [diff] [blame] | 305 | #- name: The consul data filesystem is mounted on boot |
| 306 | # mount: |
| 307 | # path: "{{ target_voltha_dir }}/consul/data" |
| 308 | # src: "{{ barrier_fs_dir }}/.consul-barrier-file" |
| 309 | # fstype: ext4 |
| 310 | # opts: loop |
| 311 | # state: mounted |
| 312 | # when: target == "cluster" |
| 313 | # tags: [cluster_host] |
Sergio Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 314 | |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 315 | - name: The glusterfs service is started |
| 316 | service: |
| 317 | name: glusterfs-server |
| 318 | enabled: yes |
| 319 | state: started |
| 320 | when: target == "cluster" |
| 321 | tags: [cluster_host] |
| 322 | |
Sergio Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 323 | - name: The replicated registry filesystem is mounted on boot |
Sergio Slobodrian | 523ee78 | 2017-08-22 16:44:21 -0400 | [diff] [blame] | 324 | mount: |
| 325 | path: "{{ target_voltha_dir }}/registry_data" |
| 326 | src: "{{ inventory_hostname }}:/registry_volume" |
| 327 | fstype: glusterfs |
| 328 | opts: "defaults,_netdev,noauto,x-systemd.automount" |
| 329 | state: present |
| 330 | when: target == "cluster" |
| 331 | tags: [cluster_host] |
Sergio Slobodrian | 8725ea8 | 2017-08-27 23:47:41 -0400 | [diff] [blame] | 332 | |
| 333 | - name: The replicated logging filesystem is mounted on boot |
| 334 | mount: |
| 335 | path: "/var/log/voltha" |
| 336 | src: "{{ inventory_hostname }}:/logging_volume" |
| 337 | fstype: glusterfs |
| 338 | opts: "defaults,_netdev,noauto,x-systemd.automount" |
| 339 | state: present |
| 340 | when: target == "cluster" |
| 341 | tags: [cluster_host] |