Skip to content

Add ansible-lint and inventory checks to CI - #48

Merged
anfimovdm merged 2 commits into
masterfrom
al-ansible-lint-ci
Oct 27, 2026
Merged

anfimovdm merged 2 commits into
masterfrom
al-ansible-lint-ci

Conversation

@anfimovdm

@anfimovdm anfimovdm commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds CI checks for the Ansible code in this repo. Until now, only commit messages were checked.

Changes

  • .github/workflows/ansible-lint.yml: a new "Ansible Checks" workflow that runs on pull requests and on pushes to master. It has two jobs:
    • ansible-lint: runs ansible-lint at the basic profile. This includes yamllint and a syntax check of every playbook, and the Galaxy dependencies from requirements.yml are installed on the fly.
    • Inventories: parses every inventories/*/ directory with ANSIBLE_INVENTORY_ANY_UNPARSED_IS_FAILED=true. Without that setting, ansible-inventory only warns about a broken source and still exits 0. The job uses --graph, so only group and host names are printed in the CI logs, never variables.
  • .ansible-lint: config. Third-party roles, cron_jobs/, systemd_templates/ and *.tmpl are excluded. var-naming[no-role-prefix] is skipped because role variables are intentionally shared with the inventories.
  • .ansible-lint-ignore: a baseline of 73 existing file/rule pairs, so they show as warnings instead of failures. New code has to pass. To shrink the baseline, fix the issues and delete the matching lines.
  • .yamllint: allows lines up to 160 characters, accepts only true/false as booleans, and uses the settings ansible-lint requires.
  • README.md: how to run the same checks locally. .gitignore: ignores the .ansible/ cache folder.
  • requirements.yml: adds the missing community.rabbitmq collection. The new lint job found this. alts_rabbitmq_server uses rabbitmq_plugin, rabbitmq_user and rabbitmq_vhost from that collection, so on a machine without it preinstalled the role failed.

Notes

  • The baseline is per file and per rule. A file already listed for yaml[truthy] can gain more yes/no values without failing.
  • Six task files have schema errors that are baselined, for example become: yes or a number as an environment value. ansible-lint stops checking those files at that point, so they get no deeper checks until fixed.

Testing

  • ansible-lint on this branch: 0 failures, 206 warnings, all from the baseline.
  • A throwaway task file with an unnamed task, an unnecessary shell and a yes boolean failed on all three rules as expected.
  • All six inventories parse. A deliberately broken hosts.yml exits 1 with the setting and 0 without it.

🤖 Generated with Claude Code

Run ansible-lint (basic profile, includes yamllint and playbook syntax
checks) and parse every inventory on pull requests and master pushes.
Existing violations are baselined in .ansible-lint-ignore so only new
code has to pass.
alts_rabbitmq_server uses rabbitmq_plugin, rabbitmq_user and
rabbitmq_vhost from community.rabbitmq, which was not listed, so the
role failed on machines without the collection preinstalled.
@anfimovdm
anfimovdm merged commit 9842a01 into master Oct 27, 2026
2 of 4 checks passed
@anfimovdm
anfimovdm deleted the al-ansible-lint-ci branch October 27, 2026 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant