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

jfroche and others added 15 commits September 10, 2025 13:58
These overlay packages will be removed once the extensions are updated
to use the new `buildPgrxExtension` function.
The previously used version was failing to build:

/build/source/src/common/get_check_data.c: In function 'pgr_SPI_getText':
/build/source/src/common/get_check_data.c:307:28: error: passing argument 1 of 'DatumGetCString' makes integer from pointer without a cast [-Wint-conversion]
  307 |     return DatumGetCString(SPI_getvalue(*tuple, *tupdesc, info.colNumber));
      |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                            |
      |                            char *
In file included from /build/source/include/c_common/postgres_connection.h:29,
                 from /build/source/src/common/get_check_data.c:27:
/nix/store/nn6vpjqlsxxmynwcrsib9agb3hpr5cqj-postgresql-17.4/include/server/postgres.h:335:23: note: expected 'Datum' {aka 'long unsigned int'} but argument is of type 'char *'
  335 | DatumGetCString(Datum X)
      |                 ~~~~~~^
make[2]: *** [src/common/CMakeFiles/common.dir/build.make:149: src/common/CMakeFiles/common.dir/get_check_data.c.o] Error 1
We cannot use nodejs.libv8 as it is too new for plv8 3.1.
We will be able to use it with plv8 3.2.
Backport upstream commit to remove the deprecated darwin framework: NixOS/nixpkgs#398707
dbmate 2.27 is now using a varchar for the version column in the
schema_migrations table.

See amacneil/dbmate#641
samrose and others added 11 commits September 10, 2025 14:39
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`
And use docker to run tests
Move ubuntu docker image to its own package.
Create one test for all system modules.
@jfroche jfroche force-pushed the feat/ansible-testing branch from 8fac60d to b3b0a55 Compare September 12, 2025 11:27
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