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

View File

@ -1,6 +1,7 @@
---
# 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
- name: Authorize build key
authorized_key:

View File

@ -1,5 +1,6 @@
# 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:
- name: Setup log path fact
include_role:

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,14 +3,15 @@
path: "{{ coverage_output_src }}"
register: coverage_report_stat
- when:
- name: Fail if coverage job succeeded and report is not present
when:
- zuul_success | default(true) | bool
- not coverage_report_stat.stat.exists
name: Fail if coverage job succeeded and report is not present
fail:
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:
- name: Collect coverage details output
synchronize:

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -7,7 +7,8 @@
become: yes
command: ip link set mtu {{ bridge_mtu }} dev {{ bridge_name }}
- when: bridge_configure_address
- name: Configure bridge address
when: bridge_configure_address
block:
- 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 }}

View File

@ -17,7 +17,8 @@
when: packer_variables is defined
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
command: >-
{{ packer_executable }}

View File

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

View File

@ -107,7 +107,8 @@
tags:
- skip_ansible_lint
- block:
- name: Collect log files
block:
- name: Discover log files for compression
find:
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:
- name: "Check if project's tools/test-setup.sh exists"
stat:

View File

@ -4,7 +4,8 @@
when: zuul_log_path is not defined
# 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)
block:
# 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) }}"
register: upload_results
- block:
- name: Return log URL
block:
- name: Return log URL to Zuul
delegate_to: localhost
zuul_return:

View File

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

View File

@ -8,7 +8,8 @@
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 defined
- name: Upload to RTD
when: rtd_credentials.username is defined
block:
- name: Require password
fail:
@ -27,7 +28,8 @@
# avoid logging any credentials
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
block:
- 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
tempfile:
state: file

View File

@ -4,7 +4,8 @@
when: zuul_log_path is not defined
# 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)
block:
# 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
# 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)
block:
# 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
# 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)
block:
# 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
# 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)
block:
# 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
# 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)
block:
# 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) }}"
register: upload_results
- block:
- name: Return logs
block:
- name: Return log URL to Zuul
delegate_to: localhost
zuul_return:

View File

@ -3,7 +3,8 @@
name: set-zuul-log-path-fact
# 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)
block:

View File

@ -61,7 +61,8 @@
# 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
# hard way.
- when: commits_since_tag_output.rc != 0
- name: Get commits
when: commits_since_tag_output.rc != 0
block:
- name: Get commits since the beginning