blob: bf613be20fa08f7431dcc6842c2d2d8511f02034 [file] [log] [blame]
Zack Williams363bc852016-04-12 13:58:29 -07001---
2- hosts: xos-1
3 remote_user: ubuntu
Zack Williams363bc852016-04-12 13:58:29 -07004 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 Williamse4fbacc2016-05-21 07:18:43 -070017 - curl
Zack Williams363bc852016-04-12 13:58:29 -070018 - python-novaclient
19 - python-neutronclient
20 - python-keystoneclient
21 - python-glanceclient
22
Scott Bakerc2cd1b52016-10-26 08:53:15 -070023 - 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 Williams363bc852016-04-12 13:58:29 -070041 - name: Clone XOS repo
42 git:
43 repo={{ xos_repo_url }}
44 dest={{ xos_repo_dest }}
45 version={{ xos_repo_branch }}
Zack Williams9b3c3612016-04-14 07:05:30 -070046 force=yes
Scott Bakerc2cd1b52016-10-26 08:53:15 -070047 when:
48 orchestration.stat.exists == False
Zack Williams363bc852016-04-12 13:58:29 -070049
Scott Baker333a3152016-06-29 08:58:42 -070050 - 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 Bakerc2cd1b52016-10-26 08:53:15 -070056 when:
57 orchestration.stat.exists == False
Scott Baker333a3152016-06-29 08:58:42 -070058
Zack Williams363bc852016-04-12 13:58:29 -070059 - name: Copy over SSH keys
60 copy:
61 src=~/.ssh/{{ item }}
Scott Baker333a3152016-06-29 08:58:42 -070062 dest={{ service_profile_repo_dest }}/{{ xos_configuration }}/
Zack Williams363bc852016-04-12 13:58:29 -070063 owner={{ ansible_user_id }} mode=0600
64 with_items:
65 - id_rsa
66 - id_rsa.pub
67
Andy Bavier6274d6a2016-08-12 18:12:01 -040068 - name: copy over node_key
Zack Williamse4fbacc2016-05-21 07:18:43 -070069 copy:
Andy Bavierd39936c2016-08-02 17:31:07 -040070 src={{ node_private_key }}
Scott Baker333a3152016-06-29 08:58:42 -070071 dest={{ service_profile_repo_dest }}/{{ xos_configuration }}/node_key
Andy Bavier6274d6a2016-08-12 18:12:01 -040072 owner={{ ansible_user_id }} mode=0600
Zack Williamse4fbacc2016-05-21 07:18:43 -070073
Zack Williamsa3e40562016-07-05 12:05:39 -070074 - name: Download Glance VM images
Zack Williams363bc852016-04-12 13:58:29 -070075 get_url:
Zack Williams62587be2016-05-25 15:56:45 -070076 url={{ item.url }}
77 checksum={{ item.checksum }}
Scott Baker333a3152016-06-29 08:58:42 -070078 dest={{ service_profile_repo_dest }}/{{ xos_configuration }}/images/{{ item.name }}.img
Zack Williams62587be2016-05-25 15:56:45 -070079 with_items: "{{ xos_images }}"
Zack Williams363bc852016-04-12 13:58:29 -070080
Scott Baker99ba01e2016-11-03 15:55:17 -070081 - 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
Andy Bavier0077cd22016-11-14 16:54:09 -0800106 tags:
107 - skip_ansible_lint # Wants this to be a handler
Scott Baker99ba01e2016-11-03 15:55:17 -0700108
Zack Williamsd31bbc92016-05-20 11:43:18 -0700109 - name: Pull docker images for XOS
Zack Williams09df9d62016-05-27 22:39:38 -0700110 become: yes
Scott Baker0e584c42016-11-04 17:33:23 -0700111 command: docker pull {{ docker_registry }}/{{ item }}:{{ docker_tag }}
Zack Williams09df9d62016-05-27 22:39:38 -0700112 with_items:
Scott Baker0e584c42016-11-04 17:33:23 -0700113 - xosproject/xos-base
Scott Baker5bd8a5e2016-11-07 10:19:38 -0800114 - xosproject/xos-postgres
115 - xosproject/cord-app-build
116 - redis
117 tags:
118 - skip_ansible_lint
Scott Baker0e584c42016-11-04 17:33:23 -0700119
120 - name: Tag the images downloaded from the local registry
121 command: docker tag {{ docker_registry }}/{{ item }}:{{ docker_tag }} {{ item }}:latest
122 with_items:
123 - xosproject/xos-base
Scott Baker5bd8a5e2016-11-07 10:19:38 -0800124 - xosproject/xos-postgres
125 - xosproject/cord-app-build
126 - redis
127 when: docker_registry_check|succeeded
Zack Williams363bc852016-04-12 13:58:29 -0700128
Zack Williams72a9ab42016-06-08 08:32:49 -0700129 - name: Rebuild XOS containers
130 when: xos_container_rebuild
131 command: make {{ item }}
Zack Williamsa3e40562016-07-05 12:05:39 -0700132 chdir="{{ xos_repo_dest }}/containers/xos/"
Zack Williams72a9ab42016-06-08 08:32:49 -0700133 with_items:
134 - base