From 11ff642fe688a35afa3876f0f9dd7c4425f13d95 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Wed, 12 Feb 2025 14:07:12 +0100 Subject: [PATCH] Auto-fix usage of modules via FQCN Since ansible-core 2.10 it is recommended to use modules via FQCN In order to align with recommendation, we perform migration by applying suggestions made by `ansible-lint --fix=fqcn` Change-Id: I335f0f1bcdb5e5564ce3f82f44eec7d8c6ab4e0e --- handlers/main.yml | 14 +++--- tasks/consoles/nova_console_novnc_install.yml | 6 +-- tasks/consoles/nova_console_novnc_ssl.yml | 6 +-- tasks/consoles/nova_console_spice_install.yml | 4 +- tasks/drivers/kvm/nova_compute_kvm.yml | 28 ++++++------ .../drivers/kvm/nova_compute_kvm_install.yml | 12 ++--- .../kvm/nova_compute_kvm_virsh_net_remove.yml | 6 +-- tasks/drivers/kvm/nova_disable_smt.yml | 6 +-- tasks/drivers/kvm/nova_enable_ksm.yml | 4 +- tasks/drivers/kvm/nova_kernel_permissions.yml | 8 ++-- tasks/main.yml | 44 +++++++++---------- tasks/nova_compute.yml | 8 ++-- tasks/nova_compute_wait.yml | 2 +- tasks/nova_db_post_setup.yml | 10 ++--- tasks/nova_db_setup.yml | 18 ++++---- tasks/nova_install.yml | 18 ++++---- tasks/nova_mdev_detect.yml | 6 +-- tasks/nova_post_install.yml | 16 +++---- tasks/nova_pre_install.yml | 14 +++--- tasks/nova_virt_detect.yml | 8 ++-- 20 files changed, 119 insertions(+), 119 deletions(-) diff --git a/handlers/main.yml b/handlers/main.yml index d8f0cbfb..e66f82c0 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -14,7 +14,7 @@ # limitations under the License. - name: Stop libvirt-bin - service: + ansible.builtin.service: name: "{{ item }}" enabled: true state: "stopped" @@ -28,7 +28,7 @@ - nova_virt_type != 'ironic' - name: Enable sockets when needed - service: + ansible.builtin.service: name: "{{ item.name | default(item) }}" state: "{{ item.condition | default(False) | ternary('started', 'stopped') }}" enabled: "{{ item.condition | default(False) }}" @@ -42,7 +42,7 @@ - Restart libvirt-bin - name: Start libvirt-bin - service: + ansible.builtin.service: name: "{{ item }}" enabled: true state: "started" @@ -56,7 +56,7 @@ - nova_virt_type != 'ironic' - name: Symlink nova config directory - file: + ansible.builtin.file: # NOTE(cloudnull): The "src" path is relative. This ensures all files remain # within the host/container confines when connecting to # them using the connection plugin or the root filesystem. @@ -69,7 +69,7 @@ - "venv changed" - name: Drop sudoers file - template: + ansible.builtin.template: src: "sudoers.j2" dest: "/etc/sudoers.d/{{ nova_system_user_name }}_sudoers" mode: "0440" @@ -80,7 +80,7 @@ - "venv changed" - name: Stop services - service: + ansible.builtin.service: name: "{{ item.service_name }}" enabled: true state: "stopped" @@ -97,7 +97,7 @@ - "systemd service changed" - name: Start services - service: + ansible.builtin.service: name: "{{ item.service_name }}" enabled: true state: "started" diff --git a/tasks/consoles/nova_console_novnc_install.yml b/tasks/consoles/nova_console_novnc_install.yml index bfb16e55..2ec6213c 100644 --- a/tasks/consoles/nova_console_novnc_install.yml +++ b/tasks/consoles/nova_console_novnc_install.yml @@ -14,7 +14,7 @@ # limitations under the License. - name: Remove existing directory if it is not a git repo or it is dirty - shell: | + ansible.builtin.shell: | EXIT_CODE=0 FOLDER_PATH="/usr/share/novnc" if [[ -e ${FOLDER_PATH} ]]; then @@ -40,7 +40,7 @@ - nova-novnc-git - name: Get package from git - git: + ansible.builtin.git: repo: "{{ nova_novncproxy_git_repo }}" dest: "/usr/share/novnc" clone: "yes" @@ -60,7 +60,7 @@ - nova-novnc-git - name: Including nova_console_novnc_ssl tasks - include_tasks: nova_console_novnc_ssl.yml + ansible.builtin.include_tasks: nova_console_novnc_ssl.yml when: - nova_console_user_ssl_cert is defined - nova_console_user_ssl_key is defined diff --git a/tasks/consoles/nova_console_novnc_ssl.yml b/tasks/consoles/nova_console_novnc_ssl.yml index 8fa12ad4..42a4dd95 100644 --- a/tasks/consoles/nova_console_novnc_ssl.yml +++ b/tasks/consoles/nova_console_novnc_ssl.yml @@ -14,7 +14,7 @@ # limitations under the License. - name: Ensure ssl cert directory exists - file: + ansible.builtin.file: path: "{{ nova_console_ssl_dir }}" state: directory owner: "nova" @@ -22,7 +22,7 @@ mode: "0755" - name: Prepare combined nova-console SSL and CA certs - command: cat {{ nova_console_user_ssl_cert }} {{ nova_console_user_ssl_ca_cert is defined | ternary(nova_console_user_ssl_ca_cert, '') }} + ansible.builtin.command: cat {{ nova_console_user_ssl_cert }} {{ nova_console_user_ssl_ca_cert is defined | ternary(nova_console_user_ssl_ca_cert, '') }} changed_when: false register: nova_console_user_ssl_combined tags: @@ -30,7 +30,7 @@ delegate_to: localhost - name: Drop user provided ssl cert and key - copy: + ansible.builtin.copy: src: "{{ item.src | default(omit) }}" content: "{{ item.content | default(omit) }}" dest: "{{ item.dest }}" diff --git a/tasks/consoles/nova_console_spice_install.yml b/tasks/consoles/nova_console_spice_install.yml index d4283ce9..0a3f830e 100644 --- a/tasks/consoles/nova_console_spice_install.yml +++ b/tasks/consoles/nova_console_spice_install.yml @@ -14,7 +14,7 @@ # limitations under the License. - name: Remove existing directory if it is not a git repo or it is dirty - shell: | + ansible.builtin.shell: | EXIT_CODE=0 FOLDER_PATH="/usr/share/spice-html5" if [[ -e ${FOLDER_PATH} ]]; then @@ -40,7 +40,7 @@ - nova-spice-git - name: Get package from git - git: + ansible.builtin.git: repo: "{{ nova_spicehtml5_git_repo }}" dest: "/usr/share/spice-html5" clone: "yes" diff --git a/tasks/drivers/kvm/nova_compute_kvm.yml b/tasks/drivers/kvm/nova_compute_kvm.yml index b8262e05..224b7655 100644 --- a/tasks/drivers/kvm/nova_compute_kvm.yml +++ b/tasks/drivers/kvm/nova_compute_kvm.yml @@ -14,7 +14,7 @@ # limitations under the License. - name: Including nova_compute_kvm_install tasks - include_tasks: nova_compute_kvm_install.yml + ansible.builtin.include_tasks: nova_compute_kvm_install.yml args: apply: tags: @@ -23,7 +23,7 @@ - always - name: Set nested kvm virt - copy: + ansible.builtin.copy: src: kvm.conf dest: /etc/modprobe.d/kvm.conf owner: root @@ -36,7 +36,7 @@ - nova-kvm - name: Add nova user to libvirtd group - user: + ansible.builtin.user: name: "{{ nova_system_user_name }}" groups: "{{ libvirt_group }}" append: "yes" @@ -45,14 +45,14 @@ - nova-libvirt - name: Ensure kvm permissions - command: "udevadm trigger" + ansible.builtin.command: "udevadm trigger" changed_when: false tags: - nova-config - nova-kvm - name: Set kernel permissions to enable libguestfs features (Ubuntu) - include_tasks: nova_kernel_permissions.yml + ansible.builtin.include_tasks: nova_kernel_permissions.yml when: - ansible_facts['distribution'] == 'Ubuntu' - nova_libvirt_inject_key | bool or nova_libvirt_inject_password | bool @@ -66,7 +66,7 @@ - always - name: Set libvirtd config - template: + ansible.builtin.template: src: libvirtd.conf.j2 dest: /etc/libvirt/libvirtd.conf owner: "root" @@ -79,7 +79,7 @@ - nova-libvirt - name: Set qemu config - template: + ansible.builtin.template: src: "qemu.conf.j2" dest: "/etc/libvirt/qemu.conf" owner: "root" @@ -92,7 +92,7 @@ - nova-libvirt - name: Unset libvirt runtime options (Ubuntu) - lineinfile: + ansible.builtin.lineinfile: dest: "/etc/default/libvirtd" line: 'libvirtd_opts=""' regexp: "^libvirtd_opts=" @@ -106,7 +106,7 @@ - nova-libvirt - name: Unset libvirt runtime options (RPM) - lineinfile: + ansible.builtin.lineinfile: dest: "/etc/sysconfig/libvirtd" line: 'LIBVIRTD_ARGS=""' regexp: "^(#)?LIBVIRTD_ARGS=*" @@ -121,7 +121,7 @@ - nova-libvirt - name: Set qemu-kvm KSM config (Ubuntu) - lineinfile: + ansible.builtin.lineinfile: dest: "/etc/default/qemu-kvm" line: "KSM_ENABLED={{ nova_compute_ksm_enabled | ternary('1', '0') }}" regexp: "^KSM_ENABLED=*" @@ -135,7 +135,7 @@ - nova-libvirt - name: Set apparmor config (Ubuntu/Debian) - lineinfile: + ansible.builtin.lineinfile: dest: "/etc/apparmor.d/local/usr.lib.libvirt.virt-aa-helper" line: " {{ nova_system_home_folder }}/instances/_base/* r," backup: true @@ -152,7 +152,7 @@ - nova-libvirt - name: Including nova_disable_smt tasks - include_tasks: nova_disable_smt.yml + ansible.builtin.include_tasks: nova_disable_smt.yml when: - ansible_facts['architecture'] == 'ppc64le' args: @@ -163,7 +163,7 @@ - always - name: Including nova_enable_ksm tasks - include_tasks: nova_enable_ksm.yml + ansible.builtin.include_tasks: nova_enable_ksm.yml when: - nova_compute_ksm_enabled | bool args: @@ -174,7 +174,7 @@ - always - name: Including nova_compute_kvm_virsh_net_remove tasks - include_tasks: nova_compute_kvm_virsh_net_remove.yml + ansible.builtin.include_tasks: nova_compute_kvm_virsh_net_remove.yml args: apply: tags: diff --git a/tasks/drivers/kvm/nova_compute_kvm_install.yml b/tasks/drivers/kvm/nova_compute_kvm_install.yml index 5495b8bf..a47dbc10 100644 --- a/tasks/drivers/kvm/nova_compute_kvm_install.yml +++ b/tasks/drivers/kvm/nova_compute_kvm_install.yml @@ -14,13 +14,13 @@ # limitations under the License. - name: Make sure libvirt is started - service: + ansible.builtin.service: name: "{{ item }}" state: "started" with_items: "{{ libvirt_service_name }}" - name: Check the state of the default qemu save directory - stat: + ansible.builtin.stat: path: "/var/lib/libvirt/qemu/save" until: _qemu_save_dir.stat.exists | bool retries: 5 @@ -29,7 +29,7 @@ register: _qemu_save_dir - name: Check if the qemu save directory is empty - command: "ls -1A /var/lib/libvirt/qemu/save" + ansible.builtin.command: "ls -1A /var/lib/libvirt/qemu/save" changed_when: false register: _qemu_save_dir_contents when: @@ -37,20 +37,20 @@ - _qemu_save_dir.stat.isdir | bool - name: Move the existing save directory to nova_libvirt_save_path - command: "mv /var/lib/libvirt/qemu/save {{ nova_libvirt_save_path }}" # noqa: no-changed-when + ansible.builtin.command: "mv /var/lib/libvirt/qemu/save {{ nova_libvirt_save_path }}" # noqa: no-changed-when when: - _qemu_save_dir.stat.isdir is defined - _qemu_save_dir.stat.isdir | bool - _qemu_save_dir_contents.stdout_lines | length == 0 - name: Create the new save directory - file: + ansible.builtin.file: path: "{{ nova_libvirt_save_path }}" state: directory mode: "0755" - name: Symlink qemu save dir to nova_libvirt_save_path - file: + ansible.builtin.file: src: "{{ nova_libvirt_save_path }}" dest: "/var/lib/libvirt/qemu/save" state: link diff --git a/tasks/drivers/kvm/nova_compute_kvm_virsh_net_remove.yml b/tasks/drivers/kvm/nova_compute_kvm_virsh_net_remove.yml index e49a7e1b..4057d87f 100644 --- a/tasks/drivers/kvm/nova_compute_kvm_virsh_net_remove.yml +++ b/tasks/drivers/kvm/nova_compute_kvm_virsh_net_remove.yml @@ -14,15 +14,15 @@ # limitations under the License. - name: Get information about libvirt default network - command: "virsh net-info default" + ansible.builtin.command: "virsh net-info default" changed_when: false failed_when: (default_net_info.rc != 0) and ('Network not found' not in default_net_info.stderr) register: default_net_info - name: Disable libvirt default network # noqa: no-changed-when - command: "virsh net-autostart default --disable" + ansible.builtin.command: "virsh net-autostart default --disable" when: default_net_info.stdout | regex_search('Autostart:\s+yes') - name: Destroy libvirt default network # noqa: no-changed-when - command: "virsh net-destroy default" + ansible.builtin.command: "virsh net-destroy default" when: default_net_info.stdout | regex_search('Active:\s+yes') diff --git a/tasks/drivers/kvm/nova_disable_smt.yml b/tasks/drivers/kvm/nova_disable_smt.yml index 0f8389f7..963c8b20 100644 --- a/tasks/drivers/kvm/nova_disable_smt.yml +++ b/tasks/drivers/kvm/nova_disable_smt.yml @@ -14,7 +14,7 @@ # limitations under the License. - name: Disable SMT - command: /usr/sbin/ppc64_cpu --smt=off + ansible.builtin.command: /usr/sbin/ppc64_cpu --smt=off register: smt_disable_result changed_when: false failed_when: false @@ -22,7 +22,7 @@ - kvm-disable-smt - name: Place the systemd init script - copy: + ansible.builtin.copy: src: "smt.service" dest: "/etc/systemd/system/smt.service" mode: "0644" @@ -34,7 +34,7 @@ register: smt_disable_service - name: Enable systemd service which disables smt - service: + ansible.builtin.service: name: smt enabled: true when: smt_disable_service | changed diff --git a/tasks/drivers/kvm/nova_enable_ksm.yml b/tasks/drivers/kvm/nova_enable_ksm.yml index 068d3bec..6cae7abe 100644 --- a/tasks/drivers/kvm/nova_enable_ksm.yml +++ b/tasks/drivers/kvm/nova_enable_ksm.yml @@ -1,12 +1,12 @@ --- - name: Enable ksm systemd service - service: + ansible.builtin.service: name: ksm enabled: true state: started - name: Enable ksmtuned systemd service - service: + ansible.builtin.service: name: ksmtuned enabled: true state: started diff --git a/tasks/drivers/kvm/nova_kernel_permissions.yml b/tasks/drivers/kvm/nova_kernel_permissions.yml index 2e35f0b8..c7953828 100644 --- a/tasks/drivers/kvm/nova_kernel_permissions.yml +++ b/tasks/drivers/kvm/nova_kernel_permissions.yml @@ -12,17 +12,17 @@ # limitations under the License. - name: Find installed kernels - find: + ansible.builtin.find: paths: "/boot" patterns: "vmlinuz-*" register: kernels - name: Determine latest installed kernel - set_fact: + ansible.builtin.set_fact: latest_kernel: "{{ kernels.files | map(attribute='path') | sort(reverse=True) | first }}" - name: Latest kernel readable to nova group/user - command: "dpkg-statoverride --update --add root nova 0640 {{ latest_kernel }}" + ansible.builtin.command: "dpkg-statoverride --update --add root nova 0640 {{ latest_kernel }}" register: dpkg_statoverride_result changed_when: - ("an override for '" ~ latest_kernel ~ "' already exists; aborting" not in dpkg_statoverride_result.stderr) @@ -32,7 +32,7 @@ not in dpkg_statoverride_result.stderr) - name: Script installed to make future kernels readable to nova group/user - copy: + ansible.builtin.copy: src: "nova_kernel_permissions" dest: "/etc/kernel/postinst.d/nova_kernel_permissions" mode: "0755" diff --git a/tasks/main.yml b/tasks/main.yml index 4bc13386..80aa3a32 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -14,7 +14,7 @@ # limitations under the License. - name: Gather variables for each operating system - include_vars: "{{ lookup('first_found', params) }}" + ansible.builtin.include_vars: "{{ lookup('first_found', params) }}" vars: params: files: @@ -29,7 +29,7 @@ - always - name: Fail when virt type is unsupported - fail: + ansible.builtin.fail: msg: "Unsupported Virt Type Provided {{ nova_supported_virt_types }}" when: - nova_virt_type is defined @@ -38,7 +38,7 @@ - always - name: Fail if service was deployed using a different installation method - fail: + ansible.builtin.fail: msg: "Switching installation methods for OpenStack services is not supported" when: - ansible_local is defined @@ -48,12 +48,12 @@ - ansible_local.openstack_ansible.nova.install_method != nova_install_method - name: Gather variables for installation method - include_vars: "{{ nova_install_method }}_install.yml" + ansible.builtin.include_vars: "{{ nova_install_method }}_install.yml" tags: - always - name: Including osa.db_setup role - include_role: + ansible.builtin.include_role: name: openstack.osa.db_setup apply: tags: @@ -83,7 +83,7 @@ - always - name: Including osa.mq_setup role - include_role: + ansible.builtin.include_role: name: openstack.osa.mq_setup apply: tags: @@ -109,7 +109,7 @@ - always - name: Including nova_virt_detect tasks - include_tasks: nova_virt_detect.yml + ansible.builtin.include_tasks: nova_virt_detect.yml args: apply: tags: @@ -120,22 +120,22 @@ - always - name: Importing nova_mdev_detect tasks - import_tasks: nova_mdev_detect.yml + ansible.builtin.import_tasks: nova_mdev_detect.yml tags: - always - name: Importing nova_pre_install tasks - import_tasks: nova_pre_install.yml + ansible.builtin.import_tasks: nova_pre_install.yml tags: - nova-install - name: Importing nova_install tasks - import_tasks: nova_install.yml + ansible.builtin.import_tasks: nova_install.yml tags: - nova-install - name: Refresh local facts - setup: + ansible.builtin.setup: filter: ansible_local gather_subset: "!all" tags: @@ -143,7 +143,7 @@ # Create certs after nova groups have been created but before handlers - name: Create and install SSL certificates for API and Consoles - include_role: + ansible.builtin.include_role: name: pki tasks_from: main_certs.yml apply: @@ -163,7 +163,7 @@ - always - name: Create and install SSL certificates for compute hosts - include_role: + ansible.builtin.include_role: name: pki tasks_from: main_certs.yml apply: @@ -185,13 +185,13 @@ - always - name: Including nova_post_install tasks - import_tasks: nova_post_install.yml + ansible.builtin.import_tasks: nova_post_install.yml tags: - nova-config - post-install - name: Including osa.service_setup tasks - include_role: + ansible.builtin.include_role: name: openstack.osa.service_setup apply: tags: @@ -228,7 +228,7 @@ - always - name: Including nova_db_setup tasks - include_tasks: nova_db_setup.yml + ansible.builtin.include_tasks: nova_db_setup.yml args: apply: tags: @@ -240,7 +240,7 @@ - always - name: Import uwsgi role - import_role: + ansible.builtin.import_role: name: uwsgi vars: uwsgi_services: "{{ uwsgi_nova_services }}" @@ -252,7 +252,7 @@ - uwsgi - name: Run the systemd service role - import_role: + ansible.builtin.import_role: name: systemd_service vars: systemd_user_name: "{{ nova_system_user_name }}" @@ -285,7 +285,7 @@ - systemd-service - name: Including nova_compute tasks - include_tasks: nova_compute.yml + ansible.builtin.include_tasks: nova_compute.yml args: apply: tags: @@ -297,7 +297,7 @@ - always - name: Include ceph_client role - include_role: + ansible.builtin.include_role: name: ceph_client apply: tags: @@ -313,10 +313,10 @@ - always - name: Flush handlers - meta: flush_handlers + ansible.builtin.meta: flush_handlers - name: Importing nova_compute_wait tasks - import_tasks: nova_compute_wait.yml + ansible.builtin.import_tasks: nova_compute_wait.yml when: - "nova_services['nova-compute']['group'] in group_names" - "nova_discover_hosts_in_cells_interval | int < 1" diff --git a/tasks/nova_compute.yml b/tasks/nova_compute.yml index 497d7e87..bbc89642 100644 --- a/tasks/nova_compute.yml +++ b/tasks/nova_compute.yml @@ -14,7 +14,7 @@ # limitations under the License. - name: Including nova_compute tasks for {{ nova_virt_type }} - include_tasks: "drivers/{{ nova_virt_type }}/nova_compute_{{ nova_virt_type }}.yml" + ansible.builtin.include_tasks: "drivers/{{ nova_virt_type }}/nova_compute_{{ nova_virt_type }}.yml" args: apply: tags: @@ -23,7 +23,7 @@ - always - name: Create the nova SSH config file - template: + ansible.builtin.template: src: "ssh_config.j2" dest: "{{ nova_system_home_folder }}/.ssh/config" owner: "{{ nova_system_user_name }}" @@ -33,7 +33,7 @@ - nova-key - name: Create ssh keys and config for cold migrations - include_role: + ansible.builtin.include_role: name: openstack.osa.ssh_keypairs args: apply: @@ -50,7 +50,7 @@ - always - name: Run the systemd mount role - include_role: + ansible.builtin.include_role: name: systemd_mount vars: systemd_mounts: diff --git a/tasks/nova_compute_wait.yml b/tasks/nova_compute_wait.yml index 33f308a0..48e9aa07 100644 --- a/tasks/nova_compute_wait.yml +++ b/tasks/nova_compute_wait.yml @@ -30,7 +30,7 @@ rescue: - name: Restart nova-compute service - service: + ansible.builtin.service: name: "{{ nova_services['nova-compute']['service_name'] }}" state: restarted diff --git a/tasks/nova_db_post_setup.yml b/tasks/nova_db_post_setup.yml index 22090d7e..7af14e1e 100644 --- a/tasks/nova_db_post_setup.yml +++ b/tasks/nova_db_post_setup.yml @@ -14,13 +14,13 @@ # limitations under the License. - name: Set the delegated task facts - set_fact: + ansible.builtin.set_fact: _db_nova_bin: "{{ hostvars[nova_conductor_setup_host]['nova_bin'] | default(nova_bin) }}" _db_nova_system_user_name: "{{ hostvars[nova_conductor_setup_host]['nova_system_user_name'] | default(nova_system_user_name) }}" # This needs to be done after Compute hosts are added. - name: Perform a cell_v2 discover - command: >- + ansible.builtin.command: >- {{ _db_nova_bin }}/nova-manage --config-file {{ nova_conf_version_dir }}/nova.conf cell_v2 discover_hosts{{ (debug | bool) | ternary(' --verbose', '') }}{{ (nova_ironic_used | bool) | ternary(' --by-service', '') }} become: true @@ -33,7 +33,7 @@ # intervention is required to resolve the issue causing remaining updates to fail. # It should be considered successfully completed only when the exit status is 0. - name: Perform online data migrations - command: "{{ _db_nova_bin }}/nova-manage --config-file {{ nova_conf_version_dir }}/nova.conf db online_data_migrations" + ansible.builtin.command: "{{ _db_nova_bin }}/nova-manage --config-file {{ nova_conf_version_dir }}/nova.conf db online_data_migrations" become: true become_user: "{{ _db_nova_system_user_name }}" changed_when: false @@ -46,7 +46,7 @@ - name: Disable the online migrations requirement delegate_to: "{{ item }}" - ini_file: + community.general.ini_file: dest: "/etc/ansible/facts.d/openstack_ansible.fact" section: nova option: need_online_data_migrations @@ -58,7 +58,7 @@ - data_migrations is succeeded - name: Create service and timer for archiving deleted records - include_role: + ansible.builtin.include_role: name: systemd_service vars: systemd_service_restart_changed: false diff --git a/tasks/nova_db_setup.yml b/tasks/nova_db_setup.yml index 4878bbc9..177b21af 100644 --- a/tasks/nova_db_setup.yml +++ b/tasks/nova_db_setup.yml @@ -14,7 +14,7 @@ # limitations under the License. - name: Synchronize the nova API DB schema - command: "{{ nova_bin }}/nova-manage --config-file {{ nova_conf_version_dir }}/nova.conf api_db sync" + ansible.builtin.command: "{{ nova_bin }}/nova-manage --config-file {{ nova_conf_version_dir }}/nova.conf api_db sync" become: true become_user: "{{ nova_system_user_name }}" changed_when: false @@ -22,14 +22,14 @@ # We need to check for existance of the cell, since nova-manage cell_v2 create_cell # might be not idempotent due to the bug https://bugs.launchpad.net/nova/+bug/1923899 - name: Get UUID of Nova Cells - command: "{{ nova_bin }}/nova-manage --config-file {{ nova_conf_version_dir }}/nova.conf cell_v2 list_cells" + ansible.builtin.command: "{{ nova_bin }}/nova-manage --config-file {{ nova_conf_version_dir }}/nova.conf cell_v2 list_cells" become: true become_user: "{{ nova_system_user_name }}" changed_when: false register: _cell_list - name: Set cell facts - set_fact: + ansible.builtin.set_fact: _cell0_record: '{{ _cell_list.stdout_lines | select("regex", "[0-]{36}") }}' _cell1_record: '{{ _cell_list.stdout_lines | select("regex", " " ~ nova_cell1_name ~ " ") }}' @@ -38,7 +38,7 @@ # Though since we anyway need to fetch cell records - let's run # it conditionally. - name: Create the cell0 mapping entry in the nova API DB - command: >- + ansible.builtin.command: >- {{ nova_bin }}/nova-manage --config-file {{ nova_conf_version_dir }}/nova.conf cell_v2 map_cell0 --database_connection mysql+pymysql://{{ nova_api_galera_user }}:{{ nova_api_container_mysql_password }}@{{ nova_api_galera_address }}/{{ nova_cell0_database }}?charset=utf8{% if nova_galera_use_ssl | bool %}&ssl_verify_cert=true{% @@ -50,7 +50,7 @@ - not _cell0_record - name: Update the cell0 mapping entry in the nova API DB - command: >- + ansible.builtin.command: >- {{ nova_bin }}/nova-manage --config-file {{ nova_conf_version_dir }}/nova.conf cell_v2 update_cell --cell_uuid 00000000-0000-0000-0000-000000000000 --database_connection mysql+pymysql://{{ nova_api_galera_user }}:{{ nova_api_container_mysql_password }}@{{ nova_api_galera_address }}/{{ nova_cell0_database }}?charset=utf8{% if nova_galera_use_ssl | bool %}&ssl_verify_cert=true{% @@ -66,13 +66,13 @@ ('ssl_verify_cert' in _cell0_record[0] and not nova_galera_use_ssl) - name: Synchronize the nova DB schema - command: "{{ nova_bin }}/nova-manage --config-file {{ nova_conf_version_dir }}/nova.conf db sync" + ansible.builtin.command: "{{ nova_bin }}/nova-manage --config-file {{ nova_conf_version_dir }}/nova.conf db sync" become: true become_user: "{{ nova_system_user_name }}" changed_when: false - name: Create the cell1 mapping entry in the nova API DB - command: >- + ansible.builtin.command: >- {{ nova_bin }}/nova-manage --config-file {{ nova_conf_version_dir }}/nova.conf cell_v2 create_cell --name {{ nova_cell1_name }} --database_connection {scheme}://{username}:{password}@{hostname}:{port}/{path}?{query} @@ -95,7 +95,7 @@ - not _cell1_record - name: "Change the template for cell {{ nova_cell1_name }}" - command: >- + ansible.builtin.command: >- {{ nova_bin }}/nova-manage --config-file {{ nova_conf_version_dir }}/nova.conf cell_v2 update_cell --cell_uuid {{ _cell1_record[0].split()[3] }} --database_connection {scheme}://{username}:{password}@{hostname}:{port}/{path}?{query} @@ -115,7 +115,7 @@ # mapping setup and before actual service restart. # https://docs.openstack.org/nova/latest/cli/nova-status.html - name: Run nova-status upgrade check to validate a healthy configuration - command: "{{ nova_bin }}/nova-status --config-file {{ nova_conf_version_dir }}/nova.conf upgrade check" + ansible.builtin.command: "{{ nova_bin }}/nova-status --config-file {{ nova_conf_version_dir }}/nova.conf upgrade check" become: true become_user: "{{ nova_system_user_name }}" register: nova_status_upgrade_check diff --git a/tasks/nova_install.yml b/tasks/nova_install.yml index dd0f2056..79ed3af5 100644 --- a/tasks/nova_install.yml +++ b/tasks/nova_install.yml @@ -14,7 +14,7 @@ # limitations under the License. - name: Record the installation method - ini_file: + community.general.ini_file: dest: "/etc/ansible/facts.d/openstack_ansible.fact" section: "nova" option: "install_method" @@ -22,12 +22,12 @@ mode: "0644" - name: Refresh local facts to ensure the nova section is present - setup: + ansible.builtin.setup: filter: ansible_local gather_subset: "!all" - name: Add dependency repos for RDO - package: + ansible.builtin.package: name: "{{ nova_distro_repos }}" state: "{{ nova_package_state }}" retries: 5 @@ -37,7 +37,7 @@ - nova_install_method == 'distro' - name: Install distro packages - package: + ansible.builtin.package: name: "{{ nova_package_list }}" state: "{{ nova_package_state }}" update_cache: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary('yes', omit) }}" @@ -52,7 +52,7 @@ - "Restart nova services" - name: Install the python venv - import_role: + ansible.builtin.import_role: name: "python_venv_build" vars: venv_python_executable: "{{ nova_venv_python_executable }}" @@ -76,7 +76,7 @@ when: nova_install_method == 'source' - name: Including nova_console tasks - include_tasks: "consoles/nova_console_{{ nova_console_type }}_install.yml" + ansible.builtin.include_tasks: "consoles/nova_console_{{ nova_console_type }}_install.yml" when: - "nova_services['nova-novncproxy']['group'] in group_names or nova_services['nova-spicehtml5proxy']['group'] in group_names or @@ -123,7 +123,7 @@ - skip_ansible_lint - name: Disable existing services for any unused console types - systemd: + ansible.builtin.systemd: name: "{{ item.service }}" enabled: false state: stopped @@ -143,7 +143,7 @@ when: nova_install_method == 'distro' block: - name: Record the osa version deployed - ini_file: + community.general.ini_file: dest: "/etc/ansible/facts.d/openstack_ansible.fact" section: nova option: venv_tag @@ -151,7 +151,7 @@ mode: "0644" - name: Initialise the upgrade facts - ini_file: + community.general.ini_file: dest: "/etc/ansible/facts.d/openstack_ansible.fact" section: nova option: "{{ item.name }}" diff --git a/tasks/nova_mdev_detect.yml b/tasks/nova_mdev_detect.yml index ebeb9379..2f24b41d 100644 --- a/tasks/nova_mdev_detect.yml +++ b/tasks/nova_mdev_detect.yml @@ -14,18 +14,18 @@ # limitations under the License. - name: Check if the mdev folder exist - stat: + ansible.builtin.stat: path: /sys/class/mdev_bus register: mdev_folder - name: Get mdev info content and store as var - command: "/bin/sh -c 'ls -1 /sys/class/mdev_bus/*/mdev_supported_types'" + ansible.builtin.command: "/bin/sh -c 'ls -1 /sys/class/mdev_bus/*/mdev_supported_types'" register: mdev changed_when: false when: mdev_folder.stat.exists - name: Register a fact for nova enabled_mdev_types - set_fact: + ansible.builtin.set_fact: discovered_mdev_types: "{{ mdev.stdout_lines | unique }}" when: - mdev.stdout_lines is defined diff --git a/tasks/nova_post_install.yml b/tasks/nova_post_install.yml index c963eb62..1cc79bf8 100644 --- a/tasks/nova_post_install.yml +++ b/tasks/nova_post_install.yml @@ -17,7 +17,7 @@ # dynamically loading facts from the nova_virt_types based on the # nova_virt_type setting. - name: Set nova config facts - set_fact: + ansible.builtin.set_fact: "{{ item.key }}": "{{ item.value }}" # noqa: var-naming[no-jinja] with_dict: "{{ nova_virt_types[nova_virt_type] }}" when: @@ -29,7 +29,7 @@ # NOTE(cloudnull): This task is required to copy rootwrap filters that we need # and nova does not provide by default. - name: Create aux nova dir - file: + ansible.builtin.file: path: "{{ item.path | default(omit) }}" state: "directory" owner: "{{ item.owner | default(nova_system_user_name) }}" @@ -41,7 +41,7 @@ group: "root" - name: Copy nova rootwrap filter config - copy: + ansible.builtin.copy: src: "{{ item }}" dest: "{{ nova_conf_version_dir }}/rootwrap.d/" owner: "root" @@ -114,7 +114,7 @@ - nova-provider-override - name: Remove legacy policy.yaml file - file: + ansible.builtin.file: path: "{{ nova_conf_dir }}/policy.yaml" state: absent when: @@ -127,13 +127,13 @@ # because we only want to copy the original files once. and we # don't want to need multiple tasks. - name: Preserve original configuration file(s) - command: "cp {{ item.target_f }} {{ item.target_f }}.original" + ansible.builtin.command: "cp {{ item.target_f }} {{ item.target_f }}.original" args: creates: "{{ item.target_f }}.original" with_items: "{{ nova_core_files }}" - name: Fetch override files - fetch: + ansible.builtin.fetch: src: "{{ item.target_f }}" dest: "{{ item.tmp_f }}" flat: true @@ -156,7 +156,7 @@ - Restart uwsgi services - name: Cleanup fetched temp files - file: + ansible.builtin.file: path: "{{ item.tmp_f }}" state: absent changed_when: false @@ -165,7 +165,7 @@ with_items: "{{ nova_core_files }}" - name: Remove nova-compute config - file: + ansible.builtin.file: path: /etc/nova/nova-compute.conf state: absent notify: diff --git a/tasks/nova_pre_install.yml b/tasks/nova_pre_install.yml index 08c8a4c0..698577df 100644 --- a/tasks/nova_pre_install.yml +++ b/tasks/nova_pre_install.yml @@ -14,7 +14,7 @@ # limitations under the License. - name: Create the system group - group: + ansible.builtin.group: name: "{{ nova_system_group_name }}" gid: "{{ nova_system_group_gid | default(omit) }}" state: "present" @@ -23,7 +23,7 @@ - nova-group - name: Create the nova system user - user: + ansible.builtin.user: name: "{{ nova_system_user_name }}" uid: "{{ nova_system_user_uid | default(omit) }}" group: "{{ nova_system_group_name }}" @@ -37,7 +37,7 @@ - nova-key - name: Create Nova NFS mount point(s) - file: + ansible.builtin.file: path: "{{ item.local_path }}" state: directory mode: "0755" @@ -52,12 +52,12 @@ - name: Source config block block: - name: Stat config directory - stat: + ansible.builtin.stat: path: "{{ nova_conf_dir }}" register: nova_conf_dir_stat - name: Remove the config directory - file: + ansible.builtin.file: path: "{{ nova_conf_dir }}" state: absent when: @@ -67,7 +67,7 @@ - nova_install_method == 'source' - name: Create nova dir - file: + ansible.builtin.file: path: "{{ item.path }}" state: "{{ item.state | default('directory') }}" owner: "{{ item.owner | default(nova_system_user_name) }}" @@ -98,6 +98,6 @@ - nova-dirs - name: Set default nova console for ppc64le - set_fact: + ansible.builtin.set_fact: nova_console_type: "novnc" when: ansible_facts['architecture'] == 'ppc64le' diff --git a/tasks/nova_virt_detect.yml b/tasks/nova_virt_detect.yml index 45e8c12e..86b02b47 100644 --- a/tasks/nova_virt_detect.yml +++ b/tasks/nova_virt_detect.yml @@ -14,17 +14,17 @@ # limitations under the License. - name: Get CPU info content and store as var - command: cat /proc/cpuinfo + ansible.builtin.command: cat /proc/cpuinfo register: cpuinfo_contents changed_when: false - name: Check for existence of KVM node - stat: + ansible.builtin.stat: path: "/dev/kvm" register: dev_kvm - name: Register a fact for the nova kvm virt type - set_fact: + ansible.builtin.set_fact: nova_virt_type: "kvm" when: - cpuinfo_contents.stdout.find('vmx') != -1 @@ -37,7 +37,7 @@ and ansible_facts['architecture'] == 'aarch64') - name: Register a fact for the nova qemu virt type - set_fact: + ansible.builtin.set_fact: nova_virt_type: "qemu" when: - nova_virt_type is not defined