Run latest ansible-lint on Ubuntu Noble

We bump the Ansible version to the version that Zuul runs. We then set
ansible-lint to the current latest version. This results in a number of
new linter violations which we fix. These violations include:

 * Needing to name plays
 * Needing to start names with a capital letter
 * Using fully qualified names for action modules
 * Quoting permissions strings to avoid octal conversion errors
 * Using explicit yaml structures for tasks

We also tell ansible-lint to mock zuul_return so that we don't get
errors from it complaining that this module is not defined.

Change-Id: Ic881313fea58f4482f70e493f3d256541d31860a
This commit is contained in:
Clark Boylan 2024-08-22 16:04:27 -07:00
parent 7ae2bbabbe
commit 60acea0da6
43 changed files with 111 additions and 76 deletions

View File

@ -18,6 +18,8 @@ skip_list:
- yaml[truthy] # "yes" is ok - yaml[truthy] # "yes" is ok
use_default_rules: true use_default_rules: true
verbosity: 1 verbosity: 1
mock_modules:
- zuul_return
# Local variables: # Local variables:
# mode: yaml # mode: yaml

View File

@ -1,5 +1,5 @@
- hosts: all - name: Set up SSH login
name: Set up SSH login hosts: all
tasks: tasks:
- name: Allow ssh login into localhost - name: Allow ssh login into localhost

View File

@ -1,3 +1,4 @@
- hosts: all - name: Fetch Sphinx Output
hosts: all
roles: roles:
- fetch-sphinx-output - fetch-sphinx-output

View File

@ -1,7 +1,7 @@
- name: playbook to enable fips - name: Playbook to enable fips
hosts: all hosts: all
tasks: tasks:
- name: enable fips - name: Enable fips
include_role: include_role:
name: enable-fips name: enable-fips
when: enable_fips | default(false) when: enable_fips | default(false)

View File

@ -1,3 +1,4 @@
- hosts: all - name: Revoke Sudo
hosts: all
roles: roles:
- revoke-sudo - revoke-sudo

View File

@ -1,4 +1,5 @@
- hosts: all - name: Run Golang Tests
hosts: all
tasks: tasks:
- name: Run golang tests - name: Run golang tests

View File

@ -2,7 +2,7 @@
hosts: all hosts: all
tasks: tasks:
- name: install docker - name: Install docker
include_role: include_role:
name: ensure-docker name: ensure-docker
@ -13,16 +13,16 @@
- name: Make environment vars - name: Make environment vars
set_fact: set_fact:
SECRETS_DIR: '{{ ansible_user_dir }}/grafana-secrets' SECRETS_DIR: '{{ ansible_user_dir }}/grafana-secrets' # noqa: var-naming[pattern]
GRAFYAML_DIR: "{{ ansible_user_dir }}/{{ zuul.projects['opendev.org/openstack/project-config'].src_dir }}/grafana" GRAFYAML_DIR: "{{ ansible_user_dir }}/{{ zuul.projects['opendev.org/openstack/project-config'].src_dir }}/grafana" # noqa: var-naming[pattern]
SCREENSHOTS: '{{ ansible_user_dir }}/screenshots' SCREENSHOTS: '{{ ansible_user_dir }}/screenshots' # noqa: var-naming[pattern]
# NOTE(ianw) : screenshots are 1920 x this height. This means # NOTE(ianw) : screenshots are 1920 x this height. This means
# it is about the right width to see easily. 5000 is a # it is about the right width to see easily. 5000 is a
# generic compromise; a bit long for some graphs, but it's # generic compromise; a bit long for some graphs, but it's
# just a solid black that compresses well in the .pngs. If # just a solid black that compresses well in the .pngs. If
# required we can key each graph to individual heights with a # required we can key each graph to individual heights with a
# config file or something some other time. # config file or something some other time.
SCREENSHOT_HEIGHT: '5000' SCREENSHOT_HEIGHT: '5000' # noqa: var-naming[pattern]
# Initial sanity check # Initial sanity check
- name: Explicitly validate dashboards - name: Explicitly validate dashboards
@ -33,7 +33,7 @@
--entrypoint /usr/local/bin/grafana-dashboard \ --entrypoint /usr/local/bin/grafana-dashboard \
docker.io/opendevorg/grafyaml --debug validate /grafana docker.io/opendevorg/grafyaml --debug validate /grafana
- name: install pip - name: Install pip
include_role: include_role:
name: ensure-pip name: ensure-pip
@ -57,7 +57,7 @@
- name: Run grafana - name: Run grafana
become: true become: true
docker_container: community.docker.docker_container:
name: grafana-opendev_test name: grafana-opendev_test
image: "docker.io/grafana/grafana-oss" image: "docker.io/grafana/grafana-oss"
state: started state: started
@ -73,7 +73,7 @@
- name: Run selenium - name: Run selenium
become: true become: true
docker_container: community.docker.docker_container:
name: selenium-firefox name: selenium-firefox
state: started state: started
image: "docker.io/selenium/standalone-firefox" image: "docker.io/selenium/standalone-firefox"
@ -127,7 +127,7 @@
loop: "{{ _dashboards.json | map(attribute='url') | list }}" loop: "{{ _dashboards.json | map(attribute='url') | list }}"
- name: Copy output - name: Copy output
synchronize: ansible.posix.synchronize:
src: '{{ SCREENSHOTS }}' src: '{{ SCREENSHOTS }}'
dest: '{{ zuul.executor.log_root }}' dest: '{{ zuul.executor.log_root }}'
mode: pull mode: pull

