ansible-lint: Fix key-order[task]

Change-Id: I92c53b1c3f2695430e8f66b4add2ab7c070c7895
Signed-off-by: Michal Nasiadka <mnasiadka@gmail.com>
This commit is contained in:
Michal Nasiadka
2025-11-21 08:18:32 -05:00
parent 02f8f9424a
commit 3d665fdb9d
11 changed files with 34 additions and 37 deletions

View File

@@ -9,8 +9,6 @@ skip_list:
# Galaxy changelog and runtime defined # Galaxy changelog and runtime defined
- galaxy[no-changelog] - galaxy[no-changelog]
- galaxy[no-runtime] - galaxy[no-runtime]
# don't fail on when at the end of block
- key-order[task]
# All tasks should be named # All tasks should be named
- name[missing] - name[missing]
# Variables names from within roles should use role_name_ as a prefix # Variables names from within roles should use role_name_ as a prefix

3
.gitignore vendored
View File

@@ -36,6 +36,9 @@ cover/
# Files created by reno build # Files created by reno build
releasenotes/build releasenotes/build
# Files generated by ansible galaxy installs
.ansible/
# Others # Others
.DS_Store .DS_Store
.vimrc .vimrc

View File

@@ -1,5 +1,7 @@
--- ---
- name: Install ceph-common - name: Install ceph-common
become: true
when: ansible_facts.os_family == 'Debian'
block: block:
- block: - block:
- name: Ensure apt sources list directory exists - name: Ensure apt sources list directory exists
@@ -47,10 +49,9 @@
state: present state: present
update_cache: true update_cache: true
when: ansible_facts.os_family == 'Debian' - become: true
become: true when: ansible_facts.os_family == 'RedHat'
block:
- block:
- name: Enable ceph yum repository - name: Enable ceph yum repository
yum_repository: yum_repository:
name: ceph name: ceph
@@ -76,6 +77,3 @@
name: "{{ ceph_yum_package }}" name: "{{ ceph_yum_package }}"
state: present state: present
enablerepo: epel enablerepo: epel
when: ansible_facts.os_family == 'RedHat'
become: true

View File

@@ -1,6 +1,7 @@
--- ---
# TODO(inc0): Gates don't seem to have ufw executable, check for it instead of ignore errors # TODO(inc0): Gates don't seem to have ufw executable, check for it instead of ignore errors
- block: - when: disable_firewall | bool
block:
- name: Set firewall default policy - name: Set firewall default policy
# noqa ignore-errors # noqa ignore-errors
become: true become: true
@@ -29,7 +30,6 @@
when: when:
- ansible_facts.os_family == 'RedHat' - ansible_facts.os_family == 'RedHat'
- firewalld_check.rc == 0 - firewalld_check.rc == 0
when: disable_firewall | bool
- import_role: - import_role:
name: openstack.kolla.packages name: openstack.kolla.packages

View File

@@ -15,7 +15,8 @@
# APT starts Docker engine right after installation, which creates # APT starts Docker engine right after installation, which creates
# iptables rules before we disable iptables in Docker config # iptables rules before we disable iptables in Docker config
- block: - when: ansible_facts.os_family == 'Debian'
block:
- name: Check if docker systemd unit exists - name: Check if docker systemd unit exists
stat: stat:
path: /etc/systemd/system/docker.service path: /etc/systemd/system/docker.service
@@ -30,7 +31,6 @@
state: link state: link
become: true become: true
when: not docker_unit_file.stat.exists when: not docker_unit_file.stat.exists
when: ansible_facts.os_family == 'Debian'
- name: Install packages - name: Install packages
package: package:
@@ -44,7 +44,11 @@
# If any packages were updated, and any containers were running, wait for the # If any packages were updated, and any containers were running, wait for the
# daemon to come up and start all previously running containers. # daemon to come up and start all previously running containers.
- block: - when:
- docker_install_result is changed
- running_containers.rc == 0
- running_containers.stdout != ''
block:
# At some point (at least on CentOS 7) Docker CE stopped starting # At some point (at least on CentOS 7) Docker CE stopped starting
# automatically after an upgrade from legacy docker . Start it manually. # automatically after an upgrade from legacy docker . Start it manually.
- name: Start docker - name: Start docker
@@ -69,10 +73,6 @@
command: "docker start {{ running_containers.stdout }}" command: "docker start {{ running_containers.stdout }}"
become: true become: true
changed_when: true changed_when: true
when:
- docker_install_result is changed
- running_containers.rc == 0
- running_containers.stdout != ''
- import_tasks: config.yml - import_tasks: config.yml

View File

@@ -1,5 +1,9 @@
--- ---
- name: Configure osbpo apt repository - name: Configure osbpo apt repository
when:
- ansible_facts.distribution == 'Debian'
- docker_sdk_python_externally_managed | default(false)
- virtualenv is none
block: block:
- name: Ensure apt sources list directory exists - name: Ensure apt sources list directory exists
file: file:
@@ -27,10 +31,6 @@
repo: "{{ docker_sdk_osbpo_apt_repo }}" repo: "{{ docker_sdk_osbpo_apt_repo }}"
filename: osbpo filename: osbpo
become: true become: true
when:
- ansible_facts.distribution == 'Debian'
- docker_sdk_python_externally_managed | default(false)
- virtualenv is none
- name: Install packages - name: Install packages
package: package:

View File

@@ -1,5 +1,6 @@
--- ---
- name: Handling for Python3.10+ externally managed environments - name: Handling for Python3.10+ externally managed environments
when: ansible_facts.python.version.major == 3 and ansible_facts.python.version.minor >= 10
block: block:
- name: Get Python - name: Get Python
ansible.builtin.command: ansible.builtin.command:
@@ -17,6 +18,4 @@
docker_sdk_python_externally_managed: true docker_sdk_python_externally_managed: true
when: python_externally_managed.stat.exists when: python_externally_managed.stat.exists
when: ansible_facts.python.version.major == 3 and ansible_facts.python.version.minor >= 10
- include_tasks: "{{ package_action }}.yml" - include_tasks: "{{ package_action }}.yml"

View File

@@ -54,6 +54,7 @@
# every boot, which will break RabbitMQ. To prevent this happens, first we check whether cloud-init # every boot, which will break RabbitMQ. To prevent this happens, first we check whether cloud-init
# has been installed, and then set manage_etc_hosts to false. # has been installed, and then set manage_etc_hosts to false.
- name: Check whether cloud-init has been installed, and ensure manage_etc_hosts is disabled - name: Check whether cloud-init has been installed, and ensure manage_etc_hosts is disabled
become: true
block: block:
- name: Check whether /etc/cloud/cloud.cfg exists - name: Check whether /etc/cloud/cloud.cfg exists
stat: stat:
@@ -66,4 +67,3 @@
dest: /etc/cloud/cloud.cfg.d/99-kolla.cfg dest: /etc/cloud/cloud.cfg.d/99-kolla.cfg
mode: "0660" mode: "0660"
when: cloud_init.stat.exists when: cloud_init.stat.exists
become: true

View File

@@ -28,7 +28,11 @@
state: started state: started
enabled: true enabled: true
- block: - when:
- podman_install_result.changed
- running_containers.rc == 0
- running_containers.stdout != ''
block:
- name: Wait for Podman to start - name: Wait for Podman to start
command: podman info command: podman info
become: true become: true
@@ -42,9 +46,5 @@
command: "podman start {{ running_containers.stdout }}" command: "podman start {{ running_containers.stdout }}"
become: true become: true
changed_when: true changed_when: true
when:
- podman_install_result.changed
- running_containers.rc == 0
- running_containers.stdout != ''
- import_tasks: config.yml - import_tasks: config.yml

View File

@@ -1,5 +1,10 @@
--- ---
- name: Configure osbpo apt repository - name: Configure osbpo apt repository
become: true
when:
- ansible_facts.distribution == 'Debian'
- podman_sdk_python_externally_managed | default(false)
- virtualenv is none
block: block:
- name: Ensure apt sources list directory exists - name: Ensure apt sources list directory exists
file: file:
@@ -42,11 +47,6 @@
- name: Update the apt cache - name: Update the apt cache
apt: apt:
update_cache: true update_cache: true
when:
- ansible_facts.distribution == 'Debian'
- podman_sdk_python_externally_managed | default(false)
- virtualenv is none
become: true
- name: Install packages - name: Install packages
package: package:

View File

@@ -1,5 +1,6 @@
--- ---
- name: Handling for Python3.10+ externally managed environments - name: Handling for Python3.10+ externally managed environments
when: ansible_facts.python.version.major == 3 and ansible_facts.python.version.minor >= 10
block: block:
- name: Get Python - name: Get Python
ansible.builtin.command: ansible.builtin.command:
@@ -17,6 +18,4 @@
podman_sdk_python_externally_managed: true podman_sdk_python_externally_managed: true
when: python_externally_managed.stat.exists when: python_externally_managed.stat.exists
when: ansible_facts.python.version.major == 3 and ansible_facts.python.version.minor >= 10
- include_tasks: "{{ package_action }}.yml" - include_tasks: "{{ package_action }}.yml"