Skip to content

Add tests for ansible and system manager modules#1746

Closed
jfroche wants to merge 64 commits intodevelopfrom
feat/ansible-testing
Closed

Add tests for ansible and system manager modules#1746
jfroche wants to merge 64 commits intodevelopfrom
feat/ansible-testing

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 and others added 11 commits December 17, 2025 14:36
Move pgrouting.nix to pgrouting/default.nix and groonga package to
pgroonga/groonga.nix. Update imports and fix relative paths for versions.json
and patch files.
Replace inline bash script generation with writeShellScriptBin for rustc
wrapper that filters empty postmaster_stub.rs arguments. Apply wrapper only
for pgrx < 0.12 since issue was fixed upstream in pgrx#1435 and pgrx#1441.
Move nixpkgs-oldstable import to a let binding to avoid importing it
three times...
Remove supabase-groonga from global flake packages and import it locally
in pgroonga extension instead. Other components access groonga via
pgroonga.passthru.groonga since groonga is only used by pgroonga.
The supabase-groonga package was moved to pgroonga extension in commit 1f0ed1f,
but Ansible was still trying to install it separately causing build failures.
This reverts commit 55474686405394826ad07a032cbcf0e36a924554.
This reverts commit cfa9bcb92219f391469ae743f95c8856b0a99561.
Remove references to darwin.apple_sdk.frameworks.{IOKit,CoreFoundation}
which have been deprecated in nixpkgs. Disable CGO to avoid Darwin
framework dependencies entirely.
samrose and others added 2 commits December 17, 2025 14:38
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
Contributor

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
Base automatically changed from update-nixpkgs to develop January 16, 2026 00:23
@jfroche
Copy link
Collaborator Author

jfroche commented Jan 29, 2026

Superseded by #1882 and #2010

@jfroche jfroche closed this Jan 29, 2026
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