4ce47e2250
Refactor that prepares kolla_container_facts module for introducing more actions that will be moved from kolla_container module and kolla_container_volume_facts. This change is based on a discussion about adding a new action to kolla_container module that retrieves all names of the running containers. It was agreed that kolla-ansible should follow Ansible's direction of splitting modules between action modules and facts modules. Because of this, kolla_container_facts needs to be able to handle different requests for data about containers or volumes. Change-Id: Ieaec8f64922e4e5a2199db2d6983518b124cb4aa Signed-off-by: Ivan Halomi <ivan.halomi@tietoevry.com>
87 lines
2.3 KiB
YAML
87 lines
2.3 KiB
YAML
---
|
|
- name: Fail if nova_libvirt container is enabled
|
|
fail:
|
|
msg: >-
|
|
The nova_libvirt container has not been cleaned up because it is enabled.
|
|
It may be disabled by setting enable_nova_libvirt_container to false.
|
|
when: enable_nova_libvirt_container | bool
|
|
|
|
- name: Get container facts
|
|
become: true
|
|
kolla_container_facts:
|
|
action: get_containers
|
|
container_engine: "{{ kolla_container_engine }}"
|
|
name:
|
|
- nova_libvirt
|
|
register: container_facts
|
|
|
|
- block:
|
|
# NOTE(mgoddard): pgrep exit status 1 means no match.
|
|
- name: Check if there are any running VMs
|
|
become: true
|
|
shell:
|
|
cmd: >
|
|
set -o pipefail &&
|
|
{ pgrep -l qemu || test $? = 1; } | awk '!/qemu-ga/ && !/qemu-img/ {print $1}'
|
|
executable: /bin/bash
|
|
register: running_vms
|
|
|
|
- name: Fail if there are any running VMs
|
|
fail:
|
|
msg: >-
|
|
Refusing to remove nova_libvirt container with running VMs:
|
|
{{ running_vms.stdout }}
|
|
when:
|
|
- running_vms.stdout != ''
|
|
- nova_libvirt_cleanup_running_vms_fatal | bool
|
|
|
|
- name: Stop and remove nova_libvirt container
|
|
become: true
|
|
kolla_container:
|
|
common_options: "{{ docker_common_options }}"
|
|
action: "stop_and_remove_container"
|
|
name: nova_libvirt
|
|
when: container_facts['nova_libvirt'] is defined
|
|
|
|
- name: Remove nova_libvirt Docker volumes
|
|
become: true
|
|
kolla_container:
|
|
common_options: "{{ docker_common_options }}"
|
|
action: "remove_volume"
|
|
name: "{{ item }}"
|
|
loop:
|
|
- libvirtd
|
|
- nova_libvirt_qemu
|
|
- nova_libvirt_secrets
|
|
when: nova_libvirt_cleanup_remove_volumes | bool
|
|
|
|
- name: Remove config for nova_libvirt
|
|
become: true
|
|
file:
|
|
path: "{{ node_config_directory }}/nova-libvirt"
|
|
state: "absent"
|
|
|
|
# Revert the changes applied in config-host.yml.
|
|
- block:
|
|
- name: Remove udev kolla kvm rules
|
|
become: true
|
|
file:
|
|
path: "/etc/udev/rules.d/99-kolla-kvm.rules"
|
|
state: absent
|
|
|
|
- name: Reset /dev/kvm ownership
|
|
become: true
|
|
file:
|
|
path: /dev/kvm
|
|
group: kvm
|
|
|
|
- name: Unmask qemu-kvm service
|
|
become: true
|
|
systemd:
|
|
name: qemu-kvm.service
|
|
masked: false
|
|
when:
|
|
- ansible_facts.distribution == 'Ubuntu'
|
|
when:
|
|
- nova_compute_virt_type == 'kvm'
|