diff --git a/roles/copy-build-sshkey/tasks/main.yaml b/roles/copy-build-sshkey/tasks/main.yaml index 69f911bfa..880a828f5 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 - name: Add build ssh key + become: true block: # Add the authorization first, to take advantage of manage_dir - name: Authorize build key @@ -32,4 +33,3 @@ mode: 0644 owner: "{{ copy_sshkey_target_user }}" force: no - become: true diff --git a/roles/ensure-cabal/tasks/main.yaml b/roles/ensure-cabal/tasks/main.yaml index d59aa3639..7f7957701 100644 --- a/roles/ensure-cabal/tasks/main.yaml +++ b/roles/ensure-cabal/tasks/main.yaml @@ -9,6 +9,7 @@ register: _cabal_version - name: Install cabal + when: _cabal_version.rc != 0 block: - name: Ensure copr dnf plugin package: @@ -25,7 +26,6 @@ name: cabal-install state: present become: true - when: _cabal_version.rc != 0 - name: Check package stat: diff --git a/roles/ensure-haskell-stack/tasks/main.yaml b/roles/ensure-haskell-stack/tasks/main.yaml index d46dce759..9cd8baacc 100644 --- a/roles/ensure-haskell-stack/tasks/main.yaml +++ b/roles/ensure-haskell-stack/tasks/main.yaml @@ -9,6 +9,7 @@ register: _stack_version - name: Install stack + when: _stack_version.rc != 0 block: # This package is somehow missing from the requirements of the # published packaged copr repo. See @@ -31,4 +32,3 @@ - name: Setup stack LTS command: "stack {% if lts_version %}--resolver {{ lts_version }}{% endif %} setup" - when: _stack_version.rc != 0 diff --git a/roles/ensure-kubernetes/tasks/minikube.yaml b/roles/ensure-kubernetes/tasks/minikube.yaml index 7f355fdff..0126fdbaf 100644 --- a/roles/ensure-kubernetes/tasks/minikube.yaml +++ b/roles/ensure-kubernetes/tasks/minikube.yaml @@ -73,6 +73,7 @@ extra_args: "" - name: Configure dns options if set + when: minikube_dns_resolvers|length>0 block: - name: Write resolv.conf template: @@ -82,7 +83,6 @@ - name: Set extra kube setttings set_fact: extra_args: "--extra-config=kubelet.resolv-conf={{ ansible_user_dir }}/.minikube/k8s_resolv.conf" - when: minikube_dns_resolvers|length>0 # See https://github.com/kubernetes/minikube/issues/14410 - name: Setup cri-dockerd diff --git a/roles/ensure-pip/tasks/RedHat.yaml b/roles/ensure-pip/tasks/RedHat.yaml index 4cd7d82a9..b27794df6 100644 --- a/roles/ensure-pip/tasks/RedHat.yaml +++ b/roles/ensure-pip/tasks/RedHat.yaml @@ -8,6 +8,8 @@ become: yes - name: Install pip + become: yes + when: ensure_pip_from_packages_with_python2 block: - name: Check for EPEL repository stat: @@ -32,5 +34,3 @@ - python-wheel state: present enablerepo: epel - become: yes - when: ensure_pip_from_packages_with_python2 diff --git a/roles/ensure-shake/tasks/main.yaml b/roles/ensure-shake/tasks/main.yaml index 9cb9a952c..fa53dfb1f 100644 --- a/roles/ensure-shake/tasks/main.yaml +++ b/roles/ensure-shake/tasks/main.yaml @@ -13,6 +13,7 @@ register: _shake_version - name: Install shake + when: "_shake_version.rc != 0" block: - name: Include OS-specific variables include_vars: "{{ zj_distro_os }}" @@ -29,4 +30,3 @@ name: "{{ shake_packages }}" state: present become: yes - when: "_shake_version.rc != 0" diff --git a/roles/ensure-twine/tasks/main.yaml b/roles/ensure-twine/tasks/main.yaml index 40789cc15..380f1ef53 100644 --- a/roles/ensure-twine/tasks/main.yaml +++ b/roles/ensure-twine/tasks/main.yaml @@ -12,6 +12,7 @@ when: register_twine.rc == 0 - name: Ensure twine is installed + when: register_twine.rc != 0 block: - name: Ensure twine is installed command: "{{ twine_python }} -m pip install twine!=1.12.0 requests-toolbelt!=0.9.0 --user" @@ -19,4 +20,3 @@ - name: Set pypi_twine_executable set_fact: pypi_twine_executable: ~/.local/bin/twine - when: register_twine.rc != 0 diff --git a/roles/fetch-javascript-tarball/tasks/main.yaml b/roles/fetch-javascript-tarball/tasks/main.yaml index c4d5bca3c..ae9eee1c1 100644 --- a/roles/fetch-javascript-tarball/tasks/main.yaml +++ b/roles/fetch-javascript-tarball/tasks/main.yaml @@ -10,6 +10,7 @@ - skip_ansible_lint - name: Return artifacts + when: not zuul_use_fetch_output block: - name: Ensure artifacts directory exists file: @@ -26,4 +27,3 @@ verify_host: true owner: no group: no - when: not zuul_use_fetch_output diff --git a/roles/fetch-sphinx-tarball/tasks/html.yaml b/roles/fetch-sphinx-tarball/tasks/html.yaml index 170f76e06..11400ea74 100644 --- a/roles/fetch-sphinx-tarball/tasks/html.yaml +++ b/roles/fetch-sphinx-tarball/tasks/html.yaml @@ -10,6 +10,7 @@ warn: false - name: Fetch HTML + when: not zuul_use_fetch_output block: - name: Fetch archive HTML synchronize: @@ -35,9 +36,9 @@ remote_src: true extra_opts: - "--no-same-owner" - when: not zuul_use_fetch_output - name: Copy HTML + when: zuul_use_fetch_output block: - name: Copy archive HTML copy: @@ -59,7 +60,6 @@ remote_src: true extra_opts: - "--no-same-owner" - when: zuul_use_fetch_output - name: Return artifact to Zuul zuul_return: diff --git a/roles/fetch-translation-output/tasks/main.yaml b/roles/fetch-translation-output/tasks/main.yaml index b6f5ec855..9d2912e16 100644 --- a/roles/fetch-translation-output/tasks/main.yaml +++ b/roles/fetch-translation-output/tasks/main.yaml @@ -4,6 +4,7 @@ register: translation_files - name: Collection translation files + when: translation_files.stat.exists block: - name: Collect translation source files synchronize: @@ -22,4 +23,3 @@ mode: 0755 remote_src: true when: zuul_use_fetch_output - when: translation_files.stat.exists diff --git a/roles/stage-output/tasks/main.yaml b/roles/stage-output/tasks/main.yaml index ec07404f5..e798e0e76 100644 --- a/roles/stage-output/tasks/main.yaml +++ b/roles/stage-output/tasks/main.yaml @@ -80,6 +80,8 @@ when: extensions_to_txt is defined and extensions_to_txt is not none - name: Collect log files + when: + - stage_compress_logs block: - name: Discover log files for compression find: @@ -104,5 +106,3 @@ loop_var: zj_log_file tags: - skip_ansible_lint - when: - - stage_compress_logs diff --git a/roles/test-upload-logs-swift/tasks/main.yaml b/roles/test-upload-logs-swift/tasks/main.yaml index 5b79fa58d..332906a5b 100644 --- a/roles/test-upload-logs-swift/tasks/main.yaml +++ b/roles/test-upload-logs-swift/tasks/main.yaml @@ -32,6 +32,7 @@ register: upload_results - name: Return log URL + when: upload_results is defined block: - name: Return log URL to Zuul delegate_to: localhost @@ -42,4 +43,3 @@ - name: Print upload failures debug: var: upload_results.upload_failures - when: upload_results is defined diff --git a/roles/upload-logs-swift/tasks/main.yaml b/roles/upload-logs-swift/tasks/main.yaml index 3af501862..858279880 100644 --- a/roles/upload-logs-swift/tasks/main.yaml +++ b/roles/upload-logs-swift/tasks/main.yaml @@ -32,6 +32,7 @@ register: upload_results - name: Return logs + when: upload_results is defined block: - name: Return log URL to Zuul delegate_to: localhost @@ -42,4 +43,3 @@ - name: Print upload failures debug: var: upload_results.upload_failures - when: upload_results is defined diff --git a/roles/validate-host/tasks/main.yaml b/roles/validate-host/tasks/main.yaml index f921ed28a..6e3bbd45e 100644 --- a/roles/validate-host/tasks/main.yaml +++ b/roles/validate-host/tasks/main.yaml @@ -26,6 +26,9 @@ mode: 0644 - name: Run zuul_debug_info and collect output + when: + - ansible_os_family != "Windows" + - ansible_python_version is version('2.7', '>=') block: - name: Collect information about zuul worker zuul_debug_info: @@ -42,7 +45,3 @@ dest: "{{ zuul_info_dir }}/zuul-info.{{ validate_host_hostname_sanitized }}.txt" src: templates/zuul-info.j2 mode: 0644 - - when: - - ansible_os_family != "Windows" - - ansible_python_version is version('2.7', '>=')