blob: abb5a3051f1b7006e8c1c3e7b44a8a624f79097e [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
106
Zack Williamsa3e40562016-07-05 12:05:39 -0700107 - 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 Williams35624562016-08-28 17:12:26 -0700113 tags:
114 - skip_ansible_lint # FIXME: use new 2.2 docker modules when available
Zack Williamsa3e40562016-07-05 12:05:39 -0700115
Zack Williamsd31bbc92016-05-20 11:43:18 -0700116 - name: Pull docker images for XOS
Zack Williams72a9ab42016-06-08 08:32:49 -0700117 when: not xos_container_rebuild
Zack Williams09df9d62016-05-27 22:39:38 -0700118 become: yes
119 command: docker pull {{ item }}
120 with_items:
Scott Baker99ba01e2016-11-03 15:55:17 -0700121 - "{{ docker_registry }}/xosproject/xos-base:{{ docker_tag }}"
Zack Williams363bc852016-04-12 13:58:29 -0700122
Zack Williams72a9ab42016-06-08 08:32:49 -0700123 - name: Rebuild XOS containers
124 when: xos_container_rebuild
125 command: make {{ item }}
Zack Williamsa3e40562016-07-05 12:05:39 -0700126 chdir="{{ xos_repo_dest }}/containers/xos/"
Zack Williams72a9ab42016-06-08 08:32:49 -0700127 with_items:
128 - base
Zack Williams35624562016-08-28 17:12:26 -0700129
130
Scott Baker99ba01e2016-11-03 15:55:17 -0700131