From 6d23d20f2f9ae6aed2d43758e9480b6c2a69c58a Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Tue, 26 Jul 2022 20:15:16 +1000 Subject: [PATCH] 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 --- roles/ara-report/tasks/main.yaml | 9 ++++++--- roles/copy-build-sshkey/tasks/main.yaml | 3 ++- roles/emit-job-header/tasks/main.yaml | 3 ++- roles/ensure-cabal/tasks/main.yaml | 3 ++- roles/ensure-haskell-stack/tasks/main.yaml | 3 ++- roles/ensure-nimble/tasks/main.yaml | 3 ++- roles/ensure-pip/tasks/RedHat.yaml | 3 ++- roles/ensure-shake/tasks/main.yaml | 3 ++- roles/fetch-coverage-output/tasks/main.yaml | 7 ++++--- roles/fetch-javascript-tarball/tasks/main.yaml | 3 ++- roles/fetch-sphinx-tarball/tasks/html.yaml | 6 ++++-- roles/fetch-subunit-output/tasks/main.yaml | 6 ++++-- roles/fetch-translation-output/tasks/main.yaml | 3 ++- roles/golangci-lint/tasks/main.yaml | 3 ++- roles/hlint/tasks/main.yaml | 3 ++- roles/multi-node-bridge/tasks/common.yaml | 6 ++++-- roles/multi-node-bridge/tasks/peer.yaml | 3 ++- roles/multi-node-bridge/tasks/switch.yaml | 3 ++- roles/packer/tasks/main.yaml | 3 ++- roles/shake-build/tasks/main.yaml | 3 ++- roles/stage-output/tasks/main.yaml | 3 ++- roles/test-setup/tasks/main.yaml | 3 ++- roles/test-upload-logs-swift/tasks/main.yaml | 6 ++++-- roles/tox/tasks/main.yaml | 3 ++- roles/trigger-readthedocs/tasks/main.yaml | 6 ++++-- roles/upload-git-mirror/tasks/main.yaml | 3 ++- roles/upload-logs-azure/tasks/main.yaml | 3 ++- roles/upload-logs-gcs/tasks/main.yaml | 3 ++- roles/upload-logs-ibm/tasks/main.yaml | 3 ++- roles/upload-logs-s3/tasks/main.yaml | 3 ++- roles/upload-logs-swift/tasks/main.yaml | 6 ++++-- roles/upload-logs/tasks/main.yaml | 3 ++- roles/version-from-git/tasks/main.yaml | 3 ++- 33 files changed, 84 insertions(+), 43 deletions(-) diff --git a/roles/ara-report/tasks/main.yaml b/roles/ara-report/tasks/main.yaml index d95e5cc42..5d40a7269 100644 --- a/roles/ara-report/tasks/main.yaml +++ b/roles/ara-report/tasks/main.yaml @@ -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' diff --git a/roles/copy-build-sshkey/tasks/main.yaml b/roles/copy-build-sshkey/tasks/main.yaml index 496347bb2..cdab10b24 100644 --- a/roles/copy-build-sshkey/tasks/main.yaml +++ b/roles/copy-build-sshkey/tasks/main.yaml @@ -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: diff --git a/roles/emit-job-header/tasks/main.yaml b/roles/emit-job-header/tasks/main.yaml index 57d277117..314a140ac 100644 --- a/roles/emit-job-header/tasks/main.yaml +++ b/roles/emit-job-header/tasks/main.yaml @@ -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: diff --git a/roles/ensure-cabal/tasks/main.yaml b/roles/ensure-cabal/tasks/main.yaml index c8f269603..d59aa3639 100644 --- a/roles/ensure-cabal/tasks/main.yaml +++ b/roles/ensure-cabal/tasks/main.yaml @@ -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 diff --git a/roles/ensure-haskell-stack/tasks/main.yaml b/roles/ensure-haskell-stack/tasks/main.yaml index fa35e3486..d46dce759 100644 --- a/roles/ensure-haskell-stack/tasks/main.yaml +++ b/roles/ensure-haskell-stack/tasks/main.yaml @@ -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 diff --git a/roles/ensure-nimble/tasks/main.yaml b/roles/ensure-nimble/tasks/main.yaml index 75689067c..93471182f 100644 --- a/roles/ensure-nimble/tasks/main.yaml +++ b/roles/ensure-nimble/tasks/main.yaml @@ -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 diff --git a/roles/ensure-pip/tasks/RedHat.yaml b/roles/ensure-pip/tasks/RedHat.yaml index 783c51ea0..4cd7d82a9 100644 --- a/roles/ensure-pip/tasks/RedHat.yaml +++ b/roles/ensure-pip/tasks/RedHat.yaml @@ -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 diff --git a/roles/ensure-shake/tasks/main.yaml b/roles/ensure-shake/tasks/main.yaml index d7c0ffd00..9cb9a952c 100644 --- a/roles/ensure-shake/tasks/main.yaml +++ b/roles/ensure-shake/tasks/main.yaml @@ -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: diff --git a/roles/fetch-coverage-output/tasks/main.yaml b/roles/fetch-coverage-output/tasks/main.yaml index 966714cd4..7e0e9639b 100644 --- a/roles/fetch-coverage-output/tasks/main.yaml +++ b/roles/fetch-coverage-output/tasks/main.yaml @@ -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: diff --git a/roles/fetch-javascript-tarball/tasks/main.yaml b/roles/fetch-javascript-tarball/tasks/main.yaml index 54dde6e0d..c4d5bca3c 100644 --- a/roles/fetch-javascript-tarball/tasks/main.yaml +++ b/roles/fetch-javascript-tarball/tasks/main.yaml @@ -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" diff --git a/roles/fetch-sphinx-tarball/tasks/html.yaml b/roles/fetch-sphinx-tarball/tasks/html.yaml index 6a2a5b22d..170f76e06 100644 --- a/roles/fetch-sphinx-tarball/tasks/html.yaml +++ b/roles/fetch-sphinx-tarball/tasks/html.yaml @@ -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" diff --git a/roles/fetch-subunit-output/tasks/main.yaml b/roles/fetch-subunit-output/tasks/main.yaml index 840581601..6fa1da526 100644 --- a/roles/fetch-subunit-output/tasks/main.yaml +++ b/roles/fetch-subunit-output/tasks/main.yaml @@ -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. diff --git a/roles/fetch-translation-output/tasks/main.yaml b/roles/fetch-translation-output/tasks/main.yaml index 67358c6f1..b6f5ec855 100644 --- a/roles/fetch-translation-output/tasks/main.yaml +++ b/roles/fetch-translation-output/tasks/main.yaml @@ -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 }}" diff --git a/roles/golangci-lint/tasks/main.yaml b/roles/golangci-lint/tasks/main.yaml index 1e55d3773..7369b6eab 100644 --- a/roles/golangci-lint/tasks/main.yaml +++ b/roles/golangci-lint/tasks/main.yaml @@ -1,4 +1,5 @@ -- block: +- name: Run golangci-lint + block: - name: Run golangci-lint command: "golangci-lint run {{ golangci_lint_options }}" args: diff --git a/roles/hlint/tasks/main.yaml b/roles/hlint/tasks/main.yaml index f04bda223..dc4fdd705 100644 --- a/roles/hlint/tasks/main.yaml +++ b/roles/hlint/tasks/main.yaml @@ -1,4 +1,5 @@ -- block: +- name: Run hlint + block: - name: Run hlint command: "hlint --report={{ report_location }} ." vars: diff --git a/roles/multi-node-bridge/tasks/common.yaml b/roles/multi-node-bridge/tasks/common.yaml index a54b50081..59b5ea647 100644 --- a/roles/multi-node-bridge/tasks/common.yaml +++ b/roles/multi-node-bridge/tasks/common.yaml @@ -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: | diff --git a/roles/multi-node-bridge/tasks/peer.yaml b/roles/multi-node-bridge/tasks/peer.yaml index 8fd4182bb..af379b453 100644 --- a/roles/multi-node-bridge/tasks/peer.yaml +++ b/roles/multi-node-bridge/tasks/peer.yaml @@ -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 }} diff --git a/roles/multi-node-bridge/tasks/switch.yaml b/roles/multi-node-bridge/tasks/switch.yaml index cfde2eb92..24891887a 100644 --- a/roles/multi-node-bridge/tasks/switch.yaml +++ b/roles/multi-node-bridge/tasks/switch.yaml @@ -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 }} diff --git a/roles/packer/tasks/main.yaml b/roles/packer/tasks/main.yaml index a208641c9..d935919fe 100644 --- a/roles/packer/tasks/main.yaml +++ b/roles/packer/tasks/main.yaml @@ -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 }} diff --git a/roles/shake-build/tasks/main.yaml b/roles/shake-build/tasks/main.yaml index 22e1652ae..177ef7b6a 100644 --- a/roles/shake-build/tasks/main.yaml +++ b/roles/shake-build/tasks/main.yaml @@ -1,4 +1,5 @@ -- block: +- name: Run shake + block: - name: Run shake command: "shake --report={{ report_location }} {{ shake_target }}" vars: diff --git a/roles/stage-output/tasks/main.yaml b/roles/stage-output/tasks/main.yaml index cf5128874..d3681c1f5 100644 --- a/roles/stage-output/tasks/main.yaml +++ b/roles/stage-output/tasks/main.yaml @@ -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" diff --git a/roles/test-setup/tasks/main.yaml b/roles/test-setup/tasks/main.yaml index a1a059d91..3693ecea2 100644 --- a/roles/test-setup/tasks/main.yaml +++ b/roles/test-setup/tasks/main.yaml @@ -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: diff --git a/roles/test-upload-logs-swift/tasks/main.yaml b/roles/test-upload-logs-swift/tasks/main.yaml index 2497ec41d..5b79fa58d 100644 --- a/roles/test-upload-logs-swift/tasks/main.yaml +++ b/roles/test-upload-logs-swift/tasks/main.yaml @@ -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: diff --git a/roles/tox/tasks/main.yaml b/roles/tox/tasks/main.yaml index 0158b0050..8051e4a10 100644 --- a/roles/tox/tasks/main.yaml +++ b/roles/tox/tasks/main.yaml @@ -36,7 +36,8 @@ {% endif %} {{ tox_extra_args }} -- block: +- name: Run tox + block: - name: Run tox args: chdir: "{{ zuul_work_dir }}" diff --git a/roles/trigger-readthedocs/tasks/main.yaml b/roles/trigger-readthedocs/tasks/main.yaml index 59e11562d..f166da7dc 100644 --- a/roles/trigger-readthedocs/tasks/main.yaml +++ b/roles/trigger-readthedocs/tasks/main.yaml @@ -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 diff --git a/roles/upload-git-mirror/tasks/main.yaml b/roles/upload-git-mirror/tasks/main.yaml index c52e1887d..ad7e39cab 100644 --- a/roles/upload-git-mirror/tasks/main.yaml +++ b/roles/upload-git-mirror/tasks/main.yaml @@ -1,4 +1,5 @@ -- block: +- name: Upload git mirror + block: - name: Create SSH private key tempfile tempfile: state: file diff --git a/roles/upload-logs-azure/tasks/main.yaml b/roles/upload-logs-azure/tasks/main.yaml index 59c0b1183..5b03d7194 100644 --- a/roles/upload-logs-azure/tasks/main.yaml +++ b/roles/upload-logs-azure/tasks/main.yaml @@ -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 diff --git a/roles/upload-logs-gcs/tasks/main.yaml b/roles/upload-logs-gcs/tasks/main.yaml index 594f8431c..996b03034 100644 --- a/roles/upload-logs-gcs/tasks/main.yaml +++ b/roles/upload-logs-gcs/tasks/main.yaml @@ -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 diff --git a/roles/upload-logs-ibm/tasks/main.yaml b/roles/upload-logs-ibm/tasks/main.yaml index 3b1b1ed20..e0be74bb5 100644 --- a/roles/upload-logs-ibm/tasks/main.yaml +++ b/roles/upload-logs-ibm/tasks/main.yaml @@ -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 diff --git a/roles/upload-logs-s3/tasks/main.yaml b/roles/upload-logs-s3/tasks/main.yaml index 61c255c7c..ee86c2dba 100644 --- a/roles/upload-logs-s3/tasks/main.yaml +++ b/roles/upload-logs-s3/tasks/main.yaml @@ -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 diff --git a/roles/upload-logs-swift/tasks/main.yaml b/roles/upload-logs-swift/tasks/main.yaml index 2497ec41d..3af501862 100644 --- a/roles/upload-logs-swift/tasks/main.yaml +++ b/roles/upload-logs-swift/tasks/main.yaml @@ -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: diff --git a/roles/upload-logs/tasks/main.yaml b/roles/upload-logs/tasks/main.yaml index dbb888d18..b54f23216 100644 --- a/roles/upload-logs/tasks/main.yaml +++ b/roles/upload-logs/tasks/main.yaml @@ -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: diff --git a/roles/version-from-git/tasks/main.yaml b/roles/version-from-git/tasks/main.yaml index 16330fafe..81928d0f9 100644 --- a/roles/version-from-git/tasks/main.yaml +++ b/roles/version-from-git/tasks/main.yaml @@ -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