From 3fa0c33ed3a6d3d60831a27d03790afedd0878bd Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Thu, 13 Feb 2025 09:57:12 +0100 Subject: [PATCH] Auto-fix yaml rules In order to reduce divergance with ansible-lint rules, we apply auto-fixing of violations. In current patch we replace all kind of truthy variables with `true` or `false` values to align with recommendations along with alignment of used quotes. Change-Id: I2773d3465665bfe95516ca8f34fc8351b1e8c18f --- .gitignore | 1 + defaults/main.yml | 16 +++-- examples/playbook.yml | 1 + handlers/main.yml | 1 + tasks/ceph_auth.yml | 6 +- tasks/ceph_auth_extra.yml | 2 - tasks/ceph_auth_extra_compute.yml | 2 - tasks/ceph_config.yml | 8 +-- tasks/ceph_config_extra.yml | 2 - tasks/ceph_get_keyrings_from_files.yml | 2 +- tasks/ceph_get_keyrings_from_mons.yml | 4 +- tasks/ceph_get_mon_host.yml | 2 +- tasks/ceph_immutable_object_cache.yml | 1 + tasks/ceph_install.yml | 2 +- tasks/ceph_install_python_libs.yml | 2 +- tasks/ceph_preinstall_apt.yml | 2 +- tasks/main.yml | 10 +-- vars/debian.yml | 1 - vars/main.yml | 90 +++++++++++++------------- vars/redhat.yml | 14 ++-- 20 files changed, 83 insertions(+), 86 deletions(-) diff --git a/.gitignore b/.gitignore index 3a77206..c46a9ec 100644 --- a/.gitignore +++ b/.gitignore @@ -45,6 +45,7 @@ logs/* # OS generated files # ###################### ._* +.ansible .tox *.egg-info .eggs diff --git a/defaults/main.yml b/defaults/main.yml index 571c5e7..8f953d8 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -40,9 +40,11 @@ ceph_client_package_state: "{{ package_state | default('latest') }}" # package repositories. ceph_pkg_source: ceph ceph_stable_release: reef -ceph_apt_pinned_packages: [{package: "*", release: "ceph.com", priority: 1001}] - -ceph_repo_url_region: "download" # see here for other mirros http://docs.ceph.com/docs/master/install/mirrors/ +ceph_apt_pinned_packages: + - package: "*" + release: "ceph.com" + priority: 1001 +ceph_repo_url_region: "download" # see here for other mirros http://docs.ceph.com/docs/master/install/mirrors/ ceph_repo_url: https://{{ ceph_repo_url_region }}.ceph.com/{{ _ceph_repo_distro_suffix }}-{{ ceph_stable_release }} ceph_repos: "{{ _ceph_repos }}" @@ -99,14 +101,14 @@ immutable_object_cache_client: immutable-object-cache # needs to access both volumes (cinder) as boot disks (nova) we default to # reuse the cinder_ceph_client # only need to change this if you'd use ceph for boot disks and not for volumes -nova_ceph_client: '{{ cinder_ceph_client }}' +nova_ceph_client: "{{ cinder_ceph_client }}" # overruled in user_secrets: # nova_ceph_client_uuid: cephkeys_access_group: ceph -openstack_service_system_user: null +openstack_service_system_user: ceph_cinder_service_names: - cinder-volume @@ -141,7 +143,7 @@ ceph_centos_epel_key: >- {{ centos_epel_key | default('http://download.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-' ~ ansible_facts['distribution_major_version']) }} # Immutible object cache - caches a read-only base layer of rbd volumes -ceph_immutable_object_cache_enabled: False +ceph_immutable_object_cache_enabled: false ceph_immutable_object_cache_service_name: "ceph-immutable-object-cache@" ceph_immutable_object_cache_dir: "/ceph-immutable-object-cache" ceph_immutable_object_cache_socket: "/run/ceph/immutable_object_cache_sock" @@ -152,7 +154,7 @@ ceph_immutable_object_cache_mode: "0775" ceph_immutable_object_cache_key_owner: "{{ ceph_immutable_object_cache_owner }}" ceph_immutable_object_cache_key_group: "{{ ceph_immutable_object_cache_group }}" -ceph_persistent_write_log_cache_enabled: False +ceph_persistent_write_log_cache_enabled: false ceph_persistent_write_log_cache_dir: "/rbd-write-log-cache" ceph_persistent_write_log_cache_owner: "libvirt-qemu" ceph_persistent_write_log_cache_group: "ceph" diff --git a/examples/playbook.yml b/examples/playbook.yml index cf94a05..0b5fe03 100644 --- a/examples/playbook.yml +++ b/examples/playbook.yml @@ -1,3 +1,4 @@ +--- - name: Install Ceph client hosts: all user: root diff --git a/handlers/main.yml b/handlers/main.yml index 5882a65..6a0673f 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,3 +1,4 @@ +--- # Copyright 2014, Rackspace US, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/tasks/ceph_auth.yml b/tasks/ceph_auth.yml index 8b664c0..2e199ab 100644 --- a/tasks/ceph_auth.yml +++ b/tasks/ceph_auth.yml @@ -29,7 +29,7 @@ user: name: "{{ openstack_service_system_user }}" groups: "{{ cephkeys_access_group }}" - append: yes + append: true notify: - Restart os services @@ -111,7 +111,7 @@ - name: Detect correct group for extra auth set_fact: - ceph_in_extra_auth_group: True + ceph_in_extra_auth_group: true with_items: "{{ ceph_extra_auth_groups }}" when: - ceph_extra_confs is defined @@ -125,7 +125,7 @@ - name: Detect extra nova uuid secret set_fact: - ceph_extra_nova_uuid: True + ceph_extra_nova_uuid: true with_items: "{{ ceph_extra_confs | default([]) }}" when: - inventory_hostname in groups[ceph_extra_compute_group] diff --git a/tasks/ceph_auth_extra.yml b/tasks/ceph_auth_extra.yml index 7102cf0..7862a69 100644 --- a/tasks/ceph_auth_extra.yml +++ b/tasks/ceph_auth_extra.yml @@ -12,8 +12,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - - - name: Create keyring files for openstack clients from extra cluster(s) shell: >- ceph auth get client.{{ item.client_name }} --cluster {{ ceph_cluster_name }} >/dev/null && diff --git a/tasks/ceph_auth_extra_compute.yml b/tasks/ceph_auth_extra_compute.yml index 93289e5..9ffaf3b 100644 --- a/tasks/ceph_auth_extra_compute.yml +++ b/tasks/ceph_auth_extra_compute.yml @@ -12,8 +12,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - - - name: Create key files for nova_compute on extra cluster(s) shell: >- ceph auth get-key client.{{ item.client_name }} --cluster {{ ceph_cluster_name }} diff --git a/tasks/ceph_config.yml b/tasks/ceph_config.yml index 362b9fe..2daadb8 100644 --- a/tasks/ceph_config.yml +++ b/tasks/ceph_config.yml @@ -25,7 +25,7 @@ slurp: src: "/etc/ceph/{{ ceph_cluster_name }}.conf" register: ceph_conf_content_mon - delegate_to: '{{ ceph_mon_host }}' + delegate_to: "{{ ceph_mon_host }}" changed_when: false when: - ceph_conf_file is not defined @@ -44,19 +44,19 @@ - name: Create ceph.conf from mon host openstack.config_template.config_template: - content: '{{ ceph_conf }}' + content: "{{ ceph_conf }}" dest: "/etc/ceph/{{ ceph_cluster_name }}.conf" owner: root group: root mode: "0644" config_type: ini - config_overrides: '{{ ceph_client_ceph_conf_overrides }}' + config_overrides: "{{ ceph_client_ceph_conf_overrides }}" notify: - Restart os services - name: Detect correct group for extra config set_fact: - ceph_in_extra_config_group: True + ceph_in_extra_config_group: true when: - ceph_extra_confs is defined - inventory_hostname in groups[item] diff --git a/tasks/ceph_config_extra.yml b/tasks/ceph_config_extra.yml index 0edcaa9..4e4040b 100644 --- a/tasks/ceph_config_extra.yml +++ b/tasks/ceph_config_extra.yml @@ -12,8 +12,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - - - name: Get extra ceph.conf files command: "scp {{ item.mon_host }}:/etc/ceph/{{ item.cluster_name | default(ceph_cluster_name) }}.conf {{ item.src }}" changed_when: false diff --git a/tasks/ceph_get_keyrings_from_files.yml b/tasks/ceph_get_keyrings_from_files.yml index 1bc9bdc..828a0b0 100644 --- a/tasks/ceph_get_keyrings_from_files.yml +++ b/tasks/ceph_get_keyrings_from_files.yml @@ -27,7 +27,7 @@ {% endfor %} {{ _keys }} changed_when: false - delegate_facts: False + delegate_facts: false delegate_to: localhost tags: - ceph-config diff --git a/tasks/ceph_get_keyrings_from_mons.yml b/tasks/ceph_get_keyrings_from_mons.yml index 22d2cea..97b5ae6 100644 --- a/tasks/ceph_get_keyrings_from_mons.yml +++ b/tasks/ceph_get_keyrings_from_mons.yml @@ -25,7 +25,7 @@ ceph auth get-or-create client.{{ item['name'] }} --cluster {{ ceph_cluster_name }} with_items: "{{ ceph_client_filtered_clients }}" changed_when: false - delegate_to: '{{ ceph_mon_host }}' + delegate_to: "{{ ceph_mon_host }}" register: ceph_client_keyrings until: ceph_client_keyrings is success retries: 3 @@ -63,7 +63,7 @@ - inventory_hostname in groups.nova_compute - nova_ceph_client in ceph_client_filtered_clients | map(attribute='name') | list changed_when: false - delegate_to: '{{ ceph_mon_host }}' + delegate_to: "{{ ceph_mon_host }}" register: ceph_nova_secret tags: - always diff --git a/tasks/ceph_get_mon_host.yml b/tasks/ceph_get_mon_host.yml index 9adb838..cf68dd6 100644 --- a/tasks/ceph_get_mon_host.yml +++ b/tasks/ceph_get_mon_host.yml @@ -26,7 +26,7 @@ - name: Set ceph_mon_host to an online monitor host set_fact: - ceph_mon_host: '{{ item.item }}' + ceph_mon_host: "{{ item.item }}" when: - item is success # Use the first available monitor diff --git a/tasks/ceph_immutable_object_cache.yml b/tasks/ceph_immutable_object_cache.yml index 875a60b..877de89 100644 --- a/tasks/ceph_immutable_object_cache.yml +++ b/tasks/ceph_immutable_object_cache.yml @@ -1,3 +1,4 @@ +--- # Copyright 2023, BBC R&D # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/tasks/ceph_install.yml b/tasks/ceph_install.yml index 561fbd5..6d42ecc 100644 --- a/tasks/ceph_install.yml +++ b/tasks/ceph_install.yml @@ -15,7 +15,7 @@ - name: Install ceph packages package: - name: '{{ ceph_client_filtered_packages }}' + name: "{{ ceph_client_filtered_packages }}" state: "{{ ceph_client_package_state }}" update_cache: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary('yes', omit) }}" cache_valid_time: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary(cache_timeout, omit) }}" diff --git a/tasks/ceph_install_python_libs.yml b/tasks/ceph_install_python_libs.yml index 71999e6..cb60a2a 100644 --- a/tasks/ceph_install_python_libs.yml +++ b/tasks/ceph_install_python_libs.yml @@ -18,7 +18,7 @@ paths: "{{ openstack_service_venv_bin | dirname }}/lib/" patterns: "python*" file_type: directory - recurse: no + recurse: false register: python_venv_details - name: Set python venvs details diff --git a/tasks/ceph_preinstall_apt.yml b/tasks/ceph_preinstall_apt.yml index da08a89..723eda4 100644 --- a/tasks/ceph_preinstall_apt.yml +++ b/tasks/ceph_preinstall_apt.yml @@ -77,7 +77,7 @@ - name: Update Apt cache apt: - update_cache: yes + update_cache: true when: (apt_repo_removed is changed) or (deb822_repos is changed) register: update_apt_cache until: update_apt_cache is success diff --git a/tasks/main.yml b/tasks/main.yml index 8d8f6cb..205e4c1 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -113,13 +113,13 @@ - name: Write AppArmor configuration for ceph immutable object caching ansible.builtin.blockinfile: - create: True + create: true mode: "0644" path: /etc/apparmor.d/local/abstractions/libvirt-qemu marker: "### {mark} OSA CEPH_CLIENT IMMUTABLE OBJECT CACHE BLOCK ###" block: | - {{ ceph_immutable_object_cache_dir }}/** r, - {{ ceph_immutable_object_cache_socket }} rw, + {{ ceph_immutable_object_cache_dir }}/** r, + {{ ceph_immutable_object_cache_socket }} rw, state: "{{ ceph_immutable_object_cache_enabled | bool | ternary('present', 'absent') }}" when: - ansible_facts['os_family'] == "Debian" @@ -139,12 +139,12 @@ - name: Write AppArmor configuration for ceph write log caching ansible.builtin.blockinfile: - create: True + create: true mode: "0644" path: /etc/apparmor.d/local/abstractions/libvirt-qemu marker: "### {mark} OSA CEPH_CLIENT WRITE LOG CACHE BLOCK ###" block: | - {{ ceph_persistent_write_log_cache_dir }}/** rwk, + {{ ceph_persistent_write_log_cache_dir }}/** rwk, state: "{{ ceph_persistent_write_log_cache_enabled | bool | ternary('present', 'absent') }}" when: - ansible_facts['os_family'] == "Debian" diff --git a/vars/debian.yml b/vars/debian.yml index 6ae92b4..1a197e6 100644 --- a/vars/debian.yml +++ b/vars/debian.yml @@ -17,7 +17,6 @@ ## APT Cache Options cache_timeout: 600 - libvirt_packages: - libvirt-daemon-system diff --git a/vars/main.yml b/vars/main.yml index b25c761..3d2b3df 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -12,26 +12,24 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - - # http://ceph.com/docs/master/rbd/rbd-openstack/ ceph_components: - component: glance_api package: "{{ python_ceph_packages }}" client: - - name: '{{ glance_ceph_client }}' - service: '{{ ceph_glance_service_names }}' + - name: "{{ glance_ceph_client }}" + service: "{{ ceph_glance_service_names }}" - component: cinder_volume package: "{{ ['ceph-common'] + python_ceph_packages }}" client: - - name: '{{ cinder_ceph_client }}' - service: '{{ ceph_cinder_service_names }}' + - name: "{{ cinder_ceph_client }}" + service: "{{ ceph_cinder_service_names }}" - component: cinder_backup package: "{{ ['ceph-common'] + python_ceph_packages }}" client: - - name: '{{ cinder_backup_ceph_client }}' - service: '{{ ceph_cinder_service_names }}' + - name: "{{ cinder_backup_ceph_client }}" + service: "{{ ceph_cinder_service_names }}" - component: nova_compute package: "{{ (libvirt_packages + ['ceph-common'] + ceph_immutable_object_cache_packages + python_ceph_packages) | select }}" client: @@ -40,7 +38,7 @@ ceph_components: owner: "{{ ceph_immutable_object_cache_key_owner }}" group: "{{ ceph_immutable_object_cache_key_group }}" enabled: "{{ ceph_immutable_object_cache_enabled }}" - service: '{{ ceph_nova_service_names }}' + service: "{{ ceph_nova_service_names }}" - component: manila_share package: "{{ ['ceph-common'] + python_ceph_packages }}" client: @@ -63,44 +61,44 @@ ceph_extra_components: [] # service: '{{ ceph_gnocchi_service_names }}' ceph_client_filtered_packages: |- - {% set packages = [] %} - {% for comp in (ceph_components + ceph_extra_components) %} - {% if comp.component in group_names %} - {% for pkg_name in comp.package %} - {% if pkg_name not in packages %} - {% set _ = packages.append(pkg_name) %} - {% endif %} - {% endfor %} - {% endif %} - {% endfor %} - {{ packages }} + {% set packages = [] %} + {% for comp in (ceph_components + ceph_extra_components) %} + {% if comp.component in group_names %} + {% for pkg_name in comp.package %} + {% if pkg_name not in packages %} + {% set _ = packages.append(pkg_name) %} + {% endif %} + {% endfor %} + {% endif %} + {% endfor %} + {{ packages }} ceph_client_filtered_services: |- - {% set services = [] %} - {% for comp in (ceph_components + ceph_extra_components) %} - {% if comp.component in group_names and 'service' in comp %} - {% set _ = services.append(comp.service) %} - {% endif %} - {% endfor %} - {{ services }} + {% set services = [] %} + {% for comp in (ceph_components + ceph_extra_components) %} + {% if comp.component in group_names and 'service' in comp %} + {% set _ = services.append(comp.service) %} + {% endif %} + {% endfor %} + {{ services }} ceph_client_filtered_clients: |- - {% set clients = [] %} - {% for comp in (ceph_components + ceph_extra_components) %} - {% if comp.component in group_names %} - {% if ((comp.component != 'cinder_backup') or - ((cinder_service_backup_program_enabled is defined and - cinder_service_backup_program_enabled | bool) and - (cinder_service_backup_driver is defined and - 'ceph' in cinder_service_backup_driver))) %} - {% for client in comp.client %} - {% if client is not mapping %} - {% set _ = clients.append({'name': client}) %} - {% elif client['enabled'] | default(true) | bool %} - {% set _ = clients.append(client) %} - {% endif %} - {% endfor %} - {% endif %} - {% endif %} - {% endfor %} - {{ clients }} + {% set clients = [] %} + {% for comp in (ceph_components + ceph_extra_components) %} + {% if comp.component in group_names %} + {% if ((comp.component != 'cinder_backup') or + ((cinder_service_backup_program_enabled is defined and + cinder_service_backup_program_enabled | bool) and + (cinder_service_backup_driver is defined and + 'ceph' in cinder_service_backup_driver))) %} + {% for client in comp.client %} + {% if client is not mapping %} + {% set _ = clients.append({'name': client}) %} + {% elif client['enabled'] | default(true) | bool %} + {% set _ = clients.append(client) %} + {% endif %} + {% endfor %} + {% endif %} + {% endif %} + {% endfor %} + {{ clients }} diff --git a/vars/redhat.yml b/vars/redhat.yml index c07efd8..c4b2fce 100644 --- a/vars/redhat.yml +++ b/vars/redhat.yml @@ -39,9 +39,9 @@ _ceph_repos: - name: ceph-client-deps baseurl: "{{ ceph_centos_epel_mirror ~ '/' ~ ansible_facts['distribution_major_version'] ~ '/Everything/' ~ ansible_facts['architecture'] }}" description: "Extra Packages for Enterprise Linux {{ ansible_facts['distribution_major_version'] }} - $basearch" - gpgcheck: yes + gpgcheck: true gpgkey: "file:///etc/pki/rpm-gpg/{{ ceph_centos_epel_key.split('/')[-1] }}" - enabled: yes + enabled: true state: "{{ (ceph_pkg_source == 'ceph') | ternary('present', 'absent') }}" includepkgs: - fmt @@ -50,7 +50,7 @@ _ceph_repos: - libarrow-doc - libbabeltrace - liboath - - 'lttng-ust*' + - "lttng-ust*" - parquet-libs - re2 - thrift @@ -59,16 +59,16 @@ _ceph_repos: description: "Ceph packages for $basearch" file: ceph baseurl: "{{ ceph_repo_url }}/el$releasever/$basearch" - gpgcheck: yes - enabled: yes + gpgcheck: true + enabled: true priority: 50 state: "{{ (ceph_pkg_source == 'ceph') | ternary('present', 'absent') }}" - name: ceph-noarch description: "Ceph noarch packages" file: ceph baseurl: "{{ ceph_repo_url }}/el$releasever/noarch" - gpgcheck: yes - enabled: yes + gpgcheck: true + enabled: true priority: 50 state: "{{ (ceph_pkg_source == 'ceph') | ternary('present', 'absent') }}"