Update work with newer ansible-lint and address some linting issues.

Change-Id: I69bd204407bd53210492a67bb8f90504a480db11
This commit is contained in:
Alex Schultz 2021-02-22 09:55:40 -07:00
parent dc3a577652
commit 063f15ec2a
8 changed files with 26 additions and 35 deletions

6
.ansible-lint Normal file
View File

@ -0,0 +1,6 @@
skip_list: # or 'skip_list' to silence them completely
- command-instead-of-shell # Use shell only when shell functionality is required
- experimental # all rules tagged as experimental
- package-latest # Package installs should not use latest
- role-name # Role name {0} does not match ``^[a-z][a-z0-9_]+$`` pattern

View File

@ -1,24 +0,0 @@
#!/bin/bash
# ANSIBLE0006: Using command rather than module
# we have a few use cases where we need to use curl and rsync
# ANSIBLE0007: Using command rather than an argument to e.g file
# we have a lot of 'rm' command and we should use file module instead
# ANSIBLE0010: Package installs should not use latest.
# Sometimes we need to update some packages.
# ANSIBLE0012: Commands should not change things if nothing needs doing
# ANSIBLE0013: Use Shell only when shell functionality is required
# ANSIBLE0016: Tasks that run when changed should likely be handlers
# this requires refactoring roles, skipping for now
# 405: Package tasks should have retries. Skipping because yum does
# this natively.
# 106: Role name with a -. We're not using galaxy.
SKIPLIST="ANSIBLE0006,ANSIBLE0007,ANSIBLE0010,ANSIBLE0012,ANSIBLE0013,ANSIBLE0016,405,106"
# Lin the role.
ansible-lint -vvv -x $SKIPLIST ./ || lint_error=1
# exit with 1 if we had a least an error or warning.
if [[ -n "$lint_error" ]]; then
exit 1;
fi

View File

@ -1,5 +1,6 @@
galaxy_info:
author: Emilien Macchi
role_name: container-registry
author: tripleo
description: A role to deploy a container registry.
license: Apache 2.0

View File

@ -18,7 +18,9 @@
- name: Converge
become: true
hosts: all
roles:
- role: ansible-role-container-registry
container_registry_deploy_docker: true
container_registry_deploy_docker_distribution: true
tasks:
- include_role:
name: ansible-role-container-registry
vars:
container_registry_deploy_docker: true
container_registry_deploy_docker_distribution: true

View File

@ -21,7 +21,8 @@
- name: Ensure role checks for missing information
hosts: all
tasks:
- set_fact:
- name: Test role failed false
set_fact:
role_failed: false
- name: ensure role fails when credentials missing
@ -32,7 +33,8 @@
vars:
ansible_python_interpreter: "{{ ansible_user_dir }}/test-python/bin/python"
rescue:
- set_fact:
- name: Test role failed true
set_fact:
role_failed: true
- name: assert on missing credentials
@ -156,6 +158,7 @@
file:
path: /tmp/tempimage
state: directory
mode: 0755
- name: create Dockerfile
copy:
@ -163,6 +166,7 @@
FROM scratch
ADD nothing /
dest: /tmp/tempimage/Dockerfile
mode: 0644
- name: Build test image
become: true
@ -170,12 +174,14 @@
cd /tmp/tempimage
touch nothing
docker build -t localhost:5000/test/testimage:v1 .
changed_when: true
register: build
- name: Verify authenticated push works
become: true
shell: |
docker push localhost:5000/test/testimage:v1
changed_when: true
- name: Cleanup
include_role:

View File

@ -66,7 +66,7 @@
path: /etc/systemd/system/docker.service.d/99-unset-mountflags.conf
section: Service
option: MountFlags
value: ""
value: '""'
create: yes
mode: '0644'
register: _cfg_flags

View File

@ -35,9 +35,8 @@ commands =
| xargs flake8 --verbose"
[testenv:ansible-lint]
basepython=python3
commands =
bash ci-scripts/ansible-lint.sh
basepython = python3
commands = ansible-lint
[testenv:linters]
basepython = python3

View File

@ -8,6 +8,7 @@
shell: |-
. {{ ansible_user_dir }}/test-python/bin/activate
molecule test --all
changed_when: true
args:
chdir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}"
executable: /bin/bash