View File

@ -1,3 +1,4 @@
- hosts: all - name: Collect Container Logs
hosts: all
roles: roles:
- collect-container-logs - collect-container-logs

View File

@ -1,4 +1,5 @@
- hosts: all - name: Fetch JavaScript Tarball
hosts: all
roles: roles:
- version-from-git - version-from-git
- fetch-javascript-tarball - fetch-javascript-tarball

View File

@ -1,3 +1,4 @@
- hosts: all - name: Fetch JavaScript Output
hosts: all
roles: roles:
- fetch-javascript-output - fetch-javascript-output

View File

@ -1,4 +1,5 @@
- hosts: all - name: Prepare JavaScript Dev Environment
hosts: all
roles: roles:
- role: bindep - role: bindep
bindep_profile: test bindep_profile: test

View File

@ -1,4 +1,5 @@
- hosts: all - name: Run npm pack
hosts: all
roles: roles:
- role: npm - role: npm
npm_command: pack npm_command: pack

View File

@ -1,4 +1,5 @@
- hosts: all - name: Push Deb to Infra PPA
hosts: all
roles: roles:
- role: infra-deb-ppa-push - role: infra-deb-ppa-push
vars: vars:

View File

@ -1,4 +1,5 @@
- hosts: all - name: Build Infra Deb Package
hosts: all
roles: roles:
- role: infra-deb-package-build - role: infra-deb-package-build
vars: vars:

View File

@ -1,4 +1,5 @@
- hosts: localhost - name: Process AFS RPM Packages
hosts: localhost
tasks: tasks:
- name: Ensure artifacts directories exist - name: Ensure artifacts directories exist
file: file:

View File

@ -1,3 +1,4 @@
- hosts: all - name: Build AFS RPM Package
hosts: all
roles: roles:
- openafs-rpm-package-build - openafs-rpm-package-build

View File

@ -1,4 +1,5 @@
- hosts: all - name: Fetch Puppet Module Output
hosts: all
roles: roles:
- fetch-puppet-module-output - fetch-puppet-module-output

View File

@ -1,4 +1,5 @@
- hosts: all - name: Prepare Puppet Module Build Environment
hosts: all
roles: roles:
- ensure-pdk-dependencies - ensure-pdk-dependencies
- revoke-sudo - revoke-sudo

View File

@ -1,3 +1,4 @@
- hosts: all - name: Build Puppet Module
hosts: all
roles: roles:
- build-puppet-module - build-puppet-module

View File

@ -1,4 +1,5 @@
- hosts: all - name: Send Release Announcement
hosts: all
tasks: tasks:
- name: Send release announcement - name: Send release announcement
command: > command: >

View File

@ -1,4 +1,5 @@
- hosts: all - name: Prepare Release Announcement Environment
hosts: all
roles: roles:
- role: bindep - role: bindep
bindep_profile: test bindep_profile: test

View File

@ -1,4 +1,5 @@
- hosts: all - name: Prepare PDF Build Environment
hosts: all
roles: roles:
- role: prepare-build-pdf-docs - role: prepare-build-pdf-docs
when: not tox_skip_pdf when: not tox_skip_pdf

View File

@ -1,4 +1,5 @@
- hosts: all - name: Build PDF Docs
hosts: all
roles: roles:
- revoke-sudo - revoke-sudo
- tox - tox

View File

@ -1,4 +1,5 @@
- hosts: all - name: Return Molecule Report As Zuul Artifact
hosts: all
tasks: tasks:
- name: Return artifact to Zuul - name: Return artifact to Zuul
zuul_return: zuul_return:

