linters: add names to blocks

This is preparation for a later version of ansbile-lint, which finds
missing names on blocks.  This seems a reasonable rule, and the
Ansible manual says [1]

  Names for blocks have been available since Ansible 2.3. We recommend
  using names in all tasks, within blocks or elsewhere, for better
  visibility into the tasks being executed when you run the playbook.

This simply adds a name tag for blocks that are missing it.  This
should have no operational change, but allows us to update the linter
in a follow-on change.

[1] https://docs.ansible.com/ansible/latest/user_guide/playbooks_blocks.html

Change-Id: I92ed4616775650aced352bc9088a07e919f1a25f
This commit is contained in:
Ian Wienand 2022-07-26 20:15:16 +10:00
parent f76cfbab11
commit 6d23d20f2f
33 changed files with 84 additions and 43 deletions

View File

@ -1,4 +1,5 @@
- block: - name: Install ARA
block:
- name: Check that ARA is installed - name: Check that ARA is installed
command: bash -c "type -p {{ ara_report_executable }}" command: bash -c "type -p {{ ara_report_executable }}"
failed_when: false failed_when: false
@ -36,7 +37,8 @@
It is likely that no report will be available, please verify the It is likely that no report will be available, please verify the
execution and the parameters of the role for details. execution and the parameters of the role for details.
- when: - name: Generate output
when:
- ara_installed.rc == 0 - ara_installed.rc == 0
- ara_db.stat.exists - ara_db.stat.exists
- ara_report_type == 'html' - ara_report_type == 'html'
@ -71,7 +73,8 @@
Something failed during the generation of the HTML report. Something failed during the generation of the HTML report.
Please verify the execution of the role for details. Please verify the execution of the role for details.
- when: - name: Save database
when:
- ara_installed.rc == 0 - ara_installed.rc == 0
- ara_db.stat.exists - ara_db.stat.exists
- ara_report_type == 'database' - ara_report_type == 'database'

View File

@ -1,6 +1,7 @@
--- ---
# Use a block to add become to a set of tasks # Use a block to add become to a set of tasks
- block: - name: Add build ssh key
block:
# Add the authorization first, to take advantage of manage_dir # Add the authorization first, to take advantage of manage_dir
- name: Authorize build key - name: Authorize build key
authorized_key: authorized_key:

View File

@ -1,5 +1,6 @@
# We don't want this to run for every host, it should only run once. # We don't want this to run for every host, it should only run once.
- run_once: yes - name: Emit log header
run_once: yes
block: block:
- name: Setup log path fact - name: Setup log path fact
include_role: include_role:

View File

@ -8,7 +8,8 @@
failed_when: false failed_when: false
register: _cabal_version register: _cabal_version
- block: - name: Install cabal
block:
- name: Ensure copr dnf plugin - name: Ensure copr dnf plugin
package: package:
name: dnf-plugins-core name: dnf-plugins-core

View File

@ -8,7 +8,8 @@
failed_when: false failed_when: false
register: _stack_version register: _stack_version
- block: - name: Install stack
block:
# This package is somehow missing from the requirements of the # This package is somehow missing from the requirements of the
# published packaged copr repo. See # published packaged copr repo. See
# https://github.com/commercialhaskell/stack/issues/5388 # https://github.com/commercialhaskell/stack/issues/5388

View File

@ -11,7 +11,8 @@
changed_when: false changed_when: false
register: _nimble_installed register: _nimble_installed
- when: _nimble_installed.rc != 0 - name: Install nimble
when: _nimble_installed.rc != 0
block: block:
# Current version of nimble is not compatible with openssl3, which is included in CentOS9 # Current version of nimble is not compatible with openssl3, which is included in CentOS9
- name: Install compat-openssl11 in CentOS 9 - name: Install compat-openssl11 in CentOS 9

View File

@ -7,7 +7,8 @@
state: present state: present
become: yes become: yes
- block: - name: Install pip
block:
- name: Check for EPEL repository - name: Check for EPEL repository
stat: stat:
path: /etc/yum.repos.d/epel.repo path: /etc/yum.repos.d/epel.repo

View File

@ -12,7 +12,8 @@
failed_when: false failed_when: false
register: _shake_version register: _shake_version
- block: - name: Install shake
block:
- name: Include OS-specific variables - name: Include OS-specific variables
include_vars: "{{ zj_distro_os }}" include_vars: "{{ zj_distro_os }}"
loop_control: loop_control:

View File

