diff --git a/.ansible-lint b/.ansible-lint new file mode 100644 index 0000000000..f12cbf4a38 --- /dev/null +++ b/.ansible-lint @@ -0,0 +1,40 @@ +parseable: true +quiet: true +# ANSIBLE0010: Package installs should not use latest +# We often deploy latest pip packages +# +# 204: Lines < 160 +# Things like keys, script lines, etc exceed this. We have good +# taste and only use long lines where appropriate. +# +# 206: {{var}} should have spaces {{ var }} +# This rule seems sane, but it appears there's no way to convince +# ansible-lint perfectly good things that are *not* ansible (like +# exim configs) in YAML shouldn't have to follow this rule. See +# https://github.com/ansible/ansible-lint/issues/534; might be able +# to turn on if fixed. +# +# 306: shells with pipes should use pipefail +# This requires running the shell as /bin/bash. There is a small +# possibility to hide errors, but we can rely on +# developers to decide when to explicitly check for failures. +# +# 503: tasks that run when "changed" should likely be handlers +# We can trust reviewers to decide if something should be a +# generic handler or not. +skip_list: + - ANSIBLE0004 + - ANSIBLE0006 + - ANSIBLE0007 + - ANSIBLE0010 + - ANSIBLE0011 + - ANSIBLE0012 + - ANSIBLE0013 + - ANSIBLE0015 + - '204' + - '206' + - '304' + - '306' + - '503' +use_default_rules: true +verbosity: 1 diff --git a/playbooks/periodic/goaccess.yaml b/playbooks/periodic/goaccess.yaml index ade92439ae..1be131cef6 100644 --- a/playbooks/periodic/goaccess.yaml +++ b/playbooks/periodic/goaccess.yaml @@ -60,10 +60,18 @@ executable: /bin/bash # Not using normal zuul job roles as static.opendev.org is not a # test node with all the normal bits in place. - # TODO: should this be an artifact instead? - name: Collect log output synchronize: dest: "{{ zuul.executor.log_root }}/{{ goaccess_site }}_goaccess_report.html" mode: pull src: "/home/zuul/{{ goaccess_site }}_goaccess_report.html" verify_host: true + - name: Return goaccess artifact to Zuul + zuul_return: + data: + zuul: + artifacts: + - name: "Goaccess report" + url: "{{ goaccess_site }}_goaccess_report.html" + metadata: + type: html_report diff --git a/tools/fake-ansible/library/zuul_return.py b/tools/fake-ansible/library/zuul_return.py new file mode 100644 index 0000000000..e1542c5f33 --- /dev/null +++ b/tools/fake-ansible/library/zuul_return.py @@ -0,0 +1,11 @@ +# This is a fake zuul_return to make ansible-lint happy +from ansible.module_utils.basic import AnsibleModule + +def main(): + module = 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 0178429ba9..bfd7bbecf6 100644 --- a/tox.ini +++ b/tox.ini @@ -11,6 +11,8 @@ deps = -r{toxinidir}/test-requirements.txt [testenv:linters] whitelist_externals = bash +setenv = + ANSIBLE_LIBRARY= {toxinidir}/tools/fake-ansible/library commands = flake8 {toxinidir}/tools/run-bashate.sh @@ -21,34 +23,7 @@ commands = # parses, but doesn't do anything. bash -c "ANSIBLE_INVENTORY_PLUGINS=./playbooks/roles/install-ansible/files/inventory_plugins ansible -i ./inventory/openstack.yaml not_a_host -a 'true'" python3 -m unittest playbooks/roles/install-ansible/files/inventory_plugins/test_yamlgroup.py - # Ansible Lint Check - # - # ANSIBLE0010: Package installs should not use latest - # We often deploy latest pip packages - # - # 204: Lines < 160 - # Things like keys, script lines, etc exceed this. We have good - # taste and only use long lines where appropriate. - # - # 206: {{var}} should have spaces {{ var }} - # This rule seems sane, but it appears there's no way to convince - # ansible-lint perfectly good things that are *not* ansible (like - # exim configs) in YAML shouldn't have to follow this rule. See - # https://github.com/ansible/ansible-lint/issues/534; might be able - # to turn on if fixed. - # - # 306: shells with pipes should use pipefail - # This requires running the shell as /bin/bash. There is a small - # possibility to hide errors, but we can rely on - # developers to decide when to explicitly check for failures. - # - # 503: tasks that run when "changed" should likely be handlers - # We can trust reviewers to decide if something should be a - # generic handler or not. - bash -c "find roles playbooks -type f -regex '.*.y[a]?ml' -print0 | xargs -t -n1 -0 \ - ansible-lint -x ANSIBLE0004 -x ANSIBLE0006 -x ANSIBLE0007 -x ANSIBLE0010 \ - -x ANSIBLE0011 -x ANSIBLE0012 -x ANSIBLE0013 -x ANSIBLE0015 \ - -x 204 -x 206 -x 304 -x 306 -x 503" + ansible-lint playbooks roles [testenv:venv] commands = {posargs}