blob: abb5a3051f1b7006e8c1c3e7b44a8a624f79097e [file] [log] [blame]
---
- hosts: xos-1
remote_user: ubuntu
tasks:
- name: Include configuration vars
include_vars: xos-setup-vars.yml
- name: Install prerequisites
apt:
name={{ item }}
update_cache=yes
cache_valid_time=3600
become: yes
with_items:
- git
- make
- curl
- python-novaclient
- python-neutronclient
- python-keystoneclient
- python-glanceclient
- name: Check to see if xos_install/orchestration directory exists
local_action: stat path="{{ playbook_dir }}/xos_install/orchestration"
register: orchestration
# Two methods to install:
# 1) If running from cord-in-a-box, then xos_install/orchestration will
# be populated with the checked-out xos repositories, and we can
# now copy them to the XOS VM.
# 2) If not running from cord-in-a-box, then xos_install will not
# exist, and we will check out the repos using git.
- name: Copy repositories to the XOS VM
synchronize:
src: "{{ playbook_dir }}/xos_install/orchestration/"
dest: "{{ orchestration_dest }}"
when:
orchestration.stat.exists == True
- name: Clone XOS repo
git:
repo={{ xos_repo_url }}
dest={{ xos_repo_dest }}
version={{ xos_repo_branch }}
force=yes
when:
orchestration.stat.exists == False
- name: Clone service-profile repo
git:
repo={{ service_profile_repo_url }}
dest={{ service_profile_repo_dest }}
version={{ service_profile_repo_branch }}
force=yes
when:
orchestration.stat.exists == False
- name: Copy over SSH keys
copy:
src=~/.ssh/{{ item }}
dest={{ service_profile_repo_dest }}/{{ xos_configuration }}/
owner={{ ansible_user_id }} mode=0600
with_items:
- id_rsa
- id_rsa.pub
- name: copy over node_key
copy:
src={{ node_private_key }}
dest={{ service_profile_repo_dest }}/{{ xos_configuration }}/node_key
owner={{ ansible_user_id }} mode=0600
- name: Download Glance VM images
get_url:
url={{ item.url }}
checksum={{ item.checksum }}
dest={{ service_profile_repo_dest }}/{{ xos_configuration }}/images/{{ item.name }}.img
with_items: "{{ xos_images }}"
- name: Check to see if registry is reachable
command: curl -sf http://docker-registry:5000/
ignore_errors: yes
register: docker_registry_check
tags:
- skip_ansible_lint
- name: Use registry if it is available
set_fact:
docker_registry: "{{ local_docker_registry }}"
docker_opts: "--insecure-registry {{ local_docker_registry }}"
docker_tag: "candidate"
when: docker_registry_check|succeeded
- name: Set docker options
become: yes
template: src=docker.j2 dest=/etc/default/docker
register: set_docker_opts
# Note this needs to be executed now, not as a handler, as the pull
# operations won't succeed without it.
- name: restart docker
become: yes
service: name=docker state=restarted
when: set_docker_opts.changed
- name: Pull database and cord-app-build image
become: yes
command: docker pull {{ item }}
with_items:
- xosproject/xos-postgres
- xosproject/cord-app-build
tags:
- skip_ansible_lint # FIXME: use new 2.2 docker modules when available
- name: Pull docker images for XOS
when: not xos_container_rebuild
become: yes
command: docker pull {{ item }}
with_items:
- "{{ docker_registry }}/xosproject/xos-base:{{ docker_tag }}"
- name: Rebuild XOS containers
when: xos_container_rebuild
command: make {{ item }}
chdir="{{ xos_repo_dest }}/containers/xos/"
with_items:
- base