Tweaks to make install run idempotent

This commit is contained in:
Egon Rijpkema 2017-08-01 10:19:54 +02:00
parent 1a78f649e8
commit 8a3fbd557d
13 changed files with 50 additions and 33 deletions

View File

@ -41,7 +41,7 @@
{{ env_vars }}
--add-host=nova-controller:{{ hostvars[groups['nova-controller'][0]]['ansible_default_ipv4']['address'] }} \
--add-host=keystone:{{ hostvars[groups['keystone'][0]]['ansible_default_ipv4']['address'] }} \
hpc/openstack-glance /etc/bootstrap.sh
{{ docker_image }} /etc/bootstrap.sh
tags: bootstrap
- name: make sure service is started

View File

@ -1,8 +1,11 @@
# Run hpc/horizon
---
- set_fact:
docker_image: webhost12.service.rug.nl/hpc/openstack-horizon:latest
- name: pull docker image
docker_image:
name: webhost12.service.rug.nl/hpc/openstack-horizon:latest
name: "{{ docker_image }}"
tags: pull
- name: install service file.

View File

@ -12,8 +12,9 @@ ExecStart=/usr/bin/docker run --name %n \
-e "KEYSTONE_HOST={{ hostvars[groups['keystone'][0]]['ansible_default_ipv4']['address'] }}" \
--add-host=nova-controller:{{ hostvars[groups['nova-controller'][0]]['ansible_default_ipv4']['address'] }} \
--add-host=keystone:{{ hostvars[groups['keystone'][0]]['ansible_default_ipv4']['address'] }} \
--add-host=neutron-controller:{{ hostvars[groups['neutron-controller'][0]]['ansible_default_ipv4']['address'] }} \
-p 80:80 \
hpc/openstack-horizon
{{ docker_image }}
[Install]
WantedBy=multi-user.target

View File

@ -6,9 +6,12 @@
state: directory
mode: 0777
- name: pull keystone image
- set_fact:
docker_image: webhost12.service.rug.nl/hpc/openstack-keystone:latest
- name: pull docker image
docker_image:
name: webhost12.service.rug.nl/hpc/openstack-keystone:latest
name: "{{ docker_image }}"
tags: pull
- name: install service file.
@ -31,7 +34,7 @@
--add-host=mariadb:{{ hostvars[groups['databases'][0]]['ansible_default_ipv4']['address'] }}
-v /srv/keystone/fernet-keys:/etc/keystone/fernet-keys
-e "KEYSTONE_HOST={{ hostvars[groups['keystone'][0]]['ansible_default_ipv4']['address'] }}"
hpc/keystone keystone-manage {{ item }}
{{ docker_image }} keystone-manage {{ item }}
with_items:
- db_sync
- fernet_setup --keystone-user keystone --keystone-group keystone
@ -43,15 +46,15 @@
--bootstrap-public-url http://{{ hostvars[groups['keystone'][0]]['ansible_default_ipv4']['address'] }}:5000/v3/
--bootstrap-region-id RegionOne
- name: make sure service is started
systemd:
name: keystone.service
state: restarted
- name: Create a domain, projects users and roles
command: >
/usr/bin/docker run --rm
--add-host=mariadb:{{ hostvars[groups['databases'][0]]['ansible_default_ipv4']['address'] }}
-v /srv/keystone/fernet-keys:/etc/keystone/fernet-keys
-e "KEYSTONE_HOST={{ hostvars[groups['keystone'][0]]['ansible_default_ipv4']['address'] }}"
hpc/keystone bash /etc/bootstrap.sh
- name: make sure service is started
systemd:
name: keystone.service
state: restarted
{{ docker_image }} bash /etc/bootstrap.sh

View File

@ -12,7 +12,7 @@ ExecStart=/usr/bin/docker run --name %n \
-e "KEYSTONE_HOST={{ hostvars[groups['keystone'][0]]['ansible_default_ipv4']['address'] }}" \
-p 5000:5000 -p 35357:35357 \
-v /srv/keystone/fernet-keys:/etc/keystone/fernet-keys \
hpc/openstack-keystone
{{ docker_image }}
[Install]
WantedBy=multi-user.target

View File