@ -3,14 +3,15 @@
path: "{{ coverage_output_src }}" path: "{{ coverage_output_src }}"
register: coverage_report_stat register: coverage_report_stat
- when: - name: Fail if coverage job succeeded and report is not present
when:
- zuul_success | default(true) | bool - zuul_success | default(true) | bool
- not coverage_report_stat.stat.exists - not coverage_report_stat.stat.exists
name: Fail if coverage job succeeded and report is not present
fail: fail:
msg: "Coverage report was not found even though tests succeeded" msg: "Coverage report was not found even though tests succeeded"
- when: coverage_report_stat.stat.exists - name: Collect coverage
when: coverage_report_stat.stat.exists
block: block:
- name: Collect coverage details output - name: Collect coverage details output
synchronize: synchronize:

View File

@ -9,7 +9,8 @@
# Ignore ANSIBLE0007: No need to use file module instead of mkdir # Ignore ANSIBLE0007: No need to use file module instead of mkdir
- skip_ansible_lint - skip_ansible_lint
- block: - name: Return artifacts
block:
- name: Ensure artifacts directory exists - name: Ensure artifacts directory exists
file: file:
path: "{{ zuul.executor.work_root }}/artifacts" path: "{{ zuul.executor.work_root }}/artifacts"

View File

@ -9,7 +9,8 @@
args: args:
warn: false warn: false
- block: - name: Fetch HTML
block:
- name: Fetch archive HTML - name: Fetch archive HTML
synchronize: synchronize:
dest: "{{ zuul.executor.log_root }}/docs-html.tar.gz" dest: "{{ zuul.executor.log_root }}/docs-html.tar.gz"
@ -36,7 +37,8 @@
- "--no-same-owner" - "--no-same-owner"
when: not zuul_use_fetch_output when: not zuul_use_fetch_output
- block: - name: Copy HTML
block:
- name: Copy archive HTML - name: Copy archive HTML
copy: copy:
dest: "{{ zuul_output_dir }}/logs/docs-html.tar.gz" dest: "{{ zuul_output_dir }}/logs/docs-html.tar.gz"

View File

@ -6,7 +6,8 @@
register: testr_command register: testr_command
failed_when: false failed_when: false
- when: - name: Process subunit
when:
- testr_command.rc == 0 - testr_command.rc == 0
# Here we run steps that should apply whether or not there is a valid # Here we run steps that should apply whether or not there is a valid
# subunit stream present. # subunit stream present.
@ -47,7 +48,8 @@
loop_control: loop_control:
loop_var: zj_item loop_var: zj_item
- when: - name: Process subunit stream
when:
- testr_command.rc == 0 - testr_command.rc == 0
- testr_command.stdout - testr_command.stdout
# Here we run steps that only apply when there is a valid subunity stream. # Here we run steps that only apply when there is a valid subunity stream.

View File

@ -3,7 +3,8 @@
path: "{{ translation_output_src }}" path: "{{ translation_output_src }}"
register: translation_files register: translation_files
- block: - name: Collection translation files
block:
- name: Collect translation source files - name: Collect translation source files
synchronize: synchronize:
dest: "{{ zuul_executor_dest }}" dest: "{{ zuul_executor_dest }}"

View File

@ -1,4 +1,5 @@
- block: - name: Run golangci-lint
block:
- name: Run golangci-lint - name: Run golangci-lint
command: "golangci-lint run {{ golangci_lint_options }}" command: "golangci-lint run {{ golangci_lint_options }}"
args: args:

View File

@ -1,4 +1,5 @@
- block: - name: Run hlint
block:
- name: Run hlint - name: Run hlint
command: "hlint --report={{ report_location }} ." command: "hlint --report={{ report_location }} ."
vars: vars:

View File

@ -10,7 +10,8 @@
# openvswitch for CentOS is available from the RDO repositories. # openvswitch for CentOS is available from the RDO repositories.
# We're setting it up manually to prevent centos-release-openstack or rdo-release # We're setting it up manually to prevent centos-release-openstack or rdo-release
# from installing repositories we don't need. # from installing repositories we don't need.
- when: - name: Install for Redhat
when:
- ansible_os_family == "RedHat" - ansible_os_family == "RedHat"
- ansible_distribution not in ["Fedora", "RedHat"] - ansible_distribution not in ["Fedora", "RedHat"]
become: yes become: yes
@ -99,7 +100,8 @@
- bridge_configure_address | bool - bridge_configure_address | bool
- bridge_authorize_internal_traffic | bool - bridge_authorize_internal_traffic | bool
- when: bridge_mtu is not defined - name: Find bridge MTU
when: bridge_mtu is not defined
block: block:
- name: Determine bridge mtu - name: Determine bridge mtu
shell: | shell: |

View File

@ -63,7 +63,8 @@
type=vxlan options:remote_ip={{ switch_ip }} options:key={{ vni }} type=vxlan options:remote_ip={{ switch_ip }} options:key={{ vni }}
options:local_ip={{ nodepool_ip }} options:local_ip={{ nodepool_ip }}
- when: bridge_configure_address - name: Configure bridge address
when: bridge_configure_address
block: block:
- name: Verify if the bridge address is set - name: Verify if the bridge address is set
shell: ip addr show dev {{ bridge_name }} | grep -q {{ bridge_address_prefix }}.{{ offset }}/{{ bridge_address_subnet }} shell: ip addr show dev {{ bridge_name }} | grep -q {{ bridge_address_prefix }}.{{ offset }}/{{ bridge_address_subnet }}

View File

@ -7,7 +7,8 @@
become: yes become: yes
command: ip link set mtu {{ bridge_mtu }} dev {{ bridge_name }} command: ip link set mtu {{ bridge_mtu }} dev {{ bridge_name }}
- when: bridge_configure_address - name: Configure bridge address
when: bridge_configure_address
block: block:
- name: Verify if the bridge address is set - name: Verify if the bridge address is set
shell: ip addr show dev {{ bridge_name }} | grep -q {{ bridge_address_prefix }}.{{ bridge_address_offset }}/{{ bridge_address_subnet }} shell: ip addr show dev {{ bridge_name }} | grep -q {{ bridge_address_prefix }}.{{ bridge_address_offset }}/{{ bridge_address_subnet }}

View File

@ -17,7 +17,8 @@
when: packer_variables is defined when: packer_variables is defined
no_log: true # We don't want to log this since credentials could be passed this way no_log: true # We don't want to log this since credentials could be passed this way
- block: - name: Run packer
block:
- name: Run packer - name: Run packer
command: >- command: >-
{{ packer_executable }} {{ packer_executable }}

View File

@ -1,4 +1,5 @@
- block: - name: Run shake
block:
- name: Run shake - name: Run shake
command: "shake --report={{ report_location }} {{ shake_target }}" command: "shake --report={{ report_location }} {{ shake_target }}"
vars: vars:

View File

@ -107,7 +107,8 @@
tags: tags:
- skip_ansible_lint - skip_ansible_lint
- block: - name: Collect log files
block:
- name: Discover log files for compression - name: Discover log files for compression
find: find:
paths: "{{ stage_dir }}/logs" paths: "{{ stage_dir }}/logs"

View File

@ -1,4 +1,5 @@
- when: not test_setup_skip - name: Run test-setup.sh
when: not test_setup_skip
block: block:
- name: "Check if project's tools/test-setup.sh exists" - name: "Check if project's tools/test-setup.sh exists"
stat: stat:

View File

@ -4,7 +4,8 @@
when: zuul_log_path is not defined when: zuul_log_path is not defined
# Always upload (true), never upload (false) or only on failure ('failure') # Always upload (true), never upload (false) or only on failure ('failure')
- when: zuul_site_upload_logs | default(true) | bool or - name: Upload logs
when: zuul_site_upload_logs | default(true) | bool or
(zuul_site_upload_logs == 'failure' and not zuul_success | bool) (zuul_site_upload_logs == 'failure' and not zuul_success | bool)
block: block:
# Use chmod instead of file because ansible 2.5 file with recurse and # Use chmod instead of file because ansible 2.5 file with recurse and
@ -30,7 +31,8 @@
delete_after: "{{ zuul_log_delete_after | default(omit) }}" delete_after: "{{ zuul_log_delete_after | default(omit) }}"
register: upload_results register: upload_results
- block: - name: Return log URL
block:
- name: Return log URL to Zuul - name: Return log URL to Zuul
delegate_to: localhost delegate_to: localhost
zuul_return: zuul_return:

View File

@ -36,7 +36,8 @@
{% endif %} {% endif %}
{{ tox_extra_args }} {{ tox_extra_args }}
- block: - name: Run tox
block:
- name: Run tox - name: Run tox
args: args:
chdir: "{{ zuul_work_dir }}" chdir: "{{ zuul_work_dir }}"

View File

@ -8,7 +8,8 @@
msg: Must set either rtd_credentials.username or rtd_credentials.integration_token msg: Must set either rtd_credentials.username or rtd_credentials.integration_token
when: (rtd_credentials.username is not defined) and (rtd_credentials.integration_token is not defined) when: (rtd_credentials.username is not defined) and (rtd_credentials.integration_token is not defined)
- when: rtd_credentials.username is defined - name: Upload to RTD
when: rtd_credentials.username is defined
block: block:
- name: Require password - name: Require password
fail: fail:
@ -27,7 +28,8 @@
# avoid logging any credentials # avoid logging any credentials
no_log: true no_log: true
- when: rtd_credentials.integration_token is defined and - name: Trigger RTD docs
when: rtd_credentials.integration_token is defined and
rtd_credentials.username is not defined rtd_credentials.username is not defined
block: block:
- name: Trigger readthedocs build webhook via token - name: Trigger readthedocs build webhook via token

View File

@ -1,4 +1,5 @@
- block: - name: Upload git mirror
block:
- name: Create SSH private key tempfile - name: Create SSH private key tempfile
tempfile: tempfile:
state: file state: file

View File

@ -4,7 +4,8 @@
when: zuul_log_path is not defined when: zuul_log_path is not defined
# Always upload (true), never upload (false) or only on failure ('failure') # Always upload (true), never upload (false) or only on failure ('failure')
- when: zuul_site_upload_logs | default(true) | bool or - name: Upload logs
when: zuul_site_upload_logs | default(true) | bool or
(zuul_site_upload_logs == 'failure' and not zuul_success | bool) (zuul_site_upload_logs == 'failure' and not zuul_success | bool)
block: block:
# Use chmod instead of file because ansible 2.5 file with recurse and # Use chmod instead of file because ansible 2.5 file with recurse and

View File

@ -4,7 +4,8 @@
when: zuul_log_path is not defined when: zuul_log_path is not defined
# Always upload (true), never upload (false) or only on failure ('failure') # Always upload (true), never upload (false) or only on failure ('failure')
- when: zuul_site_upload_logs | default(true) | bool or - name: Upload logs
when: zuul_site_upload_logs | default(true) | bool or
(zuul_site_upload_logs == 'failure' and not zuul_success | bool) (zuul_site_upload_logs == 'failure' and not zuul_success | bool)
block: block:
# Use chmod instead of file because ansible 2.5 file with recurse and # Use chmod instead of file because ansible 2.5 file with recurse and

View File

@ -4,7 +4,8 @@
when: zuul_log_path is not defined when: zuul_log_path is not defined
# Always upload (true), never upload (false) or only on failure ('failure') # Always upload (true), never upload (false) or only on failure ('failure')
- when: zuul_site_upload_logs | default(true) | bool or - name: Upload logs
when: zuul_site_upload_logs | default(true) | bool or
(zuul_site_upload_logs == 'failure' and not zuul_success | bool) (zuul_site_upload_logs == 'failure' and not zuul_success | bool)
block: block:
# Use chmod instead of file because ansible 2.5 file with recurse and # Use chmod instead of file because ansible 2.5 file with recurse and

View File

@ -4,7 +4,8 @@
when: zuul_log_path is not defined when: zuul_log_path is not defined
# Always upload (true), never upload (false) or only on failure ('failure') # Always upload (true), never upload (false) or only on failure ('failure')
- when: zuul_site_upload_logs | default(true) | bool or - name: Upload logs
when: zuul_site_upload_logs | default(true) | bool or
(zuul_site_upload_logs == 'failure' and not zuul_success | bool) (zuul_site_upload_logs == 'failure' and not zuul_success | bool)
block: block:
# Use chmod instead of file because ansible 2.5 file with recurse and # Use chmod instead of file because ansible 2.5 file with recurse and

View File

@ -4,7 +4,8 @@
when: zuul_log_path is not defined when: zuul_log_path is not defined
# Always upload (true), never upload (false) or only on failure ('failure') # Always upload (true), never upload (false) or only on failure ('failure')
- when: zuul_site_upload_logs | default(true) | bool or - name: Upload logs
when: zuul_site_upload_logs | default(true) | bool or
(zuul_site_upload_logs == 'failure' and not zuul_success | bool) (zuul_site_upload_logs == 'failure' and not zuul_success | bool)
block: block:
# Use chmod instead of file because ansible 2.5 file with recurse and # Use chmod instead of file because ansible 2.5 file with recurse and
@ -30,7 +31,8 @@
delete_after: "{{ zuul_log_delete_after | default(omit) }}" delete_after: "{{ zuul_log_delete_after | default(omit) }}"
register: upload_results register: upload_results
- block: - name: Return logs
block:
- name: Return log URL to Zuul - name: Return log URL to Zuul
delegate_to: localhost delegate_to: localhost
zuul_return: zuul_return:

View File

@ -3,7 +3,8 @@
name: set-zuul-log-path-fact name: set-zuul-log-path-fact
# Always upload (true), never upload (false) or only on failure ('failure') # Always upload (true), never upload (false) or only on failure ('failure')
- when: zuul_site_upload_logs | default(true) | bool or - name: Upload logs
when: zuul_site_upload_logs | default(true) | bool or
(zuul_site_upload_logs == 'failure' and not zuul_success | bool) (zuul_site_upload_logs == 'failure' and not zuul_success | bool)
block: block:

View File

@ -61,7 +61,8 @@
# Some repos, like storyboard-webclient, do not have any tags. git describe # Some repos, like storyboard-webclient, do not have any tags. git describe
# throws an error in those repos. To be consistent, do a commit count the # throws an error in those repos. To be consistent, do a commit count the
# hard way. # hard way.
- when: commits_since_tag_output.rc != 0 - name: Get commits
when: commits_since_tag_output.rc != 0
block: block:
- name: Get commits since the beginning - name: Get commits since the beginning