Zack Williams | fc102dd | 2016-03-01 17:31:30 -0700 | [diff] [blame] | 1 | --- |
| 2 | # tasks for xos-install role |
| 3 | |
Scott Baker | db5c8c7 | 2016-11-08 08:40:06 -0800 | [diff] [blame] | 4 | - name: Install prerequisites |
| 5 | apt: |
| 6 | name={{ item }} |
| 7 | update_cache=yes |
| 8 | cache_valid_time=3600 |
| 9 | become: yes |
| 10 | with_items: |
| 11 | - git |
| 12 | - make |
| 13 | - curl |
| 14 | - python-novaclient |
| 15 | - python-neutronclient |
| 16 | - python-keystoneclient |
| 17 | - python-glanceclient |
Zack Williams | d2cbe51 | 2016-06-03 09:33:15 -0700 | [diff] [blame] | 18 | |
Scott Baker | 34c02ac | 2017-01-16 08:58:52 -0800 | [diff] [blame] | 19 | # ---- copy repos from the dev machine to the head node ---- |
Zack Williams | 43d62b5 | 2017-01-23 07:34:45 -0700 | [diff] [blame] | 20 | # note: this happens in the `cord` repo now |
Scott Baker | 34c02ac | 2017-01-16 08:58:52 -0800 | [diff] [blame] | 21 | |
Zack Williams | 43d62b5 | 2017-01-23 07:34:45 -0700 | [diff] [blame] | 22 | # - name: Create cord destination directory |
| 23 | # become: yes |
| 24 | # file: |
| 25 | # path: "{{ cord_dest_dir }}" |
| 26 | # state: directory |
| 27 | # mode: 0755 |
| 28 | # owner: "{{ ansible_user_id }}" |
Scott Baker | 34c02ac | 2017-01-16 08:58:52 -0800 | [diff] [blame] | 29 | |
Zack Williams | 43d62b5 | 2017-01-23 07:34:45 -0700 | [diff] [blame] | 30 | # - name: Copy the whole repo tree |
| 31 | # synchronize: |
| 32 | # src: "{{ playbook_dir }}/../../../cord/" |
| 33 | # dest: "{{ cord_dest_dir }}/" |
Scott Baker | 34c02ac | 2017-01-16 08:58:52 -0800 | [diff] [blame] | 34 | |
| 35 | - name: Create directory xos_services |
| 36 | file: |
| 37 | path: "{{ ansible_user_dir }}/xos_services" |
| 38 | state: directory |
| 39 | mode: 0755 |
| 40 | |
| 41 | - name: Create directory xos_libraries |
| 42 | file: |
| 43 | path: "{{ ansible_user_dir }}/xos_libraries" |
| 44 | state: directory |
| 45 | mode: 0755 |
| 46 | |
| 47 | - name: Create bindings to service-profile and xos |
| 48 | become: yes |
| 49 | mount: |
| 50 | src: "{{ cord_dest_dir }}/orchestration/{{ item }}" |
| 51 | name: "{{ ansible_user_dir }}/{{ item }}" |
| 52 | fstype: none |
| 53 | opts: rw,bind |
| 54 | state: mounted |
Scott Baker | db5c8c7 | 2016-11-08 08:40:06 -0800 | [diff] [blame] | 55 | with_items: |
| 56 | - service-profile |
| 57 | - xos |
Scott Baker | db5c8c7 | 2016-11-08 08:40:06 -0800 | [diff] [blame] | 58 | |
Scott Baker | 34c02ac | 2017-01-16 08:58:52 -0800 | [diff] [blame] | 59 | - name: Create bindings for xos services |
| 60 | become: yes |
| 61 | mount: |
| 62 | src: "{{ cord_dest_dir }}/orchestration/xos_services/{{ item }}" |
| 63 | name: "{{ ansible_user_dir }}/xos_services/{{ item }}" |
| 64 | fstype: none |
| 65 | opts: rw,bind |
| 66 | state: mounted |
| 67 | with_items: |
| 68 | - exampleservice |
| 69 | - fabric |
| 70 | - globalxos |
| 71 | - hypercache |
| 72 | - metro-net |
| 73 | - monitoring |
| 74 | - onos-service |
| 75 | - openstack |
| 76 | - vrouter |
| 77 | - vsg |
| 78 | - vtr |
Scott Baker | db5c8c7 | 2016-11-08 08:40:06 -0800 | [diff] [blame] | 79 | |
Scott Baker | 34c02ac | 2017-01-16 08:58:52 -0800 | [diff] [blame] | 80 | - name: Create bindings for xos services that reside in onos |
| 81 | become: yes |
| 82 | mount: |
| 83 | src: "{{ cord_dest_dir }}/onos-apps/apps/{{ item }}" |
| 84 | name: "{{ ansible_user_dir }}/xos_services/{{ item }}" |
| 85 | fstype: none |
| 86 | opts: rw,bind |
| 87 | state: mounted |
Scott Baker | db5c8c7 | 2016-11-08 08:40:06 -0800 | [diff] [blame] | 88 | with_items: |
| 89 | - vtn |
| 90 | - olt |
Scott Baker | db5c8c7 | 2016-11-08 08:40:06 -0800 | [diff] [blame] | 91 | |
Scott Baker | 34c02ac | 2017-01-16 08:58:52 -0800 | [diff] [blame] | 92 | - name: Create bindings for xos libraries |
| 93 | become: yes |
| 94 | mount: |
| 95 | src: "{{ cord_dest_dir }}/orchestration/xos_libraries/{{ item }}" |
| 96 | name: "{{ ansible_user_dir }}/xos_libraries/{{ item }}" |
| 97 | fstype: none |
| 98 | opts: rw,bind |
| 99 | state: mounted |
| 100 | with_items: |
| 101 | - ng-xos-lib |
| 102 | |
| 103 | # ---- alternatively, check out repos from Internet --- |
| 104 | |
| 105 | - name: Clone service-profile repo |
| 106 | git: |
| 107 | repo={{ service_profile_repo_url }} |
| 108 | dest={{ service_profile_repo_dest }} |
| 109 | version={{ service_profile_repo_branch }} |
| 110 | force=yes |
| 111 | when: |
| 112 | False |
| 113 | |
| 114 | # ---- install keys ---- |
| 115 | |
Scott Baker | db5c8c7 | 2016-11-08 08:40:06 -0800 | [diff] [blame] | 116 | - name: Copy over SSH keys |
| 117 | command: cp ~/.ssh/{{ item }} {{ service_profile_repo_dest }}/{{ xos_configuration }}/ |
| 118 | with_items: |
| 119 | - id_rsa |
| 120 | - id_rsa.pub |
| 121 | tags: |
| 122 | - skip_ansible_lint |
| 123 | |
| 124 | - name: Copy over node key |
| 125 | command: cp {{ ansible_user_dir }}/node_key {{ service_profile_repo_dest }}/{{ xos_configuration }}/ |
| 126 | tags: |
| 127 | - skip_ansible_lint |
| 128 | |
| 129 | - name: Set ownership and permissions of keys |
| 130 | file: |
| 131 | path={{ service_profile_repo_dest }}/{{ xos_configuration }}/{{ item }} |
| 132 | owner={{ ansible_user_id }} |
| 133 | # mode=0600 |
| 134 | with_items: |
| 135 | - id_rsa |
| 136 | - id_rsa.pub |
| 137 | - node_key |
| 138 | |
Scott Baker | 06f13b8 | 2017-01-26 16:54:25 -0800 | [diff] [blame] | 139 | - name: Copy over core api key |
| 140 | copy: |
| 141 | src: "{{ playbook_dir }}/pki/intermediate_ca/private/xos-core.{{ site_suffix }}_key.pem" |
| 142 | dest: "{{ service_profile_repo_dest }}/{{ xos_configuration }}/core_api_key.pem" |
| 143 | mode: 0600 |
| 144 | |
| 145 | - name: Copy over core api cert |
| 146 | copy: |
| 147 | src: "{{ playbook_dir }}/pki/intermediate_ca/certs/xos-core.{{ site_suffix }}_cert_chain.pem" |
| 148 | dest: "{{ service_profile_repo_dest }}/{{ xos_configuration }}/core_api_cert.pem" |
| 149 | |
Zack Williams | 682450e | 2016-11-19 09:04:41 -0700 | [diff] [blame] | 150 | - name: Create templated TOSCA files |
| 151 | template: |
| 152 | src: "{{ item }}.j2" |
| 153 | dest: "{{ service_profile_repo_dest }}/{{ xos_configuration }}/{{ item }}" |
| 154 | with_items: "{{ xos_tosca_templates }}" |
Scott Baker | db5c8c7 | 2016-11-08 08:40:06 -0800 | [diff] [blame] | 155 | |
| 156 | - name: Download Glance VM images |
| 157 | get_url: |
| 158 | url={{ item.url }} |
| 159 | checksum={{ item.checksum }} |
Zack Williams | 682450e | 2016-11-19 09:04:41 -0700 | [diff] [blame] | 160 | dest={{ service_profile_repo_dest }}/{{ xos_configuration }}/images/{{ item.name }}.qcow2 |
Scott Baker | db5c8c7 | 2016-11-08 08:40:06 -0800 | [diff] [blame] | 161 | with_items: "{{ xos_images }}" |
| 162 | |
| 163 | # ---- pull docker images ---- |
| 164 | |
| 165 | - name: Check to see if registry is reachable |
| 166 | command: curl -sf http://docker-registry:5000/ |
| 167 | ignore_errors: yes |
| 168 | register: docker_registry_check |
| 169 | tags: |
| 170 | - skip_ansible_lint |
| 171 | |
| 172 | - name: Use registry if it is available |
| 173 | set_fact: |
| 174 | docker_registry: "{{ local_docker_registry }}" |
| 175 | docker_opts: "--insecure-registry {{ local_docker_registry }}" |
| 176 | docker_tag: "candidate" |
| 177 | when: docker_registry_check|succeeded |
| 178 | |
| 179 | - name: Pull docker images for XOS |
| 180 | become: yes |
| 181 | command: docker pull {{ docker_registry }}/{{ item }}:{{ docker_tag }} |
| 182 | with_items: |
| 183 | - xosproject/xos-base |
| 184 | - xosproject/xos-postgres |
| 185 | - xosproject/cord-app-build |
| 186 | - redis |
Scott Baker | c00f9c0 | 2017-01-19 09:40:14 -0800 | [diff] [blame] | 187 | - nginx |
| 188 | - node |
Scott Baker | db5c8c7 | 2016-11-08 08:40:06 -0800 | [diff] [blame] | 189 | tags: |
| 190 | - skip_ansible_lint |
| 191 | |
| 192 | - name: Tag the images downloaded from the local registry |
| 193 | command: docker tag {{ docker_registry }}/{{ item }}:{{ docker_tag }} {{ item }}:latest |
| 194 | with_items: |
| 195 | - xosproject/xos-base |
| 196 | - xosproject/xos-postgres |
| 197 | - xosproject/cord-app-build |
| 198 | - redis |
Scott Baker | c00f9c0 | 2017-01-19 09:40:14 -0800 | [diff] [blame] | 199 | - nginx |
| 200 | when: docker_registry_check|succeeded |
| 201 | |
| 202 | - name: Separately tag the node image with tag argon |
| 203 | command: docker tag {{ docker_registry }}/node:{{ docker_tag }} node:argon |
Scott Baker | db5c8c7 | 2016-11-08 08:40:06 -0800 | [diff] [blame] | 204 | when: docker_registry_check|succeeded |
| 205 | |
Zack Williams | c563b57 | 2016-06-03 09:49:53 -0700 | [diff] [blame] | 206 | |
Scott Baker | db5c8c7 | 2016-11-08 08:40:06 -0800 | [diff] [blame] | 207 | |
| 208 | |
Zack Williams | d2cbe51 | 2016-06-03 09:33:15 -0700 | [diff] [blame] | 209 | |