hpc-cloud/roles/nova-controller/tasks/main.yml

73 lines
2.7 KiB
YAML

# Build and install a docker image for nova-controller.
---
- name: include secrets
include_vars:
file: ../../secrets.yml
name: secrets
- name: Make persistent directories
file:
path: "{ item }}"
state: directory
mode: 0777
with_items:
- /srv/nova-controller
- /srv/nova-controller/root
- set_fact:
docker_image: registry.webhosting.rug.nl/hpc/openstack-nova-service:latest
env_vars: >
-e "GLANCE_CONTROLLER_HOST={{ listen_ip | default(hostvars[groups['glance-controller'][0]]['ansible_default_ipv4']['address']) }}"
-e "KEYSTONE_HOST={{ listen_ip | default(hostvars[groups['keystone'][0]]['ansible_default_ipv4']['address']) }}"
-e "MEMCACHED_HOST={{ listen_ip | default(hostvars[groups['memcached'][0]]['ansible_default_ipv4']['address']) }}"
-e "MY_IP={{ listen_ip | default(hostvars[groups['nova-controller'][0]]['ansible_default_ipv4']['address']) }}"
-e "MYSQL_HOST={{ listen_ip | default(hostvars[groups['databases'][0]]['ansible_default_ipv4']['address']) }}"
-e "MYSQL_ROOT_PASSWORD={{ secrets['MYSQL_ROOT_PASSWORD'] }}"
-e "NEUTRON_CONTROLLER_HOST={{ listen_ip | default(hostvars[groups['keystone'][0]]['ansible_default_ipv4']['address']) }}"
-e "NEUTRON_PASSWORD={{ secrets['NEUTRON_PASSWORD'] }}"
-e "NEUTRON_USER=neutron"
-e "NOVA_CONTROLLER_HOST={{ listen_ip | default(hostvars[groups['nova-controller'][0]]['ansible_default_ipv4']['address']) }}"
-e "NOVA_PASSWORD={{ secrets['NOVA_PASSWORD'] }}"
-e "NOVA_PLACEMENT_PASSWORD={{ secrets['NOVA_PLACEMENT_PASSWORD'] }}"
-e "NOVA_PLACEMENT_USER=placement"
-e "NOVA_USER=nova"
-e "OS_PASSWORD={{ secrets['OS_PASSWORD'] }}"
-e "RABBIT_PASSWORD={{ secrets['RABBIT_PASSWORD'] }}"
-e "RABBIT_USER=openstack"
tags: facts
- name: pull docker image
docker_image:
name: "{{ docker_image }}"
force: True
tags: pull
- name: install service file.
template:
src: templates/nova-controller.service
dest: /etc/systemd/system/nova-controller.service
mode: 644
owner: root
group: root
- command: systemctl daemon-reload
- name: start service at boot.
command: systemctl reenable nova-controller.service
- name: Initialize database.
command: >
/usr/bin/docker run --rm
{{ env_vars }}
--add-host=mariadb:{{ listen_ip | default(hostvars[groups['databases'][0]]['ansible_default_ipv4']['address']) }}
--add-host=keystone:{{ listen_ip | default(hostvars[groups['keystone'][0]]['ansible_default_ipv4']['address']) }}
-v /srv/nova-controller/root:/root
{{ docker_image }}
/etc/bootstrap.sh
tags: bootstrap
- name: make sure service is started
systemd:
name: nova-controller.service
state: restarted