Skip to content

Conversation

@jfroche
Copy link
Collaborator

@jfroche jfroche commented Oct 31, 2025

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

@jfroche jfroche force-pushed the test/ansible-tasks branch 7 times, most recently from caf110d to a79867e Compare October 31, 2025 17:29
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`
@jfroche jfroche force-pushed the test/ansible-tasks branch from a79867e to 7fad1eb Compare October 31, 2025 17:30
@jfroche jfroche marked this pull request as ready for review October 31, 2025 17:30
@jfroche jfroche requested review from a team as code owners October 31, 2025 17:30
Copy link
Contributor

@hunleyd hunleyd left a 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
Copy link
Contributor

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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
apt:
ansible.builtin.apt:

apt:
pkg:
- build-essential
update_cache: yes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
update_cache: yes
update_cache: true

pkg:
- build-essential
update_cache: yes
- import_tasks: ../tasks/setup-nginx.yml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- import_tasks: ../tasks/setup-nginx.yml
- ansible.builtin.import_tasks:
file: ../tasks/setup-nginx.yml

Comment on lines +11 to +14
service:
name: nginx
state: started
enabled: yes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
service:
name: nginx
state: started
enabled: yes
ansible.builtin.service:
enabled: true
name: 'nginx'
state: 'started'

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.

3 participants