@ -1,8 +1,11 @@
# Build and install a docker image for neutron-controller.
---
- set_fact:
docker_image: "webhost12.service.rug.nl/hpc/openstack-neutron-controller:latest"
- name: pull docker image
docker_image:
name: webhost12.service.rug.nl/hpc/openstack-neutron-controller:latest
name: "{{ docker_image }}"
tags: pull
- set_fact:
@ -18,10 +21,10 @@
-e "NOVA_PASSWORD=geheim"
-e "NOVA_USER=nova"
-e "MEMCACHED_HOST={{ hostvars[groups['memcached'][0]]['ansible_default_ipv4']['address'] }}"
-e "OVERLAY_INTERFACE_IP_ADDRESS={{ hostvars[groups['neutron-controller'][0]]['ansible_default_ipv4']['address'] }}"
-e "PROVIDER_INTERFACE_NAME={{ hostvars[groups['neutron-controller'][0]]['ansible_default_ipv4']['interface'] }}"
-e "RABBIT_PASSWORD=geheim"
-e "RABBIT_USER=openstack"
tags: env
- name: install service file.
template:
@ -40,7 +43,7 @@
--add-host=mariadb:{{ hostvars[groups['databases'][0]]['ansible_default_ipv4']['address'] }}
--add-host=keystone:{{ hostvars[groups['keystone'][0]]['ansible_default_ipv4']['address'] }}
--network host
hpc/openstack-neutron-controller
{{ docker_image }}
/etc/bootstrap.sh
tags: bootstrap

View File

@ -16,7 +16,7 @@ ExecStart=/usr/bin/docker run --name %n \
--privileged \
--network host \
-v /lib/modules:/lib/modules \
hpc/openstack-neutron-controller /etc/run.sh
{{ docker_image }} /etc/run.sh
[Install]
WantedBy=multi-user.target

View File

@ -1,8 +1,12 @@
# Build and install a docker image for nova-controller.
---
- set_fact:
docker_image: webhost12.service.rug.nl/hpc/openstack-nova-compute:latest
tags: facts
- name: pull docker image
docker_image:
name: webhost12.service.rug.nl/hpc/openstack-nova-compute:latest
name: "{{ docker_image }}"
tags: pull
- name: install service file.

View File

@ -34,7 +34,7 @@ ExecStart=/usr/bin/docker run --name %n \
-v /var/run/libvirt/libvirt-sock:/var/run/libvirt/libvirt-sock \
-v /srv/osdisks:/var/lib/nova/instances \
--network host \
hpc/openstack-nova-compute /etc/run.sh
{{ docker_image }} /etc/run.sh
[Install]
WantedBy=multi-user.target

View File

@ -1,11 +1,7 @@
# Build and install a docker image for nova-controller.
---
- name: pull docker image
docker_image:
name: webhost12.service.rug.nl/hpc/openstack-nova-service:latest
tags: pull
- set_fact:
docker_image: webhost12.service.rug.nl/hpc/openstack-nova-service:latest
env_vars: >
-e "MY_IP={{ hostvars[groups['nova-controller'][0]]['ansible_default_ipv4']['address'] }}"
-e "NOVA_USER=nova"
@ -24,6 +20,12 @@
-e "NEUTRON_PASSWORD=geheim"
-e "NEUTRON_USER=neutron"
-e "METADATA_SECRET=geheim"
tags: facts
- name: pull docker image
docker_image:
name: "{{ docker_image }}"
tags: pull
- name: install service file.
template:
@ -40,7 +42,7 @@
/usr/bin/docker run --rm
{{ env_vars }}
--add-host=mariadb:{{ hostvars[groups['databases'][0]]['ansible_default_ipv4']['address'] }}
hpc/openstack-nova-service
{{ docker_image }}
/etc/bootstrap.sh
tags: bootstrap

View File

@ -14,7 +14,7 @@ ExecStart=/usr/bin/docker run --name %n \
--privileged \
-p 8774:8774 \
-p 8778:8778 \
hpc/openstack-nova-service /etc/run.sh
{{ docker_image }} /etc/run.sh
[Install]
WantedBy=multi-user.target

View File

@ -30,3 +30,5 @@
- rabbitmqctl add_user openstack geheim
- rabbitmqctl set_permissions openstack ".*" ".*" ".*"
when: ansible_nodename == hostname_node0
register: command_result
failed_when: "command_result.rc not in (0, 70)"

View File

@ -1,12 +1,11 @@
---
- include: common.yml
- include: mariadb.yml
- include: glance-controller.yml
- include: horizon.yml
- include: keystone.yml
- include: mariadb.yml
- include: rabbitmq.yml
- include: memcached.yml
- include: mariadb.yml
- include: keystone.yml
- include: glance-controller.yml
- include: nova-controller.yml
- include: neutron-controller.yml
- include: nova-compute.yml
- include: nova-controller.yml
- include: rabbitmq.yml
- include: horizon.yml