diff --git a/.ansible-lint b/.ansible-lint new file mode 100644 index 0000000000..b5fa74ab63 --- /dev/null +++ b/.ansible-lint @@ -0,0 +1,12 @@ +exclude_paths: + - zuul.d/ + - grafana/ + - nodepool/ + - ../../opendev +parseable: true +quiet: false +skip_list: + - '204' # [E204] Lines should be no longer than 120 chars + - '301' # [E301] Commands should not change things if nothing needs doing + - '306' # [E306] Shells that use pipes should set the pipefail option +verbosity: 1 diff --git a/playbooks/proposal/propose-updates.yaml b/playbooks/proposal/propose-updates.yaml index 82312a52b0..0ee0e98eb3 100644 --- a/playbooks/proposal/propose-updates.yaml +++ b/playbooks/proposal/propose-updates.yaml @@ -2,7 +2,7 @@ tasks: - name: Run propose_update.sh script - command: "{{ ansible_user_dir }}/scripts/propose_update.sh {{ update_target }} {{zuul.branch}}" + command: "{{ ansible_user_dir }}/scripts/propose_update.sh {{ update_target }} {{ zuul.branch }}" args: chdir: "src/{{ zuul.project.canonical_name }}" environment: '{{ zuul | zuul_legacy_vars }}' diff --git a/playbooks/publish/openstack-artifacts.yaml b/playbooks/publish/openstack-artifacts.yaml index a75b5510b4..4dc30323c1 100644 --- a/playbooks/publish/openstack-artifacts.yaml +++ b/playbooks/publish/openstack-artifacts.yaml @@ -9,7 +9,7 @@ name: upload-afs-synchronize vars: afs_source: "{{ zuul.executor.work_root }}/artifacts/" - afs_target: "/afs/.openstack.org/project/tarballs.opendev.org/{{ zuul.project.name}}/" + afs_target: "/afs/.openstack.org/project/tarballs.opendev.org/{{ zuul.project.name }}/" - name: Destroy AFS token include_role: name: destroy-afs-token diff --git a/playbooks/translation/openstack-translation-artifacts.yaml b/playbooks/translation/openstack-translation-artifacts.yaml index 64374b6f88..c943d0a343 100644 --- a/playbooks/translation/openstack-translation-artifacts.yaml +++ b/playbooks/translation/openstack-translation-artifacts.yaml @@ -9,7 +9,7 @@ name: upload-afs-synchronize vars: afs_source: "{{ zuul.executor.work_root }}/artifacts/" - afs_target: "/afs/.openstack.org/project/tarballs.opendev.org/openstack/translation-source/{{ zuul.project.short_name}}/" + afs_target: "/afs/.openstack.org/project/tarballs.opendev.org/openstack/translation-source/{{ zuul.project.short_name }}/" - name: Destroy AFS token include_role: name: destroy-afs-token diff --git a/playbooks/translation/upstream-translation-update.yaml b/playbooks/translation/upstream-translation-update.yaml index 30b43bf765..b12790fa12 100644 --- a/playbooks/translation/upstream-translation-update.yaml +++ b/playbooks/translation/upstream-translation-update.yaml @@ -5,7 +5,7 @@ tasks: - name: Run upstream_translation_update.sh script - command: "{{ ansible_user_dir }}/scripts/upstream_translation_update.sh {{ zuul.project.short_name }} {{ zuul.job }} {{zuul.branch}} {{ ansible_user_dir }}/{{ zuul.projects['opendev.org/openstack/horizon'].src_dir }}" + command: "{{ ansible_user_dir }}/scripts/upstream_translation_update.sh {{ zuul.project.short_name }} {{ zuul.job }} {{ zuul.branch }} {{ ansible_user_dir }}/{{ zuul.projects['opendev.org/openstack/horizon'].src_dir }}" args: chdir: "{{ zuul.project.src_dir }}" diff --git a/roles/test-upload-logs/tasks/main.yaml b/roles/test-upload-logs/tasks/main.yaml index 7092734b1d..cd2b46a4c5 100644 --- a/roles/test-upload-logs/tasks/main.yaml +++ b/roles/test-upload-logs/tasks/main.yaml @@ -9,7 +9,7 @@ - name: Create log directories file: - path: "{{zuul_logserver_root}}/{{ zuul_log_path }}" + path: "{{ zuul_logserver_root }}/{{ zuul_log_path }}" state: directory recurse: yes mode: 0775 @@ -26,7 +26,7 @@ - name: Upload logs to log server synchronize: src: "{{ zuul.executor.log_root }}/" - dest: "{{zuul_logserver_root}}/{{ zuul_log_path }}/" + dest: "{{ zuul_logserver_root }}/{{ zuul_log_path }}/" rsync_opts: - "--exclude=job-output.txt" - "--exclude=job-output.json" @@ -44,7 +44,7 @@ - name: Upload console log and json output synchronize: src: "{{ zuul.executor.log_root }}/{{ item }}.gz" - dest: "{{zuul_logserver_root}}/{{ zuul_log_path }}/{{ item }}.gz" + dest: "{{ zuul_logserver_root }}/{{ zuul_log_path }}/{{ item }}.gz" verify_host: true with_items: - job-output.txt diff --git a/roles/use-cached-repos/tasks/main.yaml b/roles/use-cached-repos/tasks/main.yaml index 4456db7093..82cfabe0eb 100644 --- a/roles/use-cached-repos/tasks/main.yaml +++ b/roles/use-cached-repos/tasks/main.yaml @@ -5,9 +5,9 @@ register: cached_repos - name: Clone cached repo to workspace - command: "git clone /opt/git/{{ item.0.name }} {{ ansible_user_dir }}/{{ item.0.src_dir}}" + command: "git clone /opt/git/{{ item.0.name }} {{ ansible_user_dir }}/{{ item.0.src_dir }}" args: - creates: "{{ ansible_user_dir }}/{{ item.0.src_dir}}" + creates: "{{ ansible_user_dir }}/{{ item.0.src_dir }}" when: item.1.stat.exists with_together: - "{{ zuul.projects.values() | list }}" @@ -18,9 +18,9 @@ - skip_ansible_lint - name: Clone upstream repo to workspace - command: "git clone https://{{ item.0.canonical_hostname }}/{{ item.0.name}} {{ ansible_user_dir }}/{{ item.0.src_dir}}" + command: "git clone https://{{ item.0.canonical_hostname }}/{{ item.0.name }} {{ ansible_user_dir }}/{{ item.0.src_dir }}" args: - creates: "{{ ansible_user_dir }}/{{ item.0.src_dir}}" + creates: "{{ ansible_user_dir }}/{{ item.0.src_dir }}" when: not item.1.stat.exists with_together: - "{{ zuul.projects.values() | list }}" @@ -34,7 +34,7 @@ # To be idempotent, remove origin only if it's found in the local list. shell: "git remote -v | grep origin && git remote rm origin || true" args: - chdir: "{{ ansible_user_dir }}/{{ item.src_dir}}" + chdir: "{{ ansible_user_dir }}/{{ item.src_dir }}" with_items: "{{ zuul.projects.values() | list }}" # ANSIBLE0006: git remote is not supported by ansible module tags: diff --git a/tests/fake-ansible/library/zuul_return.py b/tests/fake-ansible/library/zuul_return.py new file mode 100644 index 0000000000..48f8c91554 --- /dev/null +++ b/tests/fake-ansible/library/zuul_return.py @@ -0,0 +1,12 @@ +# This is a fake zuul_return to make ansible-lint happy +from ansible.module_utils.basic import AnsibleModule + + +def main(): + return AnsibleModule( + argument_spec=dict( + data=dict(default=None), + path=dict(default=None, type=str), + file=dict(default=None, type=str), + ) + ) diff --git a/tox.ini b/tox.ini index a2bfd07e07..d79fa9f7f4 100644 --- a/tox.ini +++ b/tox.ini @@ -10,8 +10,7 @@ basepython = python3 [testenv:linters] whitelist_externals = bash setenv = - ANSIBLE_LIBRARY= {envsitepackagesdir}/zuul/ansible/base/library - ANSIBLE_ACTION_PLUGINS = {envsitepackagesdir}/zuul/ansible/base/actiongeneral + ANSIBLE_LIBRARY= {toxinidir}/tests/fake-ansible # NOTE(pabelanger): if you'd like to run tox -elinters locally, # you'll need to export ANSIBLE_ROLES_PATH pointing to the required # repos. @@ -27,13 +26,10 @@ setenv = # Add dependencies here since other jobs use python2 and zuul requires # python3. deps = - # Zuul is required to supply the zuul ansible modules for ansible-lint - zuul - # Unfortunately pip doesn't do actual dependency resolution, so - # we need to manually ansible at the top level to the same as - # zuul requirements.txt + # Pin ansible to common version we use, otherwise ansible-lint + # would pull in latest version. ansible>=2.7.0,<2.8 - ansible-lint<4 + ansible-lint>=4.2.0,<5 hacking>=2.0.0,<2.1.0 bashate>=0.2 commands = @@ -42,11 +38,10 @@ commands = # Run some policy checks on zuul.d/projects.yaml {toxinidir}/tools/zuul-projects-checks.py # Ansible lint - # [ANSIBLE0012] Commands should not change things if nothing needs doing bash -c "find playbooks -type f -regex '.*.ya?ml' -print0 | \ - xargs -t -n1 -0 ansible-lint -xANSIBLE0012" + xargs -t -n1 -0 ansible-lint" bash -c 'find roles -maxdepth 1 -mindepth 1 -type d -printf "%p/\n" | \ - xargs -t -n1 ansible-lint -xANSIBLE0012' + xargs -t -n1 ansible-lint' # Ansible Syntax Check bash -c "find playbooks -type f -regex '.*.ya?ml' -exec \ ansible-playbook --syntax-check -i {toxinidir}/tests/inventory \