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:-""} export MNAIO_ANSIBLE_PARAMETERS=${MNAIO_ANSIBLE_PARAMETERS:-""}
# Install Ansible Collections
ansible-galaxy install -r requirements.yml
# TODO(odyssey4me): # TODO(odyssey4me):
# Replace this build override mechanism to just respect the # Replace this build override mechanism to just respect the
# group_vars instead of duplicating defaults here. # group_vars instead of duplicating defaults here.

View File

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

View File

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

View File

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

View File

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