View File

@ -1,3 +1,4 @@
- hosts: all - name: Run Tox With Sudo Enabled
hosts: all
roles: roles:
- tox - tox

View File

@ -8,7 +8,8 @@
# #
# [1] https://review.opendev.org/c/openstack/project-config/+/872476 # [1] https://review.opendev.org/c/openstack/project-config/+/872476
- hosts: all - name: Install Python2 Dependencies
hosts: all
become: true become: true
tasks: tasks:
- name: Install Python 2.7 - name: Install Python 2.7

View File

@ -1,4 +1,5 @@
- hosts: all - name: Push Deb to Infra PPA
hosts: all
roles: roles:
- role: infra-deb-ppa-push - role: infra-deb-ppa-push
vars: vars:

View File

@ -1,4 +1,5 @@
- hosts: all - name: Build Infra Deb Package
hosts: all
roles: roles:
- role: infra-deb-package-build - role: infra-deb-package-build
vars: vars:

View File

@ -1,5 +1,6 @@
- hosts: all - name: Build Wheel Cache
strategy: free hosts: all
strategy: free # noqa: run-once[play]
pre_tasks: pre_tasks:
- name: Set fact for wheel dir - name: Set fact for wheel dir

View File

@ -1,4 +1,5 @@
- hosts: all - name: Collect Wheel Cache Build Logs
hosts: all
tasks: tasks:
- name: Ensure build logs directory exists - name: Ensure build logs directory exists
file: file:
@ -7,7 +8,7 @@
delegate_to: localhost delegate_to: localhost
- name: Compress build logs - name: Compress build logs
archive: community.general.archive:
dest: '~/logs/build-logs.tar.bz2' dest: '~/logs/build-logs.tar.bz2'
path: '~/logs/build' path: '~/logs/build'
format: bz2 format: bz2
@ -18,7 +19,7 @@
path: '~/logs/build' path: '~/logs/build'
- name: Collect final logs - name: Collect final logs
synchronize: ansible.posix.synchronize:
dest: "{{ zuul.executor.log_root }}/{{ wheel_python }}" dest: "{{ zuul.executor.log_root }}/{{ wheel_python }}"
mode: pull mode: pull
src: ~/logs/ src: ~/logs/

View File

@ -1,4 +1,5 @@
- hosts: all - name: Setup Wheel Cache Build Environment
hosts: all
roles: roles:
- bindep - bindep

View File

@ -1,4 +1,5 @@
- hosts: all - name: Check Xstatic Library Version
hosts: all
tasks: tasks:
- name: Copy version check script - name: Copy version check script
copy: copy:

View File

@ -14,7 +14,7 @@
- name: Ensure ephemeral device is unmounted - name: Ensure ephemeral device is unmounted
become: yes become: yes
mount: ansible.posix.mount:
name: "{{ ephemeral_device }}" name: "{{ ephemeral_device }}"
state: "{{ item }}" state: "{{ item }}"
with_items: with_items:
@ -24,14 +24,14 @@
- name: Get existing partitions - name: Get existing partitions
become: yes become: yes
parted: community.general.parted:
device: "{{ ephemeral_device }}" device: "{{ ephemeral_device }}"
unit: MiB unit: MiB
register: ephemeral_partitions register: ephemeral_partitions
- name: Remove any existing partitions - name: Remove any existing partitions
become: yes become: yes
parted: community.general.parted:
device: "{{ ephemeral_device }}" device: "{{ ephemeral_device }}"
number: "{{ item.num }}" number: "{{ item.num }}"
state: absent state: absent
@ -40,13 +40,13 @@
- name: Create new disk label - name: Create new disk label
become: yes become: yes
parted: community.general.parted:
label: msdos label: msdos
device: "{{ ephemeral_device }}" device: "{{ ephemeral_device }}"
- name: Create swap partition - name: Create swap partition
become: yes become: yes
parted: community.general.parted:
device: "{{ ephemeral_device }}" device: "{{ ephemeral_device }}"
number: 1 number: 1
state: present state: present
@ -55,7 +55,7 @@
- name: Create opt partition - name: Create opt partition
become: yes become: yes
parted: community.general.parted:
device: "{{ ephemeral_device }}" device: "{{ ephemeral_device }}"
number: 2 number: 2
state: present state: present
@ -68,7 +68,7 @@
- name: Write swap to fstab - name: Write swap to fstab
become: yes become: yes
mount: ansible.posix.mount:
path: none path: none
src: "{{ swap_partition }}" src: "{{ swap_partition }}"
fstype: swap fstype: swap
@ -86,7 +86,7 @@
- name: Create /opt filesystem - name: Create /opt filesystem
become: yes become: yes
filesystem: community.general.filesystem:
fstype: ext4 fstype: ext4
# The default ratio is 16384 bytes per inode or so. Reduce that to 8192 # The default ratio is 16384 bytes per inode or so. Reduce that to 8192
# bytes per inode so that we get roughly twice the number of inodes as # bytes per inode so that we get roughly twice the number of inodes as
@ -123,7 +123,7 @@
# This overmounts any existing /opt # This overmounts any existing /opt
- name: Add opt to fstab and mount - name: Add opt to fstab and mount
become: yes become: yes
mount: ansible.posix.mount:
path: /opt path: /opt
src: "{{ opt_partition }}" src: "{{ opt_partition }}"
fstype: ext4 fstype: ext4

