From ff7cbf5548ed5bfe8b48857310179353b9325c31 Mon Sep 17 00:00:00 2001 From: James Denton Date: Sat, 23 Jul 2022 20:59:37 +0000 Subject: [PATCH] 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 --- multi-node-aio/build.sh | 3 +++ .../playbooks/openstack-service-setup.yml | 24 +++++++++---------- multi-node-aio/playbooks/setup-host.yml | 24 +++++++++---------- multi-node-aio/playbooks/vm-status.yml | 12 +++++----- multi-node-aio/requirements.yml | 7 ++++++ 5 files changed, 40 insertions(+), 30 deletions(-) create mode 100644 multi-node-aio/requirements.yml diff --git a/multi-node-aio/build.sh b/multi-node-aio/build.sh index e693381b..109f8264 100755 --- a/multi-node-aio/build.sh +++ b/multi-node-aio/build.sh @@ -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. diff --git a/multi-node-aio/playbooks/openstack-service-setup.yml b/multi-node-aio/playbooks/openstack-service-setup.yml index d6a70ad9..de2285aa 100644 --- a/multi-node-aio/playbooks/openstack-service-setup.yml +++ b/multi-node-aio/playbooks/openstack-service-setup.yml @@ -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] }}" diff --git a/multi-node-aio/playbooks/setup-host.yml b/multi-node-aio/playbooks/setup-host.yml index cff5fb7f..3aff60ec 100644 --- a/multi-node-aio/playbooks/setup-host.yml +++ b/multi-node-aio/playbooks/setup-host.yml @@ -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 @@ - 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 diff --git a/multi-node-aio/playbooks/vm-status.yml b/multi-node-aio/playbooks/vm-status.yml index 4a5b0131..667ad8bb 100644 --- a/multi-node-aio/playbooks/vm-status.yml +++ b/multi-node-aio/playbooks/vm-status.yml @@ -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: diff --git a/multi-node-aio/requirements.yml b/multi-node-aio/requirements.yml new file mode 100644 index 00000000..c0d342d5 --- /dev/null +++ b/multi-node-aio/requirements.yml @@ -0,0 +1,7 @@ +--- +collections: +- ansible.netcommon +- ansible.posix +- community.general +- community.libvirt +- openstack.cloud