Skip to content

Conversation

@jfroche
Copy link
Collaborator

@jfroche jfroche commented Aug 11, 2025

We are slowly moving ansible code to nix system manager modules.
To speed up the migration, we want to test the ansible code without building the whole AMI and have a fast feedback loop.
We also want to quickly test our changes on system manager modules.

The tests are running docker images with ubuntu using testinfra.

@jfroche jfroche changed the base branch from develop to update-nixpkgs August 11, 2025 12:58
@jfroche jfroche changed the base branch from update-nixpkgs to develop August 11, 2025 12:59
@jfroche jfroche force-pushed the feat/ansible-testing branch from 551892e to e5e1b82 Compare August 11, 2025 16:43
@jfroche jfroche changed the base branch from develop to update-nixpkgs August 11, 2025 16:44
@jfroche jfroche force-pushed the feat/ansible-testing branch 2 times, most recently from 8549d92 to c2bd94d Compare August 19, 2025 18:00
@jfroche jfroche marked this pull request as ready for review August 29, 2025 12:11
@jfroche jfroche requested review from a team as code owners August 29, 2025 12:11
@samrose samrose requested a review from a team as a code owner September 2, 2025 13:27
Comment on lines +2 to +11
- name: Check if nix is installed
ansible.builtin.command: which nix
register: nix_installed
failed_when: nix_installed.rc != 0
ignore_errors: true

- name: Install nix
ansible.builtin.shell: curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install --no-confirm --extra-conf 'substituters = https://cache.nixos.org https://nix-postgres-artifacts.s3.amazonaws.com' --extra-conf 'trusted-public-keys = nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI=% cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY='
when: nix_installed.rc != 0
become: true
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of ignore_errors, why not use a block/rescue

Suggested change
- name: Check if nix is installed
ansible.builtin.command: which nix
register: nix_installed
failed_when: nix_installed.rc != 0
ignore_errors: true
- name: Install nix
ansible.builtin.shell: curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install --no-confirm --extra-conf 'substituters = https://cache.nixos.org https://nix-postgres-artifacts.s3.amazonaws.com' --extra-conf 'trusted-public-keys = nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI=% cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY='
when: nix_installed.rc != 0
become: true
- name: Install nix if needed
block:
- name: Check if nix is installed
ansible.builtin.command: which nix
register: nix_installed
failed_when: nix_installed.rc != 0
rescue:
- name: Install nix
ansible.builtin.shell: curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install --no-confirm --extra-conf 'substituters = https://cache.nixos.org https://nix-postgres-artifacts.s3.amazonaws.com' --extra-conf 'trusted-public-keys = nix-postgres-artifacts:dGZlQOvKcNEjvT7QEAJbcV6b6uk7VF/hWMjhYleiaLI=% cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY='
become: true

@samrose samrose force-pushed the update-nixpkgs branch 2 times, most recently from 6b51806 to a33cf5d Compare September 10, 2025 17:58
@jfroche jfroche force-pushed the feat/ansible-testing branch 2 times, most recently from b3b0a55 to fc77a26 Compare September 12, 2025 11:57
@samrose samrose force-pushed the update-nixpkgs branch 2 times, most recently from 37962e0 to 52722b1 Compare November 18, 2025 15:46
@yvan-sraka yvan-sraka force-pushed the update-nixpkgs branch 5 times, most recently from dc596ec to 758c52d Compare November 25, 2025 17:46
@jfroche jfroche force-pushed the update-nixpkgs branch 2 times, most recently from 778aa93 to 7f7fad9 Compare November 26, 2025 00:28
@yvan-sraka yvan-sraka force-pushed the update-nixpkgs branch 2 times, most recently from 5080bbe to 1504f7b Compare December 1, 2025 10:10
@yvan-sraka yvan-sraka force-pushed the update-nixpkgs branch 10 times, most recently from 38ac05d to 5f30f41 Compare December 9, 2025 18:14
@yvan-sraka yvan-sraka force-pushed the update-nixpkgs branch 5 times, most recently from b48e4c3 to 3df6c4a Compare December 12, 2025 10:07
@samrose samrose force-pushed the update-nixpkgs branch 3 times, most recently from 771718f to 4e32d5b Compare December 17, 2025 19:36
This complements the existing AMI tests in testinfra by providing
a faster feedback loops for Ansible development without requiring a full
VM.

Also as 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.

Docker is used outside of the Nix sandbox for the moment.

You can run the tests using `nix run -L .\#ansible-test`
@jfroche jfroche force-pushed the feat/ansible-testing branch from f478f94 to 8bf8a53 Compare December 29, 2025 17:22
@coderabbitai
Copy link

coderabbitai bot commented Dec 29, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/ansible-testing

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jfroche jfroche force-pushed the feat/ansible-testing branch from 8bf8a53 to 0b687d4 Compare December 29, 2025 17:33
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.

4 participants