lint: bumping to latest versions

- run `pre-commit autoupdate` and fixed new issues
- adopted newer pre-commit config for ansible-lint 4.2.0+
- fixed some reported broken rules
- temporary disabled few rules, just to contain the size of of review,
  planning to drop/fix them in follow-ups.

Change-Id: I807ba4e919527be56c85ec72d0f4c7148f04e994
This commit is contained in:
Sorin Sbarnea 2020-01-05 16:00:10 +00:00 committed by Sagi Shnaidman
parent 0de40307b8
commit 16649df878
18 changed files with 50 additions and 18 deletions

View File

@ -7,7 +7,10 @@ quiet: false
skip_list:
# TODO(ssbarnea): Gradually remove these skips ASAP
- 204 # Lines should be no longer than 160 chars
- 301 # Commands should not change things if nothing needs doing
- 302 # rm used in place of argument state=absent to file module
- 303 # sed used in place of template, replace or lineinfile module
- 306 # Shells that use pipes should set the pipefail option
- 504 # Do not use 'local_action', use 'delegate_to: localhost'
- 601 # Don't compare to literal True/False
- 602 # Don't compare to empty string

View File

@ -1,7 +1,7 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
rev: v2.4.0
hooks:
- id: trailing-whitespace
- id: mixed-line-ending
@ -15,18 +15,24 @@ repos:
- id: check-yaml
files: .*\.(yaml|yml)$
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.18.0
rev: v1.20.0
hooks:
- id: yamllint
files: \.(yaml|yml)$
types: [file, yaml]
entry: yamllint --strict -f parsable
- repo: https://github.com/ansible/ansible-lint
rev: v4.1.1a1
rev: v4.2.0
hooks:
- id: ansible-lint
files: \.(yaml|yml)$
entry: ansible-lint --force-color -v
always_run: true
pass_filenames: false
# do not add file filters here as ansible-lint does not give reliable
# results when called with individual files.
# https://github.com/ansible/ansible-lint/issues/611
verbose: true
# plugins is the standard collection dir for modules
entry: env ANSIBLE_LIBRARY=plugins ansible-lint --force-color -p -v
- repo: https://github.com/openstack-dev/bashate.git
rev: 0.6.0
hooks:

View File

@ -12,3 +12,4 @@
become: true
shell: >
"{{ working_dir }}"/add-provisioning-interface.sh
changed_when: true

View File

@ -70,8 +70,11 @@
- name: get undercloud ip
delegate_to: "{{ virthost }}"
shell: ip route get 1 | awk '{print $NF;exit}'
shell: |
set -euo pipefail
ip route get 1 | awk '{print $NF;exit}'
register: registered_undercloud_ip
changed_when: false
- name: Re-add the virthost to the inventory
add_host:

View File

@ -33,6 +33,7 @@
- name: Map project name to DLRN project name
register: project_name_mapped
shell: >
set -euo pipefail;
source {{ build_repo_dir }}/dlrn-venv/bin/activate;
export PROJECT_NAME=$(echo {{ artg_change.project }} | sed "s|openstack/||");
rdopkg findpkg -s $PROJECT_NAME -l rdoinfo | grep ^name | awk '{print $2}'

View File

@ -41,7 +41,7 @@
{% endif %}
- name: Check if virtualenv is in the system
shell: "{{ python_cmd }} -m virtualenv --version"
command: "{{ python_cmd }} -m virtualenv --version"
args:
warn: false
register: virtualenv_exist
@ -92,6 +92,7 @@
dest: '{{ build_repo_dir }}/DLRN/projects.ini'
- name: Install and update pip
# noqa 403
pip:
name: pip
virtualenv: "{{ build_repo_dir }}/dlrn-venv"
@ -106,6 +107,7 @@
when: not dlrn_pre_installed|bool
- name: Pip install DLRN
# noqa 403
pip:
name: dlrn
virtualenv: "{{ build_repo_dir }}/dlrn-venv"
@ -254,12 +256,12 @@
find {{ build_repo_dir }}/DLRN/data/repos -type f -name '*.rpm' -print0 | xargs -0 cp -t {{ build_repo_dir }}/gating_repo;
- name: Run createrepo on generated rpms
shell: 'createrepo gating_repo'
command: createrepo gating_repo
args:
chdir: '{{ build_repo_dir }}'
- name: Compress the repo
shell: 'tar czf {{ artg_compressed_gating_repo }} gating_repo'
command: 'tar czf {{ artg_compressed_gating_repo }} gating_repo'
args:
chdir: '{{ build_repo_dir }}'
- name: Trigger repo injection for quickstart

View File

