Make NovaResumeGuestsStateOnHostBoot podman compatible

With podman therefore are changes required to the libvirt-guests
unit file and how we dealt with dependencies of the containers.
With podman systemd is used to manage the containers which we now
can use for container dependencies and use libvirt-guests from
inside a container.

Change-Id: I2a1f370732effd3303942dd5ec46892ec4a85df9
Closes-Bug: #1830067
This commit is contained in:
Martin Schuppert 2019-05-22 16:05:08 +02:00
parent 45a94c8710
commit 6b0d025fd6
2 changed files with 58 additions and 4 deletions

View File

@ -591,6 +591,7 @@ outputs:
privileged: true
user: nova
restart: always
depends_on: tripleo_nova_libvirt
healthcheck: {get_attr: [ContainersCommon, healthcheck_rpc_port]}
volumes:
list_concat:
@ -688,10 +689,17 @@ outputs:
- name: is Nova Resume Guests State On Host Boot enabled
set_fact:
resume_guests_state_on_host_boot_enabled: {get_param: NovaResumeGuestsStateOnHostBoot}
- name: install libvirt-guests systemd unit file
when: resume_guests_state_on_host_boot_enabled|bool
- name: install libvirt-guests systemd unit file (docker)
when:
- resume_guests_state_on_host_boot_enabled|bool
- container_cli == 'docker'
block:
- name: libvirt-guests unit to stop nova_api container before shutdown VMs
- name: make sure libvirt-client is installed
when: resume_guests_state_on_host_boot_enabled|bool
package:
name: libvirt-client
state: present
- name: libvirt-guests unit to stop nova_compute container before shutdown VMs
copy:
dest: /etc/systemd/system/libvirt-guests.service
content: |
@ -726,6 +734,47 @@ outputs:
name: libvirt-guests
enabled: yes
daemon_reload: yes
- name: install tripleo_nova_libvirt_guests systemd unit file (podman)
when:
- resume_guests_state_on_host_boot_enabled|bool
- container_cli == 'podman'
block:
- name: make sure default libvirt-guests is disabled
systemd:
name: libvirt-guests
enabled: no
state: stopped
masked: yes
daemon_reload: yes
- name: libvirt-guests unit to stop nova_compute container before shutdown VMs
copy:
dest: /etc/systemd/system/tripleo_nova_libvirt_guests.service
content: |
[Unit]
Description=Suspend libvirt Guests in tripleo
Requires=virt-guest-shutdown.target
After=systemd-machined.service
After=tripleo_nova_libvirt.service
Before=tripleo_nova_compute.service
Documentation=man:libvirtd(8)
Documentation=https://libvirt.org
[Service]
EnvironmentFile=-/etc/sysconfig/libvirt-guests
ExecStart=/usr/bin/podman exec nova_libvirt /bin/rm -f /var/lib/libvirt/libvirt-guests
ExecStop=/usr/bin/podman exec nova_libvirt /bin/sh -x /usr/libexec/libvirt-guests.sh shutdown
Type=oneshot
RemainAfterExit=yes
StandardOutput=journal+console
TimeoutStopSec=0
[Install]
WantedBy=multi-user.target
- name: tripleo_nova_libvirt_guests enable VM shutdown on compute reboot/shutdown
systemd:
name: tripleo_nova_libvirt_guests
enabled: yes
daemon_reload: yes
- name: create persistent directories
file:
path: "{{ item.path }}"

View File

@ -515,6 +515,7 @@ outputs:
list_join:
- "\n"
- - include tripleo::profile::base::nova::libvirt
- include tripleo::profile::base::nova::compute::libvirt_guests
- {get_attr: [MySQLClient, role_data, step_config]}
config_image: {get_param: DockerNovaLibvirtConfigImage}
kolla_config:
@ -629,6 +630,8 @@ outputs:
privileged: true
security_opt: label=disable
restart: always
depends_on:
- tripleo_nova_virtlogd
healthcheck:
test: /openstack/healthcheck
volumes:
@ -788,11 +791,13 @@ outputs:
failed_when: false
register: libvirt_installed
check_mode: no
- name: make sure libvirt services are disabled
- name: make sure libvirt services are disabled and masked
service:
name: "{{ item }}"
state: stopped
enabled: no
masked: yes
daemon_reload: yes
with_items:
- libvirtd.service
- virtlogd.socket