Zack Williams | 363bc85 | 2016-04-12 13:58:29 -0700 | [diff] [blame] | 1 | --- |
| 2 | - hosts: xos-1 |
| 3 | remote_user: ubuntu |
Zack Williams | 363bc85 | 2016-04-12 13:58:29 -0700 | [diff] [blame] | 4 | tasks: |
| 5 | - name: Include configuration vars |
| 6 | include_vars: xos-setup-vars.yml |
| 7 | |
| 8 | - name: Install prerequisites |
| 9 | apt: |
| 10 | name={{ item }} |
| 11 | update_cache=yes |
| 12 | cache_valid_time=3600 |
| 13 | become: yes |
| 14 | with_items: |
| 15 | - git |
| 16 | - make |
Zack Williams | e4fbacc | 2016-05-21 07:18:43 -0700 | [diff] [blame] | 17 | - curl |
Zack Williams | 363bc85 | 2016-04-12 13:58:29 -0700 | [diff] [blame] | 18 | - python-novaclient |
| 19 | - python-neutronclient |
| 20 | - python-keystoneclient |
| 21 | - python-glanceclient |
| 22 | |
Scott Baker | c2cd1b5 | 2016-10-26 08:53:15 -0700 | [diff] [blame] | 23 | - name: Check to see if xos_install/orchestration directory exists |
| 24 | local_action: stat path="{{ playbook_dir }}/xos_install/orchestration" |
| 25 | register: orchestration |
| 26 | |
| 27 | # Two methods to install: |
| 28 | # 1) If running from cord-in-a-box, then xos_install/orchestration will |
| 29 | # be populated with the checked-out xos repositories, and we can |
| 30 | # now copy them to the XOS VM. |
| 31 | # 2) If not running from cord-in-a-box, then xos_install will not |
| 32 | # exist, and we will check out the repos using git. |
| 33 | |
| 34 | - name: Copy repositories to the XOS VM |
| 35 | synchronize: |
| 36 | src: "{{ playbook_dir }}/xos_install/orchestration/" |
| 37 | dest: "{{ orchestration_dest }}" |
| 38 | when: |
| 39 | orchestration.stat.exists == True |
| 40 | |
Zack Williams | 363bc85 | 2016-04-12 13:58:29 -0700 | [diff] [blame] | 41 | - name: Clone XOS repo |
| 42 | git: |
| 43 | repo={{ xos_repo_url }} |
| 44 | dest={{ xos_repo_dest }} |
| 45 | version={{ xos_repo_branch }} |
Zack Williams | 9b3c361 | 2016-04-14 07:05:30 -0700 | [diff] [blame] | 46 | force=yes |
Scott Baker | c2cd1b5 | 2016-10-26 08:53:15 -0700 | [diff] [blame] | 47 | when: |
| 48 | orchestration.stat.exists == False |
Zack Williams | 363bc85 | 2016-04-12 13:58:29 -0700 | [diff] [blame] | 49 | |
Scott Baker | 333a315 | 2016-06-29 08:58:42 -0700 | [diff] [blame] | 50 | - name: Clone service-profile repo |
| 51 | git: |
| 52 | repo={{ service_profile_repo_url }} |
| 53 | dest={{ service_profile_repo_dest }} |
| 54 | version={{ service_profile_repo_branch }} |
| 55 | force=yes |
Scott Baker | c2cd1b5 | 2016-10-26 08:53:15 -0700 | [diff] [blame] | 56 | when: |
| 57 | orchestration.stat.exists == False |
Scott Baker | 333a315 | 2016-06-29 08:58:42 -0700 | [diff] [blame] | 58 | |
Zack Williams | 363bc85 | 2016-04-12 13:58:29 -0700 | [diff] [blame] | 59 | - name: Copy over SSH keys |
| 60 | copy: |
| 61 | src=~/.ssh/{{ item }} |
Scott Baker | 333a315 | 2016-06-29 08:58:42 -0700 | [diff] [blame] | 62 | dest={{ service_profile_repo_dest }}/{{ xos_configuration }}/ |
Zack Williams | 363bc85 | 2016-04-12 13:58:29 -0700 | [diff] [blame] | 63 | owner={{ ansible_user_id }} mode=0600 |
| 64 | with_items: |
| 65 | - id_rsa |
| 66 | - id_rsa.pub |
| 67 | |
Andy Bavier | 6274d6a | 2016-08-12 18:12:01 -0400 | [diff] [blame] | 68 | - name: copy over node_key |
Zack Williams | e4fbacc | 2016-05-21 07:18:43 -0700 | [diff] [blame] | 69 | copy: |
Andy Bavier | d39936c | 2016-08-02 17:31:07 -0400 | [diff] [blame] | 70 | src={{ node_private_key }} |
Scott Baker | 333a315 | 2016-06-29 08:58:42 -0700 | [diff] [blame] | 71 | dest={{ service_profile_repo_dest }}/{{ xos_configuration }}/node_key |
Andy Bavier | 6274d6a | 2016-08-12 18:12:01 -0400 | [diff] [blame] | 72 | owner={{ ansible_user_id }} mode=0600 |
Zack Williams | e4fbacc | 2016-05-21 07:18:43 -0700 | [diff] [blame] | 73 | |
Zack Williams | a3e4056 | 2016-07-05 12:05:39 -0700 | [diff] [blame] | 74 | - name: Download Glance VM images |
Zack Williams | 363bc85 | 2016-04-12 13:58:29 -0700 | [diff] [blame] | 75 | get_url: |
Zack Williams | 62587be | 2016-05-25 15:56:45 -0700 | [diff] [blame] | 76 | url={{ item.url }} |
| 77 | checksum={{ item.checksum }} |
Scott Baker | 333a315 | 2016-06-29 08:58:42 -0700 | [diff] [blame] | 78 | dest={{ service_profile_repo_dest }}/{{ xos_configuration }}/images/{{ item.name }}.img |
Zack Williams | 62587be | 2016-05-25 15:56:45 -0700 | [diff] [blame] | 79 | with_items: "{{ xos_images }}" |
Zack Williams | 363bc85 | 2016-04-12 13:58:29 -0700 | [diff] [blame] | 80 | |
Scott Baker | 99ba01e | 2016-11-03 15:55:17 -0700 | [diff] [blame] | 81 | - name: Check to see if registry is reachable |
| 82 | command: curl -sf http://docker-registry:5000/ |
| 83 | ignore_errors: yes |
| 84 | register: docker_registry_check |
| 85 | tags: |
| 86 | - skip_ansible_lint |
| 87 | |
| 88 | - name: Use registry if it is available |
| 89 | set_fact: |
| 90 | docker_registry: "{{ local_docker_registry }}" |
| 91 | docker_opts: "--insecure-registry {{ local_docker_registry }}" |
| 92 | docker_tag: "candidate" |
| 93 | when: docker_registry_check|succeeded |
| 94 | |
| 95 | - name: Set docker options |
| 96 | become: yes |
| 97 | template: src=docker.j2 dest=/etc/default/docker |
| 98 | register: set_docker_opts |
| 99 | |
| 100 | # Note this needs to be executed now, not as a handler, as the pull |
| 101 | # operations won't succeed without it. |
| 102 | - name: restart docker |
| 103 | become: yes |
| 104 | service: name=docker state=restarted |
| 105 | when: set_docker_opts.changed |
| 106 | |
Zack Williams | a3e4056 | 2016-07-05 12:05:39 -0700 | [diff] [blame] | 107 | - name: Pull database and cord-app-build image |
| 108 | become: yes |
| 109 | command: docker pull {{ item }} |
| 110 | with_items: |
| 111 | - xosproject/xos-postgres |
| 112 | - xosproject/cord-app-build |
Zack Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 113 | tags: |
| 114 | - skip_ansible_lint # FIXME: use new 2.2 docker modules when available |
Zack Williams | a3e4056 | 2016-07-05 12:05:39 -0700 | [diff] [blame] | 115 | |
Zack Williams | d31bbc9 | 2016-05-20 11:43:18 -0700 | [diff] [blame] | 116 | - name: Pull docker images for XOS |
Zack Williams | 72a9ab4 | 2016-06-08 08:32:49 -0700 | [diff] [blame] | 117 | when: not xos_container_rebuild |
Zack Williams | 09df9d6 | 2016-05-27 22:39:38 -0700 | [diff] [blame] | 118 | become: yes |
Scott Baker | 0e584c4 | 2016-11-04 17:33:23 -0700 | [diff] [blame^] | 119 | command: docker pull {{ docker_registry }}/{{ item }}:{{ docker_tag }} |
Zack Williams | 09df9d6 | 2016-05-27 22:39:38 -0700 | [diff] [blame] | 120 | with_items: |
Scott Baker | 0e584c4 | 2016-11-04 17:33:23 -0700 | [diff] [blame^] | 121 | - xosproject/xos-base |
| 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 | when: (not xos_container_rebuild) and (docker_registry_check|succeeded) |
Zack Williams | 363bc85 | 2016-04-12 13:58:29 -0700 | [diff] [blame] | 128 | |
Zack Williams | 72a9ab4 | 2016-06-08 08:32:49 -0700 | [diff] [blame] | 129 | - name: Rebuild XOS containers |
| 130 | when: xos_container_rebuild |
| 131 | command: make {{ item }} |
Zack Williams | a3e4056 | 2016-07-05 12:05:39 -0700 | [diff] [blame] | 132 | chdir="{{ xos_repo_dest }}/containers/xos/" |
Zack Williams | 72a9ab4 | 2016-06-08 08:32:49 -0700 | [diff] [blame] | 133 | with_items: |
| 134 | - base |
Zack Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 135 | |
| 136 | |
Scott Baker | 99ba01e | 2016-11-03 15:55:17 -0700 | [diff] [blame] | 137 | |