Repository navigation
Add ansible-lint and inventory checks to CI - #48
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 tomaster. It has two jobs:ansible-lintat thebasicprofile. This includes yamllint and a syntax check of every playbook, and the Galaxy dependencies fromrequirements.ymlare installed on the fly.inventories/*/directory withANSIBLE_INVENTORY_ANY_UNPARSED_IS_FAILED=true. Without that setting,ansible-inventoryonly 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*.tmplare 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 onlytrue/falseas 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 missingcommunity.rabbitmqcollection. The new lint job found this.alts_rabbitmq_serverusesrabbitmq_plugin,rabbitmq_userandrabbitmq_vhostfrom that collection, so on a machine without it preinstalled the role failed.Notes
yaml[truthy]can gain moreyes/novalues without failing.become: yesor a number as anenvironmentvalue. ansible-lint stops checking those files at that point, so they get no deeper checks until fixed.Testing
ansible-linton this branch: 0 failures, 206 warnings, all from the baseline.shelland ayesboolean failed on all three rules as expected.hosts.ymlexits 1 with the setting and 0 without it.🤖 Generated with Claude Code