Skip to content

Commit

Permalink
Fix: Update shellcheck ansible role
Browse files Browse the repository at this point in the history
Update molecule test formats and update the role to build with
latest version of ansible. Fix ansible lint errors and warnings.

Update tox and pre-commit dependencies to build with latest versions
of ansible and molecule.

Signed-off-by: Anil Belur <[email protected]>
Change-Id: I5951bf442e54726845f1b886b27f656c97b9948d
  • Loading branch information
askb committed Feb 11, 2024
1 parent ed2fb0e commit c16de7c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 19 deletions.
4 changes: 1 addition & 3 deletions .yamllint
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ rules:
max-spaces-inside: 1
level: error
line-length: disable
# NOTE(retr0h): Templates no longer fail this lint rule.
# Uncomment if running old Molecule templates.
# truthy: disable
truthy: disable

ignore: |
.tox/
6 changes: 2 additions & 4 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ dependency:
name: galaxy
driver:
name: docker
lint: |
set -e
yamllint .
ansible-lint tasks/*.yml
platforms:
- name: centos7
image: centos:7
Expand All @@ -16,6 +12,8 @@ platforms:
image: ubuntu:18.04
- name: ubuntu2004
image: ubuntu:20.04
- name: ubuntu2204
image: ubuntu:22.04
provisioner:
name: ansible
scenario:
Expand Down
7 changes: 4 additions & 3 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
---
- name: Fetch ShellCheck
get_url:
ansible.builtin.get_url:
url: 'https://github.com/koalaman/shellcheck/releases/download/{{ shellcheck_version }}/shellcheck-{{ shellcheck_version }}.linux.x86_64.tar.xz'
dest: /tmp/shellcheck.tar.xz
checksum: '{{ shellcheck_checksum }}'
mode: 0644
become: true

- name: Unpack ShellCheck
unarchive:
ansible.builtin.unarchive:
src: /tmp/shellcheck.tar.xz
dest: /tmp
list_files: true
remote_src: true
become: true

- name: Install ShellCheck to /usr/local/bin/shellcheck
copy:
ansible.builtin.copy:
src: '/tmp/shellcheck-{{ shellcheck_version }}/shellcheck'
dest: /usr/local/bin/shellcheck
mode: 0755
Expand Down
28 changes: 19 additions & 9 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,28 @@
minversion = 1.6
envlist =
molecule,
pre-commit
pre-commit,
lint
skipsdist=true

[testenv:molecule]
basepython = python3
deps =
ansible~=2.9.6
ansible-lint~=4.2.0
ansible
docker
molecule
yamllint
molecule~=3.0.8
molecule[docker]
pytest~=5.4.0
molecule-docker
passenv = *
commands =
./molecule.sh
allowlist_externals =
./molecule.sh

[testenv:pre-commit]
basepython = python3
allowlist_externals =
/bin/sh
deps = pre-commit
allowlist_externals = /bin/sh
passenv = HOME
commands =
pre-commit run --all-files --show-diff-on-failure
/bin/sh -c 'if ! git config --get user.name > /dev/null; then \
Expand All @@ -45,3 +43,15 @@ commands =
/bin/sh -c "if [ -f .git/REMOVE_USEREMAIL ]; then \
git config --global --unset user.email; \
rm -f .git/REMOVE_USEREMAIL; fi"

[testenv:lint]
basepython = python310
deps =
ansible-lint
yamllint
commands =
/bin/bash -c "ansible-lint tasks/*.yml"
yamllint .
allowlist_externals =
/bin/bash
yamllint

0 comments on commit c16de7c

Please sign in to comment.