@ -21,7 +21,7 @@
copy: "src={{ local_working_dir }}/gating_repo.tar.gz dest=/tmp/gating_repo.tar.gz"
- name: Copy compressed repo to /tmp
shell: cp -f {{ ib_repo_file_path }} /tmp/gating_repo.tar.gz
command: cp -f {{ ib_repo_file_path }} /tmp/gating_repo.tar.gz
when: ib_repo_host is not defined
- include: install_built_repo.yml

View File

@ -1,5 +1,6 @@
---
- name: ensure libguestfs is installed
# noqa 403
yum: name=libguestfs-tools-c state=latest
become: true

View File

@ -1,7 +1,8 @@
---
- name: Set abs path for image
shell: echo "{{ image_to_modify }}"
command: echo "{{ image_to_modify }}"
register: image_to_modify_abs_path
changed_when: false
- name: Create a temp dir for extracting images
command: mktemp -d

View File

@ -120,7 +120,8 @@
- delete
- name: Get output from nodes
shell: openstack stack output show {{ stack_name }} subnode_ip_pairs -c output_value -f value
command: >
openstack stack output show {{ stack_name }} subnode_ip_pairs -c output_value -f value
register: subnode_ips
- name: Add hosts

View File

@ -66,6 +66,7 @@
when: ansible_distribution|lower != 'fedora'
- name: Install packages
# noqa 403
package:
name: "{{ packages_list }}"
state: latest
@ -74,9 +75,10 @@
- include: clone-ci-repos.yml
- name: Set primary public key on all hosts
shell: cat /etc/nodepool/id_rsa.pub
command: cat /etc/nodepool/id_rsa.pub
register: primary_key
when: inventory_hostname == "subnode-0"
changed_when: false
- name: Add primary key
lineinfile:
@ -141,6 +143,7 @@
block:
- name: Update packages
# noqa 403
package:
name: '*'
state: latest

View File

@ -96,8 +96,9 @@
- block:
- name: Get full stack status info in case of failure
shell: openstack stack show "{{ stack_name }}"
command: openstack stack show "{{ stack_name }}"
register: failed_stack
changed_when: false
- name: Show stack status in case of failure
debug: var="failed_stack.stdout"

View File

@ -23,6 +23,7 @@
- name: Install python setuptools (easy_install)
when: easy_install_exists.rc != 0
# noqa 403
package:
state: latest
name:
@ -34,6 +35,7 @@
command: "{{ python_cmd }} -m easy_install pip"
- name: Update pip
# noqa 403
pip:
name: pip
state: latest
@ -41,6 +43,7 @@
become: true
- name: Pip install container-check
# noqa 403
pip:
name: container-check
state: latest

View File

@ -4,6 +4,7 @@
block:
- name: Ensure rpm requirements for ssl and heat template are installed
become: true
# noqa 403
package:
name:
- openssl

View File

@ -183,6 +183,7 @@
quickstart_venv: "{{ lookup('env','OPT_WORKDIR') }}"
block:
- name: Install ansible-lint
# noqa 403
pip:
name: ansible-lint
state: latest

View File

@ -18,6 +18,7 @@
when: release == 'newton'
- name: Install openstack services tempest plugins
# noqa 403
package:
state: latest
name: "{{ item | regex_replace( '^python[0-9]*-(.*)$', python_package_prefix + '-\\1' ) }}"

View File

@ -21,7 +21,7 @@
when: release != 'newton'
- name: Check if virtualenv is in the system
shell: "{{ python_cmd }} -m virtualenv --version"
command: "{{ python_cmd }} -m virtualenv --version"
register: virtualenv_exist
failed_when: false
changed_when: false

View File

@ -35,7 +35,8 @@
shell: find /var/cache/tripleo-quickstart/images/* -mtime +3 -exec rm -rf {} \;
- name: remove tripleo-quickstart /var/oooqvms
shell: rm -rf /var/oooqvms/
command: rm -rf /var/oooqvms/
changed_when: true
- name: remove ansible-role-tripleo-image-build artifacts
shell: >
@ -56,10 +57,11 @@
- name: destroy local libvirt storage, networks and config
become: true
shell: "rm -rf {{ working_dir }}/.config/libvirt"
command: "rm -rf {{ working_dir }}/.config/libvirt"
- name: get user_id for stack user
shell: >
set -euo pipefail;
cat /etc/passwd | grep stack | awk -F ':' '{ print $3 }'
register: user_id
@ -103,10 +105,11 @@
user: name={{ non_root_user }} remove=yes force=yes state=absent
- name: remove stack home dir
shell: rm -Rf {{ item }}
command: rm -Rf {{ item }}
with_items:
- /home/{{ non_root_user }}
- /var/spool/mail/{{ non_root_user }}
changed_when: true
- name: remove files automation files from /root
file: name={{ item }} state=absent