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: |
| 30 | False # orchestration.stat.exists == True # XXX |
| 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: |
| 49 | False # (orchestration.stat.exists == True) and (onos_apps.stat.exists == True) # XXX |
| 50 | |
| 51 | # ---- alternatively, check out repos from Internet --- |
| 52 | |
| 53 | - name: Clone service-profile repo |
Zack Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 54 | git: |
Scott Baker | db5c8c7 | 2016-11-08 08:40:06 -0800 | [diff] [blame] | 55 | repo={{ service_profile_repo_url }} |
| 56 | dest={{ service_profile_repo_dest }} |
| 57 | version={{ service_profile_repo_branch }} |
| 58 | force=yes |
| 59 | when: |
| 60 | True # orchestration.stat.exists == False # XXX |
| 61 | |
| 62 | # ---- install keys ---- |
| 63 | |
| 64 | - name: Copy over SSH keys |
| 65 | command: cp ~/.ssh/{{ item }} {{ service_profile_repo_dest }}/{{ xos_configuration }}/ |
| 66 | with_items: |
| 67 | - id_rsa |
| 68 | - id_rsa.pub |
| 69 | tags: |
| 70 | - skip_ansible_lint |
| 71 | |
| 72 | - name: Copy over node key |
| 73 | command: cp {{ ansible_user_dir }}/node_key {{ service_profile_repo_dest }}/{{ xos_configuration }}/ |
| 74 | tags: |
| 75 | - skip_ansible_lint |
| 76 | |
| 77 | - name: Set ownership and permissions of keys |
| 78 | file: |
| 79 | path={{ service_profile_repo_dest }}/{{ xos_configuration }}/{{ item }} |
| 80 | owner={{ ansible_user_id }} |
| 81 | # mode=0600 |
| 82 | with_items: |
| 83 | - id_rsa |
| 84 | - id_rsa.pub |
| 85 | - node_key |
| 86 | |
| 87 | # ---- |
| 88 | |
| 89 | - name: Download Glance VM images |
| 90 | get_url: |
| 91 | url={{ item.url }} |
| 92 | checksum={{ item.checksum }} |
| 93 | dest={{ service_profile_repo_dest }}/{{ xos_configuration }}/images/{{ item.name }}.img |
| 94 | with_items: "{{ xos_images }}" |
| 95 | |
| 96 | # ---- pull docker images ---- |
| 97 | |
| 98 | - name: Check to see if registry is reachable |
| 99 | command: curl -sf http://docker-registry:5000/ |
| 100 | ignore_errors: yes |
| 101 | register: docker_registry_check |
| 102 | tags: |
| 103 | - skip_ansible_lint |
| 104 | |
| 105 | - name: Use registry if it is available |
| 106 | set_fact: |
| 107 | docker_registry: "{{ local_docker_registry }}" |
| 108 | docker_opts: "--insecure-registry {{ local_docker_registry }}" |
| 109 | docker_tag: "candidate" |
| 110 | when: docker_registry_check|succeeded |
| 111 | |
| 112 | - name: Pull docker images for XOS |
| 113 | become: yes |
| 114 | command: docker pull {{ docker_registry }}/{{ item }}:{{ docker_tag }} |
| 115 | with_items: |
| 116 | - xosproject/xos-base |
| 117 | - xosproject/xos-postgres |
| 118 | - xosproject/cord-app-build |
| 119 | - redis |
| 120 | tags: |
| 121 | - skip_ansible_lint |
| 122 | |
| 123 | - name: Tag the images downloaded from the local registry |
| 124 | command: docker tag {{ docker_registry }}/{{ item }}:{{ docker_tag }} {{ item }}:latest |
| 125 | with_items: |
| 126 | - xosproject/xos-base |
| 127 | - xosproject/xos-postgres |
| 128 | - xosproject/cord-app-build |
| 129 | - redis |
| 130 | when: docker_registry_check|succeeded |
| 131 | |
| 132 | # ---- optional: rebuild base container ---- |
Scott Baker | 333a315 | 2016-06-29 08:58:42 -0700 | [diff] [blame] | 133 | |
Zack Williams | c563b57 | 2016-06-03 09:49:53 -0700 | [diff] [blame] | 134 | - name: Rebuild XOS containers |
| 135 | when: xos_container_rebuild |
Scott Baker | db5c8c7 | 2016-11-08 08:40:06 -0800 | [diff] [blame] | 136 | command: make {{ item }} |
| 137 | chdir="{{ xos_repo_dest }}/containers/xos/" |
Zack Williams | 72a9ab4 | 2016-06-08 08:32:49 -0700 | [diff] [blame] | 138 | with_items: |
Scott Baker | db5c8c7 | 2016-11-08 08:40:06 -0800 | [diff] [blame] | 139 | - base |
Zack Williams | c563b57 | 2016-06-03 09:49:53 -0700 | [diff] [blame] | 140 | |
Scott Baker | db5c8c7 | 2016-11-08 08:40:06 -0800 | [diff] [blame] | 141 | |
| 142 | |
Zack Williams | d2cbe51 | 2016-06-03 09:33:15 -0700 | [diff] [blame] | 143 | |