From 4416d82c8927e61971e9bb50cfc171076633e2ab Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Tue, 11 Feb 2025 19:31: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: I7220eec2957ea2ef8acfa9dba3e443ab39251646 --- handlers/main.yml | 6 ++-- tasks/cinder_backends.yml | 12 ++++---- tasks/cinder_cleanup_old_facts.yml | 4 +-- tasks/cinder_db_post_setup.yml | 10 +++---- tasks/cinder_db_sync.yml | 2 +- tasks/cinder_install.yml | 14 +++++----- tasks/cinder_install_source.yml | 4 +-- tasks/cinder_lvm_config.yml | 6 ++-- tasks/cinder_post_install.yml | 22 +++++++-------- tasks/cinder_pre_install.yml | 10 +++---- tasks/cinder_qos.yml | 4 +-- tasks/main.yml | 45 +++++++++++++++--------------- 12 files changed, 69 insertions(+), 70 deletions(-) diff --git a/handlers/main.yml b/handlers/main.yml index d225debf..0a5b1747 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -14,7 +14,7 @@ # limitations under the License. - name: Stop services - service: + ansible.builtin.service: name: "{{ item.service_name }}" enabled: true state: stopped @@ -31,7 +31,7 @@ - "cert installed" - name: Start services - service: + ansible.builtin.service: name: "{{ item.service_name }}" enabled: true state: "started" @@ -48,7 +48,7 @@ - "cert installed" - name: Ensure tgt service restarted - service: + ansible.builtin.service: name: "{{ tgt_service_name }}" enabled: true state: restarted diff --git a/tasks/cinder_backends.yml b/tasks/cinder_backends.yml index f4882213..24d93978 100644 --- a/tasks/cinder_backends.yml +++ b/tasks/cinder_backends.yml @@ -14,7 +14,7 @@ # limitations under the License. - name: Ensure cinder api is available - uri: + ansible.builtin.uri: url: "{{ cinder_service_v3_internaluri }}" status_code: 200,300 validate_certs: "{{ not keystone_service_internaluri_insecure | bool }}" @@ -28,16 +28,16 @@ # we should do that and use the delegation to the service setup host # so that we can remove the openrc file from the target host. - name: Implement openrc/clouds.yaml - import_role: + ansible.builtin.import_role: name: "openstack_openrc" - name: Create singular cinder_backends variable for all hosts - set_fact: + ansible.builtin.set_fact: _cinder_backends: "{{ (_cinder_backends | default(cinder_backends | default({}))) | combine(hostvars[item]['cinder_backends'] | default({})) }}" with_items: "{{ groups[cinder_services['cinder-volume']['group']] }}" - name: Add in cinder devices types - shell: | + ansible.builtin.shell: | . {{ ansible_facts['env']['HOME'] }}/openrc CLI_OPTIONS="{{ ((keystone_service_adminuri_insecure | bool) or (keystone_service_internaluri_insecure | bool)) | ternary('--insecure', '') }}" if ! {{ __cinder_python_interpreter_dirname }}/openstack ${CLI_OPTIONS} volume type show "{{ item.key }}"; then @@ -54,7 +54,7 @@ changed_when: false - name: Add extra cinder volume types - shell: | + ansible.builtin.shell: | . {{ ansible_facts['env']['HOME'] }}/openrc CLI_OPTIONS="{{ ((keystone_service_adminuri_insecure | bool) or (keystone_service_internaluri_insecure | bool)) | ternary('--insecure', '') }}" {% for evtype in item.value.extra_volume_types %} @@ -74,7 +74,7 @@ when: item.value.extra_volume_types is defined - name: Importing cinder_qos tasks - import_tasks: cinder_qos.yml + ansible.builtin.import_tasks: cinder_qos.yml when: cinder_qos_specs is defined tags: - cinder-qos diff --git a/tasks/cinder_cleanup_old_facts.yml b/tasks/cinder_cleanup_old_facts.yml index 22862b54..95e7568d 100644 --- a/tasks/cinder_cleanup_old_facts.yml +++ b/tasks/cinder_cleanup_old_facts.yml @@ -17,7 +17,7 @@ # This file and the task calling it may be removed in Queens. - name: Remove the old db_sync fact - ini_file: + community.general.ini_file: dest: "/etc/ansible/facts.d/openstack_ansible.fact" section: cinder option: "need_db_sync" @@ -25,6 +25,6 @@ mode: "0644" - name: Refresh local facts - setup: + ansible.builtin.setup: filter: ansible_local gather_subset: "!all" diff --git a/tasks/cinder_db_post_setup.yml b/tasks/cinder_db_post_setup.yml index bd8e10ad..29efc2a1 100644 --- a/tasks/cinder_db_post_setup.yml +++ b/tasks/cinder_db_post_setup.yml @@ -16,7 +16,7 @@ - name: Perform data migrations if necessary and all cinder services are up block: - name: Perform online data migrations - command: "{{ cinder_bin }}/cinder-manage db online_data_migrations" + ansible.builtin.command: "{{ cinder_bin }}/cinder-manage db online_data_migrations" register: data_migrations changed_when: false retries: 5 @@ -25,18 +25,18 @@ rescue: - name: Check if all cinder services are up - shell: "{{ cinder_bin }}/cinder-manage service list | /usr/bin/awk '{ if(NR>1) print $5 }' | /bin/egrep -vq ':-)'" + ansible.builtin.shell: "{{ cinder_bin }}/cinder-manage service list | /usr/bin/awk '{ if(NR>1) print $5 }' | /bin/egrep -vq ':-)'" register: failed_cinder_services changed_when: false ignore_errors: true - name: Fail if any cinder service is down - fail: + ansible.builtin.fail: msg: At least one cinder service is down. You need to fix this before re-running the playbook. when: failed_cinder_services.rc != 1 - name: All cinder services are up, but migration failed nontheless. - fail: + ansible.builtin.fail: msg: An unexpected error occured. when: failed_cinder_services.rc == 1 @@ -47,7 +47,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: cinder option: need_online_data_migrations diff --git a/tasks/cinder_db_sync.yml b/tasks/cinder_db_sync.yml index b8a189c8..faea7903 100644 --- a/tasks/cinder_db_sync.yml +++ b/tasks/cinder_db_sync.yml @@ -14,7 +14,7 @@ # limitations under the License. - name: Perform a cinder DB sync - command: "{{ cinder_bin }}/cinder-manage db sync" + ansible.builtin.command: "{{ cinder_bin }}/cinder-manage db sync" become: true become_user: "{{ cinder_system_user_name }}" changed_when: false diff --git a/tasks/cinder_install.yml b/tasks/cinder_install.yml index db7d51b0..dc712904 100644 --- a/tasks/cinder_install.yml +++ b/tasks/cinder_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: "cinder" option: "install_method" @@ -22,12 +22,12 @@ mode: "0644" - name: Refresh local facts to ensure the cinder section is present - setup: + ansible.builtin.setup: filter: ansible_local gather_subset: "!all" - name: Install distro packages - package: + ansible.builtin.package: name: "{{ cinder_package_list }}" state: "{{ cinder_package_state }}" update_cache: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary('yes', omit) }}" @@ -40,11 +40,11 @@ - "Restart cinder services" - name: Install cinder packages from PIP - import_tasks: cinder_install_source.yml + ansible.builtin.import_tasks: cinder_install_source.yml when: cinder_install_method == 'source' - name: Run the systemd service role - import_role: + ansible.builtin.import_role: name: systemd_service vars: systemd_user_name: "{{ cinder_system_user_name }}" @@ -65,7 +65,7 @@ when: cinder_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: cinder option: venv_tag @@ -73,7 +73,7 @@ mode: "0644" - name: Set the upgrade facts - ini_file: + community.general.ini_file: dest: "/etc/ansible/facts.d/openstack_ansible.fact" section: cinder option: "{{ item }}" diff --git a/tasks/cinder_install_source.yml b/tasks/cinder_install_source.yml index fc5dade0..dc3e6087 100644 --- a/tasks/cinder_install_source.yml +++ b/tasks/cinder_install_source.yml @@ -14,7 +14,7 @@ # limitations under the License. - name: Install the python venv - import_role: + ansible.builtin.import_role: name: "python_venv_build" vars: venv_python_executable: "{{ cinder_venv_python_executable }}" @@ -35,7 +35,7 @@ value: "{{ cinder_venv_tag }}" - name: Link in the os-brick rootwrap filters - file: + ansible.builtin.file: src: "{{ cinder_bin | dirname }}/etc/os-brick/rootwrap.d/os-brick.filters" dest: /etc/cinder/rootwrap.d/os-brick.filters state: link diff --git a/tasks/cinder_lvm_config.yml b/tasks/cinder_lvm_config.yml index 07152d08..c018a712 100644 --- a/tasks/cinder_lvm_config.yml +++ b/tasks/cinder_lvm_config.yml @@ -14,21 +14,21 @@ # limitations under the License. - name: Discover lvm devices - shell: >- + ansible.builtin.shell: >- /sbin/pvdisplay | awk '/PV\ Name/ {print $3}' | sed 's/\/dev\///g' register: lvm_devices changed_when: lvm_devices.rc != 0 failed_when: false - name: Ensure "/etc/lvm" directory - file: + ansible.builtin.file: state: "directory" path: "/etc/lvm" mode: "0755" when: lvm_devices.rc == 0 - name: Drop lvm Config - template: + ansible.builtin.template: src: "lvm.conf.j2" dest: "/etc/lvm/lvm.conf" owner: "root" diff --git a/tasks/cinder_post_install.yml b/tasks/cinder_post_install.yml index 97a0f40d..f44a2cd7 100644 --- a/tasks/cinder_post_install.yml +++ b/tasks/cinder_post_install.yml @@ -16,7 +16,7 @@ # NOTE(cloudnull): This task is required to copy rootwrap filters that we need # and cinder does not provide by default. - name: Create aux cinder dir - file: + ansible.builtin.file: path: "/etc/cinder/rootwrap.d" state: "directory" owner: "root" @@ -77,7 +77,7 @@ - cinder-policy-override - name: Remove legacy policy.yaml file - file: + ansible.builtin.file: path: "/etc/cinder/policy.yaml" state: absent when: @@ -89,13 +89,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: "{{ cinder_core_files }}" - name: Fetch override files - fetch: + ansible.builtin.fetch: src: "{{ item.target_f }}.original" dest: "{{ item.tmp_f }}" flat: true @@ -119,7 +119,7 @@ - Restart uwsgi services - name: Cleanup fetched temp files - file: + ansible.builtin.file: path: "{{ item.tmp_f }}" state: absent changed_when: false @@ -129,7 +129,7 @@ # NOTE(cloudnull): This will ensure strong permissions on all rootwrap files. # NOTE(noonedeadpunk): X keeps execute permissions for rootwrap.d itself. - name: Set rootwrap.d permissions - file: + ansible.builtin.file: path: "/etc/cinder/rootwrap.d" owner: "root" group: "root" @@ -137,7 +137,7 @@ recurse: true - name: Ensure cinder tgt include - lineinfile: + ansible.builtin.lineinfile: dest: /etc/tgt/targets.conf line: "include /var/lib/cinder/volumes/*" state: present @@ -148,7 +148,7 @@ - cinder_backend_lvm_inuse | bool - name: Ensure iscsi service is started - service: + ansible.builtin.service: name: "{{ tgt_service_name }}" state: started enabled: true @@ -160,7 +160,7 @@ # NOTE(jrosser) it is necessarry to start the iscsid service to # generate an initiator uuid if one is not already present - name: Ensure iscsid service is started - service: + ansible.builtin.service: name: "iscsid" state: started enabled: true @@ -169,7 +169,7 @@ - cinder_backend_lvm_inuse | bool - name: Create nfs shares export file - template: + ansible.builtin.template: src: nfs_shares.j2 dest: "{{ item.value.nfs_shares_config }}" mode: "0644" @@ -181,7 +181,7 @@ - cinder-nfs - name: Drop sudoers file - template: + ansible.builtin.template: src: "sudoers.j2" dest: "/etc/sudoers.d/{{ cinder_system_user_name }}_sudoers" mode: "0440" diff --git a/tasks/cinder_pre_install.yml b/tasks/cinder_pre_install.yml index 7979fef5..cb311cbf 100644 --- a/tasks/cinder_pre_install.yml +++ b/tasks/cinder_pre_install.yml @@ -14,14 +14,14 @@ # limitations under the License. - name: Create the system group - group: + ansible.builtin.group: name: "{{ cinder_system_group_name }}" gid: "{{ cinder_system_group_gid | default(omit) }}" state: "present" system: "yes" - name: Create the cinder system user - user: + ansible.builtin.user: name: "{{ cinder_system_user_name }}" uid: "{{ cinder_system_user_uid | default(omit) }}" group: "{{ cinder_system_group_name }}" @@ -38,12 +38,12 @@ - name: Source config block block: - name: Stat config directory - stat: + ansible.builtin.stat: path: "/etc/cinder" register: cinder_conf_dir_stat - name: Remove the config directory - file: + ansible.builtin.file: path: "/etc/cinder" state: absent when: @@ -53,7 +53,7 @@ - cinder_install_method == 'source' - name: Create cinder dir - file: + ansible.builtin.file: path: "{{ item.path | default(omit) }}" src: "{{ item.src | default(omit) }}" dest: "{{ item.dest | default(omit) }}" diff --git a/tasks/cinder_qos.yml b/tasks/cinder_qos.yml index 4bc12cbc..b70052b4 100644 --- a/tasks/cinder_qos.yml +++ b/tasks/cinder_qos.yml @@ -14,7 +14,7 @@ # limitations under the License. - name: Add in cinder qos types - shell: | + ansible.builtin.shell: | . {{ ansible_facts['env']['HOME'] }}/openrc CLI_OPTIONS="{{ ((keystone_service_adminuri_insecure | bool) or (keystone_service_internaluri_insecure | bool)) | ternary('--insecure', '') }}" {{ __cinder_python_interpreter_dirname }}/openstack ${CLI_OPTIONS} volume qos list --format value --column Name | grep -x {{ item.name }} || \ @@ -32,7 +32,7 @@ - cinder-qos - name: Associate qos types to volume types - shell: | + ansible.builtin.shell: | . {{ ansible_facts['env']['HOME'] }}/openrc CLI_OPTIONS="{{ ((keystone_service_adminuri_insecure | bool) or (keystone_service_internaluri_insecure | bool)) | ternary('--insecure', '') }}" {% for vtype in item.cinder_volume_types %} diff --git a/tasks/main.yml b/tasks/main.yml index ce820059..7259cd5f 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 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 @@ -39,12 +39,12 @@ - ansible_local.openstack_ansible.cinder.install_method != cinder_install_method - name: Gather variables for installation method - include_vars: "{{ cinder_install_method }}_install.yml" + ansible.builtin.include_vars: "{{ cinder_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: @@ -66,7 +66,7 @@ - always - name: Including osa.mq_setup role - include_role: + ansible.builtin.include_role: name: openstack.osa.mq_setup apply: tags: @@ -92,7 +92,7 @@ - always - name: Importing cinder_lvm_config tasks - import_tasks: cinder_lvm_config.yml + ansible.builtin.import_tasks: cinder_lvm_config.yml when: - "cinder_services['cinder-volume']['group'] in group_names" - "cinder_backend_lvm_inuse | bool" @@ -100,17 +100,17 @@ - cinder-config - name: Importing cinder_pre_install tasks - import_tasks: cinder_pre_install.yml + ansible.builtin.import_tasks: cinder_pre_install.yml tags: - cinder-install - name: Importing cinder_install tasks - import_tasks: cinder_install.yml + ansible.builtin.import_tasks: cinder_install.yml tags: - cinder-install - name: Create and install SSL certificates - include_role: + ansible.builtin.include_role: name: pki tasks_from: main_certs.yml apply: @@ -130,14 +130,14 @@ - always - name: Refresh local facts - setup: + ansible.builtin.setup: filter: ansible_local gather_subset: "!all" tags: - cinder-config - name: Including cinder_cleanup_old_facts tasks - include_tasks: cinder_cleanup_old_facts.yml + ansible.builtin.include_tasks: cinder_cleanup_old_facts.yml args: apply: tags: @@ -150,13 +150,13 @@ - always - name: Importing cinder_post_install tasks - import_tasks: cinder_post_install.yml + ansible.builtin.import_tasks: cinder_post_install.yml tags: - cinder-config - post-install - name: Run the systemd service role - import_role: + ansible.builtin.import_role: name: systemd_service vars: systemd_service_enabled: "{{ ((cinder_services['cinder-volume']['group'] in group_names) and (cinder_ceilometer_enabled | bool)) | ternary(true, false) }}" @@ -181,14 +181,14 @@ - cinder-config - name: Importing cinder_db_sync tasks - import_tasks: cinder_db_sync.yml + ansible.builtin.import_tasks: cinder_db_sync.yml when: - _cinder_is_first_api_play_host tags: - cinder-config - name: Import uwsgi role - import_role: + ansible.builtin.import_role: name: uwsgi vars: uwsgi_services: "{{ uwsgi_cinder_services }}" @@ -198,7 +198,7 @@ - uwsgi - name: Including osa.service_setup role - include_role: + ansible.builtin.include_role: name: openstack.osa.service_setup apply: tags: @@ -223,7 +223,7 @@ - always - name: Import ceph_client role - import_role: + ansible.builtin.import_role: name: ceph_client vars: openstack_service_system_user: "{{ cinder_system_user_name }}" @@ -238,7 +238,7 @@ # so are installed after the ceph_client role is run to ensure that the ceph repos setup # is in place. - name: Install cinder volumes distro tool packages - package: + ansible.builtin.package: name: "{{ cinder_volume_distro_packages_tools }}" state: "{{ cinder_package_state }}" update_cache: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary('yes', omit) }}" @@ -251,17 +251,16 @@ - "cinder_services['cinder-volume']['group'] in group_names" - name: Flush handlers - meta: flush_handlers - + ansible.builtin.meta: flush_handlers - name: Importing cinder_db_post_setup tasks - import_tasks: cinder_db_post_setup.yml + ansible.builtin.import_tasks: cinder_db_post_setup.yml when: - "_cinder_is_last_play_host" tags: - cinder-config - name: Importing cinder_backends tasks - include_tasks: cinder_backends.yml + ansible.builtin.include_tasks: cinder_backends.yml args: apply: tags: @@ -274,7 +273,7 @@ - cinder-config - name: Create service and timer for archiving deleted records - include_role: + ansible.builtin.include_role: name: systemd_service vars: systemd_service_restart_changed: false