View File

@ -30,7 +30,8 @@
# If we have ephemeral storage and we don't appear to have setup swap, # If we have ephemeral storage and we don't appear to have setup swap,
# we will create a swap and move /opt to a large data partition there. # we will create a swap and move /opt to a large data partition there.
- include_tasks: ephemeral.yaml - name: Setup swap on ephemeral storage
include_tasks: ephemeral.yaml
when: when:
- ephemeral_device is defined - ephemeral_device is defined
- ansible_memory_mb['swap']['total'] | int + 10 <= configure_swap_size - ansible_memory_mb['swap']['total'] | int + 10 <= configure_swap_size
@ -38,7 +39,8 @@
# If no ephemeral device and no swap, then we will setup some swap # If no ephemeral device and no swap, then we will setup some swap
# space on the root device to ensure all hosts a consistent memory # space on the root device to ensure all hosts a consistent memory
# environment. # environment.
- include_tasks: root.yaml - name: Setup swap file on root device
include_tasks: root.yaml
when: when:
- ephemeral_device is undefined - ephemeral_device is undefined
- ansible_memory_mb['swap']['total'] | int + 10 <= configure_swap_size - ansible_memory_mb['swap']['total'] | int + 10 <= configure_swap_size
@ -55,10 +57,11 @@
# cloud I/O based swap during our runs if we can help it # cloud I/O based swap during our runs if we can help it
- name: Set swappiness - name: Set swappiness
become: yes become: yes
sysctl: ansible.posix.sysctl:
name: vm.swappiness name: vm.swappiness
value: 30 value: 30
state: present state: present
- name: Debug the ephemeral_device variable - name: Debug the ephemeral_device variable
debug: var=ephemeral_device debug:
var: ephemeral_device

View File

@ -17,7 +17,8 @@
root_filesystem: "{{ root_fs.stdout }}" root_filesystem: "{{ root_fs.stdout }}"
- name: Debug the root_filesystem variable - name: Debug the root_filesystem variable
debug: var=root_filesystem debug:
var: root_filesystem
# Note, we don't use a sparse device to avoid wedging when disk space # Note, we don't use a sparse device to avoid wedging when disk space
# and memory are both unavailable. # and memory are both unavailable.
@ -34,7 +35,7 @@
path: /root/swapfile path: /root/swapfile
owner: root owner: root
group: root group: root
mode: 0600 mode: '0600'
- name: Make swapfile - name: Make swapfile
become: yes become: yes
@ -42,7 +43,7 @@
- name: Write swap to fstab - name: Write swap to fstab
become: yes become: yes
mount: ansible.posix.mount:
path: none path: none
src: /root/swapfile src: /root/swapfile
fstype: swap fstype: swap
@ -56,4 +57,5 @@
command: swapon -a command: swapon -a
- name: Debug the swap_required variable - name: Debug the swap_required variable
debug: var=swap_required debug:
var: swap_required

View File

@ -62,7 +62,7 @@
tar czf {{ infra_deb_project }}-debs.tar.gz ./{{ infra_deb_project }} tar czf {{ infra_deb_project }}-debs.tar.gz ./{{ infra_deb_project }}
- name: Copy built packages - name: Copy built packages
synchronize: ansible.posix.synchronize:
src: '{{ ansible_user_dir }}/{{ infra_deb_project }}-debs.tar.gz' src: '{{ ansible_user_dir }}/{{ infra_deb_project }}-debs.tar.gz'
dest: '{{ zuul.executor.log_root }}' dest: '{{ zuul.executor.log_root }}'
mode: pull mode: pull

