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

88 lines
2.9 KiB
YAML

# Build and install a docker image for glance.
---
- name: include secrets
include_vars:
file: ../../secrets.yml
name: secrets
- set_fact:
docker_image: registry.webhosting.rug.nl/hpc/openstack-glance:latest
env_vars: >
-e "GLANCE_HOST={{ listen_ip | default(hostvars[groups['glance-controller'][0]]['ansible_default_ipv4']['address']) }}"
-e "GLANCE_PASSWORD={{ secrets['GLANCE_PASSWORD'] }}"
-e "GLANCE_USER=glance"
-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 "MYSQL_HOST={{ listen_ip | default(hostvars[groups['databases'][0]]['ansible_default_ipv4']['address']) }}"
-e "MYSQL_ROOT_PASSWORD={{ secrets['MYSQL_ROOT_PASSWORD'] }}"
-e "OS_PASSWORD={{ secrets['OS_PASSWORD'] }}"
-e "RABBIT_HOST={{ listen_ip | default(hostvars[groups['rabbitmq'][0]]['ansible_default_ipv4']['address']) }}"
-e "RABBIT_PASSWORD={{ secrets['RABBIT_PASSWORD'] }}"
-e "RABBIT_USER=openstack"
-e "USE_CEPH={{ use_ceph }}"
-e "MON_INITIAL_MEMBERS={{ ceph_mon_initial_members }}"
-e "MON_HOST={{ ceph_mon_host }}"
-e "PUBLIC_NETWORK={{ ceph_public_network }}"
-e "OSD_POOL_DEFAULT_SIZE={{ ceph_osd_pool_default_size }}"
#- name: pull docker image
# docker_image:
# name: "{{ docker_image }}"
# tags: pull
- name: Make build and persistent directories
file:
path: "{{ item }}"
state: directory
mode: 0777
with_items:
- /srv/glance
- /srv/glance/root
- /srv/glance/etc/ceph
- name: copy ceph-client configurationfile
copy:
src: files/ceph.conf
dest: /srv/glance/etc/ceph/ceph.conf
mode: 0644
- name: copy ceph-client-keyring
copy:
src: files/ceph.client.images.keyring
dest: /srv/glance/etc/ceph/ceph.client.images.keyring
mode: 0644
#- name: set ceph client keyring
# copy:
# content: "{{ceph_images_client_keyring}}"
# dest: /srv/cinder-storage/etc/ceph/ceph.client.images.keyring
# when: use_ceph
- name: install service file.
template:
src: templates/glance.service
dest: /etc/systemd/system/glance.service
mode: 644
owner: root
group: root
- name: start service at boot.
command: systemctl reenable glance.service
- command: systemctl daemon-reload
- name: Initialize database.
command: >
/usr/bin/docker run --rm
{{ env_vars }}
--add-host=keystone:{{ listen_ip | default(hostvars[groups['keystone'][0]]['ansible_default_ipv4']['address']) }} \
-v /srv/glance/root:/root \
-v /var/lib/glance/images:/var/lib/glance/images \
{{ docker_image }} /etc/bootstrap.sh
tags: bootstrap
- name: make sure service is started
systemd:
name: glance.service
state: restarted