-
-
Notifications
You must be signed in to change notification settings - Fork 213
feat: add ansible task testing infrastructure based on Docker and pytest #1882
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
a79867e to
7fad1eb
Compare
hunleyd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mostly ansible-lint fixups
7fad1eb to
dc23e8f
Compare
| ansible.builtin.user: | ||
| name: 'nginx' | ||
| state: 'present' | ||
| name: nginx |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quote dropping is intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably not is my guess. maybe needs rebase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran ansible-lint --fix and it automatically removes unnecessary quotes to follow YAML best practices for improved readability (https://docs.ansible.com/projects/lint/rules/yaml/#yaml).
|
@hunleyd I realize it may not yet be documented very well, but in order for you to get 1:1 parity with the linter in this PR, you would want to:
By doing it this way, you'll then use the same ansible lint version in this PR, and the same configuration. This helps avoid the "works on my machine" problem that may come up if we install ansible lint and tools from brew install etc. We can get 1:1 with what other developers are doing with |
This complements the existing AMI tests in testinfra by providing a faster feedback loops for Ansible development without requiring a full VM. We are also using testinfra to validate that the Ansible tasks have the desired effect. It is based on Docker, it can be run locally (e.g. macOS) or in CI. Note that this approach is not intended to replace the AMI tests, but rather to provide a more efficient way to test Ansible tasks during development. You can run the tests using `nix run -L .\#ansible-test`
Configure pre-commit hook to run ansible-lint on test playbooks and their dependencies. Since test playbooks include tasks from existing task files, ansible-lint automatically validates those dependencies as well.
dc23e8f to
bac839f
Compare
|
Also we have pre-commit hook in the dev shell. So if you start the dev shell using The pre-commit hook configuration is defined in |
This complements the existing AMI tests in testinfra by providing a faster feedback loops for Ansible development without requiring a full VM.
We are also using testinfra to validate that the Ansible tasks have the desired effect.
It is based on Docker, it can be run locally (e.g. macOS) or in CI.
Note that this approach is not intended to replace the AMI tests, but rather to provide a more efficient way to test Ansible tasks during development.
You can run the tests using
nix run -L .\#ansible-test