View File

@ -8,7 +8,7 @@
copy: copy:
dest: '/usr/local/jenkins/slave_scripts/' dest: '/usr/local/jenkins/slave_scripts/'
src: '{{ item }}' src: '{{ item }}'
mode: 0755 mode: '0755'
with_items: with_items:
- install-distro-packages.sh - install-distro-packages.sh
- jenkinsci-upload.sh - jenkinsci-upload.sh

View File

@ -75,7 +75,7 @@
tar cvzf openafs-rpms.tar.gz RPMS tar cvzf openafs-rpms.tar.gz RPMS
- name: Copy built rpms - name: Copy built rpms
synchronize: ansible.posix.synchronize:
src: '{{ ansible_user_dir }}/rpmbuild/' src: '{{ ansible_user_dir }}/rpmbuild/'
dest: '{{ zuul.executor.log_root }}' dest: '{{ zuul.executor.log_root }}'
mode: pull mode: pull

View File

@ -63,7 +63,7 @@
- name: Ensure zanata-cli perms - name: Ensure zanata-cli perms
file: file:
path: "/opt/zanata/zanata-cli-{{ zanata_client_version }}/bin/zanata-cli" path: "/opt/zanata/zanata-cli-{{ zanata_client_version }}/bin/zanata-cli"
mode: 0755 mode: '0755'
- name: Link zanata-cli - name: Link zanata-cli
file: file:
@ -74,7 +74,7 @@
# This is a preview module in Ansible 2.3. It may not work. # This is a preview module in Ansible 2.3. It may not work.
- name: Import cert to java keystore - name: Import cert to java keystore
java_cert: community.general.java_cert:
cert_url: "{{ zanata_api_credentials.fqdn }}" cert_url: "{{ zanata_api_credentials.fqdn }}"
keystore_path: /etc/ssl/certs/java/cacerts keystore_path: /etc/ssl/certs/java/cacerts
keystore_pass: changeit keystore_pass: changeit
@ -85,7 +85,7 @@
- name: Set permissions for cacert - name: Set permissions for cacert
file: file:
path: /etc/ssl/certs/java/cacerts path: /etc/ssl/certs/java/cacerts
mode: 0644 mode: '0644'
become: true become: true
- name: Ensure zanata config dir - name: Ensure zanata config dir
@ -102,7 +102,7 @@
copy: copy:
dest: '{{ ansible_user_dir }}/scripts/' dest: '{{ ansible_user_dir }}/scripts/'
src: '{{ item }}' src: '{{ item }}'
mode: 0755 mode: '0755'
with_items: with_items:
- common_translation_update.sh - common_translation_update.sh
- create-zanata-xml.py - create-zanata-xml.py

View File

@ -5,8 +5,6 @@
hacking>=7.0.0,<8.0.0 # Apache-2.0 hacking>=7.0.0,<8.0.0 # Apache-2.0
# ansible-lint requires ansible>=2.9 # ansible-lint requires ansible>=2.9
ansible>=5,<6 ansible>=8,<9
# pin these two until someone has time to update all our skips to >=6.16 ansible-lint<25.0.0
ansible-lint>=6,<6.5
ansible-compat<4
bashate>=0.2 bashate>=0.2

View File

@ -3,10 +3,12 @@
# If you add new tests, also update the files section in job # If you add new tests, also update the files section in job
# base-integration in zuul.d/jobs.yaml. # base-integration in zuul.d/jobs.yaml.
- hosts: all - name: Ensure Output Dirs
hosts: all
roles: roles:
- ensure-output-dirs - ensure-output-dirs
- hosts: all - name: Fetch Output
hosts: all
roles: roles:
- fetch-output - fetch-output

View File

@ -3,5 +3,6 @@
# If you add new tests, also update the files section in job # If you add new tests, also update the files section in job
# extra-integration in zuul.d/jobs.yaml. # extra-integration in zuul.d/jobs.yaml.
- import_playbook: prepare-zanata-client.yaml - name: Prepare Zanata Client
import_playbook: prepare-zanata-client.yaml
when: ansible_os_family == 'Debian' when: ansible_os_family == 'Debian'

View File

@ -1451,7 +1451,6 @@
- openstack/project-config - openstack/project-config
- opendev/system-config - opendev/system-config
- zuul/zuul-jobs - zuul/zuul-jobs
nodeset: ubuntu-jammy
vars: vars:
tox_envlist: linters tox_envlist: linters
tox_environment: tox_environment: