-
-
Notifications
You must be signed in to change notification settings - Fork 212
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
caf110d to
a79867e
Compare
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`
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
| - name: Install nix | ||
| uses: cachix/install-nix-action@v31 | ||
| with: | ||
| install_url: https://releases.nixos.org/nix/nix-2.31.2/install |
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.
AIUI, @samrose wants us to use Nix 2.29.x for now for $reasons
| - hosts: localhost | ||
| tasks: | ||
| - name: Install dependencies | ||
| apt: |
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.
| apt: | |
| ansible.builtin.apt: |
| apt: | ||
| pkg: | ||
| - build-essential | ||
| update_cache: yes |
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.
| update_cache: yes | |
| update_cache: true |
| pkg: | ||
| - build-essential | ||
| update_cache: yes | ||
| - import_tasks: ../tasks/setup-nginx.yml |
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.
| - import_tasks: ../tasks/setup-nginx.yml | |
| - ansible.builtin.import_tasks: | |
| file: ../tasks/setup-nginx.yml |
| service: | ||
| name: nginx | ||
| state: started | ||
| enabled: yes |
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.
| service: | |
| name: nginx | |
| state: started | |
| enabled: yes | |
| ansible.builtin.service: | |
| enabled: true | |
| name: 'nginx' | |
| state: 'started' |
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