lint: pre-commit hook maintenance

Notable change is bumping of ansible-lint so it does proper
playbook/role detection.

Change-Id: I6e3242ee69253894166eb8e79143422495fe35b0
Task: https://tree.taiga.io/project/tripleo-ci-board/task/1374
This commit is contained in:
Sorin Sbarnea 2019-11-26 10:15:11 +00:00
parent b9f753d967
commit a420735759
8 changed files with 32 additions and 15 deletions

View File

@ -1,13 +1,11 @@
---
parseable: true
exclude_paths:
- config/
- releasenotes/
skip_list:
# One two excuses for adding skips: bugs in linter and recent linter bumping
- ANSIBLE0006
- ANSIBLE0012
- ANSIBLE0016
- '204' # [E204] Lines should be no longer than 120 chars
# E602 https://github.com/ansible/ansible-lint/issues/450
- '602' # [E602] Don't compare to empty string
# E405 is too new and we need to enable it in a separate change
- '405' # [E405] Remote package tasks should have a retry
- '701' # [E701] No 'galaxy_info' found

View File

@ -13,7 +13,7 @@ repos:
- texttable
- pyyaml
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.1.0
rev: v2.4.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
@ -24,30 +24,31 @@ repos:
- id: check-symlinks
- id: debug-statements
- id: flake8
additional_dependencies:
- hacking<1.2.0,>=1.1.0
- id: check-yaml
files: .*\.(yaml|yml)$
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.14.0
rev: v1.20.0
hooks:
- id: yamllint
files: \.(yaml|yml)$
types: [file, yaml]
entry: yamllint --strict -f parsable
# Revert to upstream branch fix for bug below is released (tagged)
# https://github.com/ansible/ansible-lint/issues/595
- repo: https://github.com/ansible/ansible-lint.git
rev: 0523c63f193d65313dcd743686d7fb0623a72ee8
rev: v4.2.0
hooks:
- id: ansible-lint
files: \.(yaml|yml)$
entry: env ANSIBLE_LIBRARY=./library 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
entry: env ANSIBLE_LIBRARY=library ansible-lint --force-color -p -v
- repo: https://github.com/openstack-dev/bashate.git
rev: 0.6.0
hooks:
- id: bashate
entry: bashate --error . --verbose --ignore=E006,E040
entry: bashate --error . --ignore=E006,E040
# Run bashate check for all bash scripts
# Ignores the following rules:
# E006: Line longer than 79 columns (as many scripts use jinja

View File

@ -69,6 +69,7 @@
# Get the expected checksum for the remote image.
- name: Get image expected checksum
# noqa: 303
command: >
curl -skfL {{ image.url }}.md5
register: md5_expected
@ -109,6 +110,7 @@
# use an ansible `until` loop, combined with curl's `-C-` option
# to continue interrupted downloads.
- name: Get image
# noqa: 303
command: >
curl -skfL -C- -o _{{ image.name }}.{{ image.type }} {{ image.url }}
args:
@ -202,3 +204,4 @@
{% if not image_cache_dir_cleanup|bool %}
-mtime +{{ image_cache_expire_days|int - 1 }} {% endif %} |
xargs --no-run-if-empty -t rm -rf
changed_when: true

View File

@ -31,11 +31,13 @@
qemu-img create -f qcow2 -o preallocation=off
'{{ working_dir }}/undercloud-resized.qcow2'
'80G'
changed_when: true
- name: Test libguestfs
shell: libguestfs-test-tool > {{ working_dir }}/libguestfs-test.log 2>&1;
ignore_errors: true
register: libguestfs
changed_when: false
- name: Compose libguestfs env vars
template:
@ -52,11 +54,13 @@
2>&1 | tee -a {{ working_dir }}/virt-resize.log
register: result
no_log: result is success
changed_when: true
- name: Rename resized image to original name
command: >
mv -f '{{ working_dir }}/undercloud-resized.qcow2'
'{{ working_dir }}/undercloud.qcow2'
changed_when: true
- name: Calculate password hash
no_log: true
@ -66,6 +70,7 @@
args:
executable: /usr/bin/python
register: hash
changed_when: false
- name: Copy generated password to file
copy:
@ -80,6 +85,7 @@
--root-password file:"{{ working_dir }}/pwtemp"
>> {{ working_dir }}/virt-customize.log 2>&1
register: root_password
changed_when: true
- name: Remove root password file
file:
@ -93,6 +99,7 @@
--run-command 'xfs_growfs /'
>> {{ working_dir }}/virt-customize.log 2>&1
when: resize_qcow_filesystem|default(true)|bool
changed_when: true
- name: Disable cloud-init
shell: >
@ -100,6 +107,7 @@
virt-customize -v -a {{ working_dir }}/undercloud.qcow2
--run-command "grubby --update-kernel=ALL --args=\"cloud-init=disabled\""
>> {{ working_dir }}/virt-customize.log 2>&1
changed_when: true
- name: Inject ssh public key into the image
shell: >
@ -112,6 +120,7 @@
--run-command 'chmod 0600 /root/.ssh/authorized_keys'
--selinux-relabel
>> {{ working_dir }}/virt-customize.log 2>&1
changed_when: true
# note upstream images may be in use and have the zuul user created
- name: Add zuul user to the image
@ -131,6 +140,7 @@
# we should NOT create symlinks between python->python3
# see https://www.python.org/dev/peps/pep-0394/
# --run-command 'ln -s /usr/bin/python3 /usr/bin/python'
changed_when: true
- name: Install and enable qemu-guest-agent
shell: >
@ -139,6 +149,7 @@
--run-command 'yum install -y qemu-guest-agent'
--run-command 'systemctl enable qemu-guest-agent'
>> {{ working_dir }}/virt-customize.log 2>&1
changed_when: true
- debug:
msg: "Add basic packages we need to the image"

View File

@ -46,3 +46,4 @@
echo "append domain-name-servers {{ custom_nameserver }};" >> /etc/dhcp/dhclient.conf
{% endif %}
become: true
changed_when: true

View File

@ -7,3 +7,4 @@
become: true
register: result
no_log: result.rc == 0
changed_when: true

View File

@ -20,6 +20,7 @@
chdir: '{{ local_working_dir }}'
register: registered_nodes_output
no_log: true
changed_when: false
- name: set_fact for filtered openstack inventory nodes by types
set_fact:

View File

@ -31,6 +31,7 @@
command: id -u {{ non_root_user }}
register: non_root_user_uid
delegate_to: virthost
changed_when: false
- name: set fact on non_root_user_uid
set_fact: