Update MNAIO to use Ansible Collections

This patch updates various playbooks within the MNAIO to use ansible
collections, which is required for the latest Ansible versions.

Change-Id: Ia7694e6b182dc8898b56730537cc99759a722b20
This commit is contained in:
James Denton 2022-07-23 20:59:37 +00:00
parent 6cc3b9b03d
commit ff7cbf5548
5 changed files with 40 additions and 30 deletions

View File

@ -26,6 +26,9 @@ ansible vm_hosts \
export MNAIO_ANSIBLE_PARAMETERS=${MNAIO_ANSIBLE_PARAMETERS:-""}
# Install Ansible Collections
ansible-galaxy install -r requirements.yml
# TODO(odyssey4me):
# Replace this build override mechanism to just respect the
# group_vars instead of duplicating defaults here.

View File

@ -17,15 +17,15 @@
tasks:
- name: Ensure python-shade library is present to run ansible os_xxx modules
apt:
name: python-shade
state: present
tags:
- always
# - name: Ensure python-shade library is present to run ansible os_xxx modules
# apt:
# name: python-shade
# state: present
# tags:
# - always
- name: Create flavors of nova VMs
os_nova_flavor:
openstack.cloud.os_nova_flavor:
endpoint_type: internal
cloud: default
state: present
@ -40,7 +40,7 @@
- create_flavors
- name: Create networks
os_network:
openstack.cloud.os_network:
endpoint_type: internal
cloud: default
state: present
@ -55,7 +55,7 @@
- create_networks
- name: Create networks (OVN)
os_network:
openstack.cloud.os_network:
endpoint_type: internal
cloud: default
state: present
@ -68,7 +68,7 @@
when: osa_enable_networking_ovn | default(false) | bool
- name: Create subnets on networks
os_subnet:
openstack.cloud.os_subnet:
endpoint_type: internal
cloud: default
state: present
@ -86,7 +86,7 @@
- create_networks
- name: Create a router on both public and private networks
os_router:
openstack.cloud.os_router:
endpoint_type: internal
cloud: default
state: present
@ -109,7 +109,7 @@
- create_networks
- name: Setup rules on all security groups
os_security_group_rule:
openstack.cloud.os_security_group_rule:
endpoint_type: internal
cloud: default
security_group: "{{ item[1] }}"

View File

@ -183,7 +183,7 @@
root_public_key: "{{ public_key_get.stdout }}"
- name: Ensure root can ssh to localhost
authorized_key:
ansible.posix.authorized_key:
user: "root"
key: "{{ root_public_key }}"
@ -303,30 +303,30 @@
- mnaio_bridges is changed
- name: Disable default virt network
virt_net:
community.libvirt.virt_net:
name: "default"
state: inactive
- name: Prevent default virt network autostart
virt_net:
community.libvirt.virt_net:
name: "default"
autostart: no
- name: Define virt network(s)
virt_net:
community.libvirt.virt_net:
name: "{{ item.value.iface }}"
state: present
xml: "{{ lookup('template', 'kvm/libvirt-network-template.xml.j2') }}"
with_dict: "{{ mnaio_host_networks }}"
- name: Set virt network(s) to active
virt_net:
community.libvirt.virt_net:
name: "{{ item.value.iface }}"
state: active
with_dict: "{{ mnaio_host_networks }}"
- name: Set virt network(s) to autostart
virt_net:
community.libvirt.virt_net:
name: "{{ item.value.iface }}"
autostart: yes
with_dict: "{{ mnaio_host_networks }}"
@ -352,7 +352,7 @@
- mnaio_data_disk is defined
block:
- name: Setup the data disk partition
parted:
community.general.parted:
device: "/dev/{{ mnaio_data_disk }}"
label: gpt
number: 1
@ -361,7 +361,7 @@
register: _add_partition
- name: Prepare the data disk file system
filesystem:
community.general.filesystem:
fstype: ext4
dev: "/dev/{{ mnaio_data_disk }}{{ mnaio_data_disk_suffix | default('1') }}"
force: yes
@ -370,7 +370,7 @@
- _add_partition is changed
- name: Mount the data disk
mount:
ansible.posix.mount:
src: "/dev/{{ mnaio_data_disk }}{{ mnaio_data_disk_suffix | default('1') }}"
path: /data
state: mounted
@ -385,7 +385,7 @@
state: directory
- name: Define the default virt storage pool
virt_pool:
community.libvirt.virt_pool:
name: default
state: present
xml: |
@ -402,12 +402,12 @@
</pool>
- name: Set default virt storage pool to active
virt_pool:
community.libvirt.virt_pool:
name: default
state: active
- name: Set default virt storage pool to autostart
virt_pool:
community.libvirt.virt_pool:
name: default
autostart: yes

View File

@ -19,7 +19,7 @@
gather_facts: false
tasks:
- name: Create vm_servers group
add_host:
ansible.builtin.add_host:
name: "{{ item }}"
groups: vm_servers
when:
@ -39,21 +39,21 @@
timeout: "{{ vm_ssh_timeout }}"
rescue:
- name: Gather VM info (rescue)
virt:
community.libvirt.virt:
command: status
name: "{{ inventory_hostname }}"
connection: local
register: vm_info
- name: Stop VM (rescue)
virt:
community.libvirt.virt:
command: destroy
name: "{{ inventory_hostname }}"
connection: local
when: vm_info.status == 'running'
- name: Start VM (rescue)
virt:
community.libvirt.virt:
command: start
name: "{{ inventory_hostname }}"
connection: local
@ -67,7 +67,7 @@
ignore_errors: true
- name: Gather VM info 2nd pass (rescue)
virt:
community.libvirt.virt:
command: status
name: "{{ inventory_hostname }}"
connection: local
@ -89,7 +89,7 @@
meta: refresh_inventory
- name: Create vm_servers group
add_host:
ansible.builtin.add_host:
name: "{{ item }}"
groups: vm_servers
when:

View File

@ -0,0 +1,7 @@
---
collections:
- ansible.netcommon
- ansible.posix
- community.general
- community.libvirt
- openstack.cloud