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 | db5c8c7 | 2016-11-08 08:40:06 -0800 | [diff] [blame] | 19 | # ---- copy repos from the dev machine to the head node ---- |
| 20 | |
| 21 | - name: Check to see if orchestration directory exists |
| 22 | local_action: stat path="{{ playbook_dir }}/../../orchestration" |
| 23 | register: orchestration |
| 24 | |
| 25 | - name: Copy repositories to the head node |
| 26 | synchronize: |
| 27 | src: "{{ playbook_dir }}/../../orchestration/{{ item }}" |
| 28 | dest: "{{ ansible_user_dir }}/" |
| 29 | when: |
Scott Baker | f9eac1c | 2016-11-22 12:01:42 -0800 | [diff] [blame] | 30 | False # orchestration.stat.exists == True # XXX |
Scott Baker | db5c8c7 | 2016-11-08 08:40:06 -0800 | [diff] [blame] | 31 | with_items: |
| 32 | - service-profile |
| 33 | - xos |
| 34 | - xos_libraries |
| 35 | - xos_services |
| 36 | |
| 37 | - name: Check to see if onos_apps directory exists |
| 38 | local_action: stat path="{{ playbook_dir }}/../../onos-apps/apps" |
| 39 | register: onos_apps |
| 40 | |
| 41 | - name: Copy in onos-apps that have XOS code |
| 42 | synchronize: |
| 43 | src: "{{ playbook_dir }}/../../onos-apps/apps/{{ item }}" |
| 44 | dest: "{{ ansible_user_dir }}/xos_services/" |
| 45 | with_items: |
| 46 | - vtn |
| 47 | - olt |
| 48 | when: |
Scott Baker | f9eac1c | 2016-11-22 12:01:42 -0800 | [diff] [blame] | 49 | False # (orchestration.stat.exists == True) and (onos_apps.stat.exists == True) # XXX |
Zack Williams | 682450e | 2016-11-19 09:04:41 -0700 | [diff] [blame] | 50 | |
Scott Baker | db5c8c7 | 2016-11-08 08:40:06 -0800 | [diff] [blame] | 51 | |
| 52 | # ---- alternatively, check out repos from Internet --- |
| 53 | |
| 54 | - name: Clone service-profile repo |
Zack Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 55 | git: |
Scott Baker | db5c8c7 | 2016-11-08 08:40:06 -0800 | [diff] [blame] | 56 | repo={{ service_profile_repo_url }} |
| 57 | dest={{ service_profile_repo_dest }} |
| 58 | version={{ service_profile_repo_branch }} |
| 59 | force=yes |
| 60 | when: |
Scott Baker | f9eac1c | 2016-11-22 12:01:42 -0800 | [diff] [blame] | 61 | True # orchestration.stat.exists == False # XXX |
Scott Baker | db5c8c7 | 2016-11-08 08:40:06 -0800 | [diff] [blame] | 62 | |
| 63 | # ---- install keys ---- |
| 64 | |
| 65 | - name: Copy over SSH keys |
| 66 | command: cp ~/.ssh/{{ item }} {{ service_profile_repo_dest }}/{{ xos_configuration }}/ |
| 67 | with_items: |
| 68 | - id_rsa |
| 69 | - id_rsa.pub |
| 70 | tags: |
| 71 | - skip_ansible_lint |
| 72 | |
| 73 | - name: Copy over node key |
| 74 | command: cp {{ ansible_user_dir }}/node_key {{ service_profile_repo_dest }}/{{ xos_configuration }}/ |
| 75 | tags: |
| 76 | - skip_ansible_lint |
| 77 | |
| 78 | - name: Set ownership and permissions of keys |
| 79 | file: |
| 80 | path={{ service_profile_repo_dest }}/{{ xos_configuration }}/{{ item }} |
| 81 | owner={{ ansible_user_id }} |
| 82 | # mode=0600 |
| 83 | with_items: |
| 84 | - id_rsa |
| 85 | - id_rsa.pub |
| 86 | - node_key |
| 87 | |
Zack Williams | 682450e | 2016-11-19 09:04:41 -0700 | [diff] [blame] | 88 | - name: Create templated TOSCA files |
| 89 | template: |
| 90 | src: "{{ item }}.j2" |
| 91 | dest: "{{ service_profile_repo_dest }}/{{ xos_configuration }}/{{ item }}" |
| 92 | with_items: "{{ xos_tosca_templates }}" |
Scott Baker | db5c8c7 | 2016-11-08 08:40:06 -0800 | [diff] [blame] | 93 | |
| 94 | - name: Download Glance VM images |
| 95 | get_url: |
| 96 | url={{ item.url }} |
| 97 | checksum={{ item.checksum }} |
Zack Williams | 682450e | 2016-11-19 09:04:41 -0700 | [diff] [blame] | 98 | dest={{ service_profile_repo_dest }}/{{ xos_configuration }}/images/{{ item.name }}.qcow2 |
Scott Baker | db5c8c7 | 2016-11-08 08:40:06 -0800 | [diff] [blame] | 99 | with_items: "{{ xos_images }}" |
| 100 | |
| 101 | # ---- pull docker images ---- |
| 102 | |
| 103 | - name: Check to see if registry is reachable |
| 104 | command: curl -sf http://docker-registry:5000/ |
| 105 | ignore_errors: yes |
| 106 | register: docker_registry_check |
| 107 | tags: |
| 108 | - skip_ansible_lint |
| 109 | |
| 110 | - name: Use registry if it is available |
| 111 | set_fact: |
| 112 | docker_registry: "{{ local_docker_registry }}" |
| 113 | docker_opts: "--insecure-registry {{ local_docker_registry }}" |
| 114 | docker_tag: "candidate" |
| 115 | when: docker_registry_check|succeeded |
| 116 | |
| 117 | - name: Pull docker images for XOS |
| 118 | become: yes |
| 119 | command: docker pull {{ docker_registry }}/{{ item }}:{{ docker_tag }} |
| 120 | with_items: |
| 121 | - xosproject/xos-base |
| 122 | - xosproject/xos-postgres |
| 123 | - xosproject/cord-app-build |
| 124 | - redis |
| 125 | tags: |
| 126 | - skip_ansible_lint |
| 127 | |
| 128 | - name: Tag the images downloaded from the local registry |
| 129 | command: docker tag {{ docker_registry }}/{{ item }}:{{ docker_tag }} {{ item }}:latest |
| 130 | with_items: |
| 131 | - xosproject/xos-base |
| 132 | - xosproject/xos-postgres |
| 133 | - xosproject/cord-app-build |
| 134 | - redis |
| 135 | when: docker_registry_check|succeeded |
| 136 | |
Zack Williams | c563b57 | 2016-06-03 09:49:53 -0700 | [diff] [blame] | 137 | |
Scott Baker | db5c8c7 | 2016-11-08 08:40:06 -0800 | [diff] [blame] | 138 | |
| 139 | |
Zack Williams | d2cbe51 | 2016-06-03 09:33:15 -0700 | [diff] [blame] | 140 | |