Cinder storage role
This commit is contained in:
parent
0c28f889b3
commit
29c0634bc1
61
roles/cinder-storage/tasks/main.yml
Normal file
61
roles/cinder-storage/tasks/main.yml
Normal file
@ -0,0 +1,61 @@
|
||||
# Build and install a docker image for cinder.
|
||||
---
|
||||
- name: include secrets
|
||||
include_vars:
|
||||
file: ../../secrets.yml
|
||||
name: secrets
|
||||
|
||||
- set_fact:
|
||||
docker_image: webhost12.service.rug.nl/hpc/openstack-cinder-storage:latest
|
||||
env_vars: >
|
||||
-e "MY_IP={{ ansible_default_ipv4.address }}"
|
||||
-e "CINDER_HOST={{ hostvars[groups['cinder-storage'][0]]['ansible_default_ipv4']['address'] }}"
|
||||
-e "CINDER_PASSWORD={{ secrets['CINDER_PASSWORD'] }}"
|
||||
-e "CINDER_USER=cinder"
|
||||
-e "GLANCE_HOST={{ hostvars[groups['glance-controller'][0]]['ansible_default_ipv4']['address'] }}"
|
||||
-e "KEYSTONE_HOST={{ hostvars[groups['keystone'][0]]['ansible_default_ipv4']['address'] }}"
|
||||
-e "MYSQL_HOST={{ 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={{ hostvars[groups['rabbitmq'][0]]['ansible_default_ipv4']['address'] }}"
|
||||
-e "RABBIT_PASSWORD={{ secrets['RABBIT_PASSWORD'] }}"
|
||||
-e "RABBIT_USER=openstack"
|
||||
|
||||
- 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/cinder-storage
|
||||
- /srv/cinder-storage/root
|
||||
|
||||
- name: initial setup
|
||||
command: >
|
||||
/usr/bin/docker run --rm
|
||||
--privileged
|
||||
{{ env_vars }}
|
||||
-v /srv/cinder-storage/root:/root \
|
||||
-v "{{ storage_volume }}":/dev/cinder_storage_volume \
|
||||
{{ docker_image }} /etc/bootstrap.sh
|
||||
tags: bootstrap
|
||||
|
||||
- name: install service file.
|
||||
template:
|
||||
src: templates/cinder-storage.service
|
||||
dest: /etc/systemd/system/cinder-storage.service
|
||||
mode: 644
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
- command: systemctl daemon-reload
|
||||
|
||||
- name: make sure service is started
|
||||
systemd:
|
||||
name: cinder-storage.service
|
||||
state: restarted
|
20
roles/cinder-storage/templates/cinder-storage.service
Normal file
20
roles/cinder-storage/templates/cinder-storage.service
Normal file
@ -0,0 +1,20 @@
|
||||
[Unit]
|
||||
Description=Openstack Glance Container
|
||||
After=docker.service
|
||||
Requires=docker.service
|
||||
|
||||
[Service]
|
||||
TimeoutStartSec=0
|
||||
Restart=always
|
||||
ExecStartPre=-/usr/bin/docker kill %n
|
||||
ExecStartPre=-/usr/bin/docker rm %n
|
||||
ExecStart=/usr/bin/docker run --name %n \
|
||||
--privileged \
|
||||
{{ env_vars | replace('\n', '') }} \
|
||||
-v /srv/cinder-storage/root:/root \
|
||||
-v "{{ storage_volume }}":/dev/cinder_storage_volume \
|
||||
-p 8776:8776 \
|
||||
{{ docker_image }}
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Loading…
Reference in New Issue
Block a user