Make storage playbooks idempotent
Also this disables libvirt networking templates, untill we have a working template requirement. Change-Id: Id3098b3dc5eec15f41c30d5b656dd3bc9a632e42
This commit is contained in:
parent
88a2792eb5
commit
24e9812d56
@ -14,6 +14,11 @@
|
||||
|
||||
set -ex
|
||||
|
||||
READINESS_CHECK_FILE="/tmp/healthy"
|
||||
|
||||
## Remove healthy status before starting
|
||||
[ -f "${READINESS_CHECK_FILE}" ] && rm ${READINESS_CHECK_FILE}
|
||||
|
||||
# wait for libvirt socket to be ready
|
||||
TIMEOUT=300
|
||||
while [[ ! -e /var/run/libvirt/libvirt-sock ]]; do
|
||||
@ -51,10 +56,15 @@ while [[ ${TIMEOUT} -gt 0 ]]; do
|
||||
done
|
||||
|
||||
ansible-playbook -v \
|
||||
-e @/vino/spec \
|
||||
-e @/var/lib/vino-builder/flavors/flavors.yaml \
|
||||
-e @/var/lib/vino-builder/flavor-templates/flavor-templates.yaml \
|
||||
-e @/var/lib/vino-builder/network-templates/network-templates.yaml \
|
||||
-e @/var/lib/vino-builder/storage-templates/storage-templates.yaml \
|
||||
-e @$DYNAMIC_DATA_FILE \
|
||||
/playbooks/vino-builder.yaml
|
||||
|
||||
touch ${READINESS_CHECK_FILE}
|
||||
|
||||
while true; do
|
||||
sleep infinity
|
||||
done
|
@ -14,29 +14,19 @@
|
||||
# never re-define it
|
||||
- name: add networks defined if they do not already exist
|
||||
virt_net:
|
||||
command: define
|
||||
state: present
|
||||
# looks like setting name here is a redundant, the name is anyways taken from the template xml file, but should set it to make virt_pool module happy.
|
||||
name: "{{ item.name }}"
|
||||
xml: "{{ item.libvirtTemplate }}"
|
||||
uri: "{{ libvirt_uri }}"
|
||||
when: 'item.name not in ansible_libvirt_networks'
|
||||
vars:
|
||||
nodebridgegw: ipam.bridge_ip
|
||||
|
||||
# Re-gather Facts will be available as 'ansible_libvirt_networks'
|
||||
- name: re-gather facts on existing virsh networks
|
||||
- name: activate the network
|
||||
virt_net:
|
||||
command: facts
|
||||
name: ""
|
||||
uri: "{{ libvirt_uri }}"
|
||||
ignore_errors: true
|
||||
|
||||
- name: start the network
|
||||
virt_net:
|
||||
command: create
|
||||
state: active
|
||||
name: "{{ item.name }}"
|
||||
uri: "{{ libvirt_uri }}"
|
||||
when: item.name in ansible_libvirt_networks and ansible_libvirt_networks[item.name].state != "active"
|
||||
|
||||
# these are idempotent so require no conditional checks
|
||||
- name: autostart the network
|
||||
@ -44,9 +34,3 @@
|
||||
autostart: yes
|
||||
name: "{{ item.name }}"
|
||||
uri: "{{ libvirt_uri }}"
|
||||
|
||||
- name: activate the network
|
||||
virt_net:
|
||||
state: active
|
||||
name: "{{ item.name }}"
|
||||
uri: "{{ libvirt_uri }}"
|
@ -4,45 +4,12 @@
|
||||
command: facts
|
||||
uri: "{{ libvirt_uri }}"
|
||||
|
||||
- name: Print value of ansible storage pools
|
||||
debug:
|
||||
msg: "Value of ansible_libvirt_pools is {{ ansible_libvirt_pools }}"
|
||||
|
||||
- name: write out storage xml template
|
||||
copy: content="{{item.libvirtTemplate}}" dest="/tmp/storage-{{item.name}}.xml"
|
||||
|
||||
- name: define the storage pool
|
||||
shell: "virsh pool-define /tmp/storage-{{item.name}}.xml"
|
||||
|
||||
# Re-gather facts after definining additional pools available as 'ansible_libvirt_pools'
|
||||
- name: re-gather facts on existing virsh pools after defining missing pools
|
||||
- name: define storage the storage pool
|
||||
virt_pool:
|
||||
command: facts
|
||||
uri: "{{ libvirt_uri }}"
|
||||
|
||||
- name: build the storage pool
|
||||
virt_pool:
|
||||
command: build
|
||||
name: "{{ item.name }}"
|
||||
uri: "{{ libvirt_uri }}"
|
||||
when: item.name in ansible_libvirt_pools and ansible_libvirt_pools[item.name].state != "active"
|
||||
|
||||
- name: start the storage pool
|
||||
virt_pool:
|
||||
command: create
|
||||
name: "{{ item.name }}"
|
||||
uri: "{{ libvirt_uri }}"
|
||||
when: item.name in ansible_libvirt_pools and ansible_libvirt_pools[item.name].state != "active"
|
||||
|
||||
# these are idempotent so require no conditional checks
|
||||
|
||||
# TODO: we are not actually defining configs on the host
|
||||
# for some reason we cannot do this
|
||||
- name: autostart the storage pool
|
||||
virt_pool:
|
||||
autostart: yes
|
||||
state: present
|
||||
name: "{{ item.name }}"
|
||||
uri: "{{ libvirt_uri }}"
|
||||
xml: "{{item.libvirtTemplate}}"
|
||||
|
||||
- name: activate the storage pool
|
||||
virt_pool:
|
||||
|
@ -10,9 +10,9 @@
|
||||
# configure networks #
|
||||
##########################################
|
||||
|
||||
- name: create network
|
||||
include_tasks: create-network.yaml
|
||||
loop: "{{ libvirtNetworks }}"
|
||||
# - name: create network
|
||||
# include_tasks: create-network.yaml
|
||||
# loop: "{{ libvirtNetworks }}"
|
||||
|
||||
##########################################
|
||||
# configure domains #
|
||||
|
Loading…
Reference in New Issue
Block a user