Update ansible-lint and add fake zuul_return
- Use zuul_return fake module to make ansible lint happy, this allows to remove Zuul import. - While ansible-lint 4.2.0 is now able to detect playbooks/roles, this is broken, so don't use it - move its config out of tox.ini so it can be used by any tools, or without tox Change-Id: Ie8935f47db855647e19ae091044e5ac1871f1551 Co-Authored-By: Sorin Sbarnea <ssbarnea@redhat.com> Co-Authored-By: Andreas Jaeger <aj@suse.com>
This commit is contained in:
parent
13ade443d5
commit
0326363e48
12
.ansible-lint
Normal file
12
.ansible-lint
Normal file
@ -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
|
@ -2,7 +2,7 @@
|
|||||||
tasks:
|
tasks:
|
||||||
|
|
||||||
- name: Run propose_update.sh script
|
- 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:
|
args:
|
||||||
chdir: "src/{{ zuul.project.canonical_name }}"
|
chdir: "src/{{ zuul.project.canonical_name }}"
|
||||||
environment: '{{ zuul | zuul_legacy_vars }}'
|
environment: '{{ zuul | zuul_legacy_vars }}'
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
name: upload-afs-synchronize
|
name: upload-afs-synchronize
|
||||||
vars:
|
vars:
|
||||||
afs_source: "{{ zuul.executor.work_root }}/artifacts/"
|
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
|
- name: Destroy AFS token
|
||||||
include_role:
|
include_role:
|
||||||
name: destroy-afs-token
|
name: destroy-afs-token
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
name: upload-afs-synchronize
|
name: upload-afs-synchronize
|
||||||
vars:
|
vars:
|
||||||
afs_source: "{{ zuul.executor.work_root }}/artifacts/"
|
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
|
- name: Destroy AFS token
|
||||||
include_role:
|
include_role:
|
||||||
name: destroy-afs-token
|
name: destroy-afs-token
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Run upstream_translation_update.sh script
|
- 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:
|
args:
|
||||||
chdir: "{{ zuul.project.src_dir }}"
|
chdir: "{{ zuul.project.src_dir }}"
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
- name: Create log directories
|
- name: Create log directories
|
||||||
file:
|
file:
|
||||||
path: "{{zuul_logserver_root}}/{{ zuul_log_path }}"
|
path: "{{ zuul_logserver_root }}/{{ zuul_log_path }}"
|
||||||
state: directory
|
state: directory
|
||||||
recurse: yes
|
recurse: yes
|
||||||
mode: 0775
|
mode: 0775
|
||||||
@ -26,7 +26,7 @@
|
|||||||
- name: Upload logs to log server
|
- name: Upload logs to log server
|
||||||
synchronize:
|
synchronize:
|
||||||
src: "{{ zuul.executor.log_root }}/"
|
src: "{{ zuul.executor.log_root }}/"
|
||||||
dest: "{{zuul_logserver_root}}/{{ zuul_log_path }}/"
|
dest: "{{ zuul_logserver_root }}/{{ zuul_log_path }}/"
|
||||||
rsync_opts:
|
rsync_opts:
|
||||||
- "--exclude=job-output.txt"
|
- "--exclude=job-output.txt"
|
||||||
- "--exclude=job-output.json"
|
- "--exclude=job-output.json"
|
||||||
@ -44,7 +44,7 @@
|
|||||||
- name: Upload console log and json output
|
- name: Upload console log and json output
|
||||||
synchronize:
|
synchronize:
|
||||||
src: "{{ zuul.executor.log_root }}/{{ item }}.gz"
|
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
|
verify_host: true
|
||||||
with_items:
|
with_items:
|
||||||
- job-output.txt
|
- job-output.txt
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
register: cached_repos
|
register: cached_repos
|
||||||
|
|
||||||
- name: Clone cached repo to workspace
|
- 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:
|
args:
|
||||||
creates: "{{ ansible_user_dir }}/{{ item.0.src_dir}}"
|
creates: "{{ ansible_user_dir }}/{{ item.0.src_dir }}"
|
||||||
when: item.1.stat.exists
|
when: item.1.stat.exists
|
||||||
with_together:
|
with_together:
|
||||||
- "{{ zuul.projects.values() | list }}"
|
- "{{ zuul.projects.values() | list }}"
|
||||||
@ -18,9 +18,9 @@
|
|||||||
- skip_ansible_lint
|
- skip_ansible_lint
|
||||||
|
|
||||||
- name: Clone upstream repo to workspace
|
- 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:
|
args:
|
||||||
creates: "{{ ansible_user_dir }}/{{ item.0.src_dir}}"
|
creates: "{{ ansible_user_dir }}/{{ item.0.src_dir }}"
|
||||||
when: not item.1.stat.exists
|
when: not item.1.stat.exists
|
||||||
with_together:
|
with_together:
|
||||||
- "{{ zuul.projects.values() | list }}"
|
- "{{ zuul.projects.values() | list }}"
|
||||||
@ -34,7 +34,7 @@
|
|||||||
# To be idempotent, remove origin only if it's found in the local list.
|
# 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"
|
shell: "git remote -v | grep origin && git remote rm origin || true"
|
||||||
args:
|
args:
|
||||||
chdir: "{{ ansible_user_dir }}/{{ item.src_dir}}"
|
chdir: "{{ ansible_user_dir }}/{{ item.src_dir }}"
|
||||||
with_items: "{{ zuul.projects.values() | list }}"
|
with_items: "{{ zuul.projects.values() | list }}"
|
||||||
# ANSIBLE0006: git remote is not supported by ansible module
|
# ANSIBLE0006: git remote is not supported by ansible module
|
||||||
tags:
|
tags:
|
||||||
|
12
tests/fake-ansible/library/zuul_return.py
Normal file
12
tests/fake-ansible/library/zuul_return.py
Normal file
@ -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),
|
||||||
|
)
|
||||||
|
)
|
17
tox.ini
17
tox.ini
@ -10,8 +10,7 @@ basepython = python3
|
|||||||
[testenv:linters]
|
[testenv:linters]
|
||||||
whitelist_externals = bash
|
whitelist_externals = bash
|
||||||
setenv =
|
setenv =
|
||||||
ANSIBLE_LIBRARY= {envsitepackagesdir}/zuul/ansible/base/library
|
ANSIBLE_LIBRARY= {toxinidir}/tests/fake-ansible
|
||||||
ANSIBLE_ACTION_PLUGINS = {envsitepackagesdir}/zuul/ansible/base/actiongeneral
|
|
||||||
# NOTE(pabelanger): if you'd like to run tox -elinters locally,
|
# NOTE(pabelanger): if you'd like to run tox -elinters locally,
|
||||||
# you'll need to export ANSIBLE_ROLES_PATH pointing to the required
|
# you'll need to export ANSIBLE_ROLES_PATH pointing to the required
|
||||||
# repos.
|
# repos.
|
||||||
@ -27,13 +26,10 @@ setenv =
|
|||||||
# Add dependencies here since other jobs use python2 and zuul requires
|
# Add dependencies here since other jobs use python2 and zuul requires
|
||||||
# python3.
|
# python3.
|
||||||
deps =
|
deps =
|
||||||
# Zuul is required to supply the zuul ansible modules for ansible-lint
|
# Pin ansible to common version we use, otherwise ansible-lint
|
||||||
zuul
|
# would pull in latest version.
|
||||||
# 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
|
|
||||||
ansible>=2.7.0,<2.8
|
ansible>=2.7.0,<2.8
|
||||||
ansible-lint<4
|
ansible-lint>=4.2.0,<5
|
||||||
hacking>=2.0.0,<2.1.0
|
hacking>=2.0.0,<2.1.0
|
||||||
bashate>=0.2
|
bashate>=0.2
|
||||||
commands =
|
commands =
|
||||||
@ -42,11 +38,10 @@ commands =
|
|||||||
# Run some policy checks on zuul.d/projects.yaml
|
# Run some policy checks on zuul.d/projects.yaml
|
||||||
{toxinidir}/tools/zuul-projects-checks.py
|
{toxinidir}/tools/zuul-projects-checks.py
|
||||||
# Ansible lint
|
# Ansible lint
|
||||||
# [ANSIBLE0012] Commands should not change things if nothing needs doing
|
|
||||||
bash -c "find playbooks -type f -regex '.*.ya?ml' -print0 | \
|
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" | \
|
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
|
# Ansible Syntax Check
|
||||||
bash -c "find playbooks -type f -regex '.*.ya?ml' -exec \
|
bash -c "find playbooks -type f -regex '.*.ya?ml' -exec \
|
||||||
ansible-playbook --syntax-check -i {toxinidir}/tests/inventory \
|
ansible-playbook --syntax-check -i {toxinidir}/tests/inventory \
|
||||||
|
Loading…
Reference in New Issue
Block a user