public inbox for kdevops@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH v5 00/12] Define Ansible inventory in the Ansible Configuration file
@ 2025-07-24 19:36 Daniel Gomez
  2025-07-24 19:36 ` [PATCH v5 01/12] playbooks: fix playbook name for all hosts plays Daniel Gomez
                   ` (13 more replies)
  0 siblings, 14 replies; 20+ messages in thread
From: Daniel Gomez @ 2025-07-24 19:36 UTC (permalink / raw)
  To: Luis Chamberlain, Chuck Lever; +Cc: kdevops, Daniel Gomez, Daniel Gomez

Following Chuck's proposed changes to make task parallelism configurable
via the Ansible configuration file [1], and the subsequent cleanup
of ansible-playbook calls [2] along with the Python interpreter
improvements [3] to better support distros like NixOS through simplified
global interpreter configuration [4], I considered applying the same
approach to the inventory file. This would further streamline our
Ansible wrapper in the kdevops Makefiles.

Why make this change? By specifying the inventory file (typically
'hosts' file in kdevops) directly in ansible.cfg, we eliminate the
need for repeated -i/--inventory arguments and gain flexibility in
where the inventory file is located. This also supports the broader
sandboxing goal discussed in [5]. Moreover, by including localhost in
the inventory, we can clean up the Makefile wrapper even further by
removing --connection=localhost and -i localhost options, while also
enabling workflows to run directly on the controller node (with some
extra more modifications).

https://lore.kernel.org/kdevops/20240827-ansible-cleanups-v1-0-2828a816de5e@samsung.com/

[1]
Increase default task parallelism
https://lore.kernel.org/kdevops/20250404204827.34941-1-cel@kernel.org/
[2]
[PATCH 2/2] Makefile: Remove "-f 30" command line argument
https://lore.kernel.org/kdevops/20250417172119.3190398-2-cel@kernel.org/

[3]
https://lore.kernel.org/kdevops/20250404-python-interpreter-v1-0-04783b627ce7@samsung.com/

[4]
https://lore.kernel.org/kdevops/kwpt5iizzmryybpg6z3fgs6koak27rjggydfighd42wn7mxqja@2hwvtppppzsk/

[5]
https://lore.kernel.org/kdevops/20240827-ansible-cleanups-v1-0-2828a816de5e@samsung.com/

This series promotes the Ansible inventory file (typically 'hosts'
in kdevops) to the Ansible Configuration file (ansible.cfg). By doing
this, we allow to control the hosts globally rather than in all the
ansible-playbook commands, as well as clean up the ansible-playbook
command.

So, we don't need to define anymore the inventory file in the command.
However, playbooks may still be controlled on which targets the playbook
is run. This is done through the playbook itself and/or through the
ansible-playbook argument --limit. Also notice delegate_to is needed
when the playbook runs and iterates on specific nodes such as baseline
and dev but a specific task needs to be handled back to the controller
node.

As part of the series, the term 'all' to refer to all hosts is redefined
to include the localhost. This removes the need to be explicit with
localhost playbooks runs, as it's now just another target in the
inventory file. This term redefinition requires to change playbooks that
use the term all, either through ansible-playbook command or through
the host: field in the YAML playbook file. For this reason, the term
has been replaced in most cases with 'baseline:dev', which means all
targets in the inventory file in the baseline and dev groups, matching
the 'all' concept in the former configuration 'hosts' file. Except the
bootlinux.yml and guestfs.yml playbooks, all playbooks run either on
localhost or remote targets (the previous 'all' definition). Therefore,
all playbooks have been converted to use 'hosts: baseline:dev'. For
the bootlinux.yml playbook, 'all' is kept and the control of host
execution is done via the --limit argument. It was found that only
the linux-clone-9p target runs the bootlinux playbook in the localhost
while the rest of linux-* targets run the playbook in all the remotes
(baseline:dev). For guestfs.yml, a combination of --limit + delegate_to
is needed for the reason explained above: to iterate on the targets
(baseline:dev) but delegate certain tags to the controller node with
delegate_to.

In addition, in order to help me debug this change, I found it
convenient to print the Makefile target name being run before the
command. This allows to be more explicit in verbose mode (V=1) when a
playbook is run (or any subsequent command in the target). And makes it
easier to discover which target the ansible-playbook command belongs to
when debugging playbook execution. To clarify, V=1 already prints the
command but not the Makefile target. The command output behaviour will
be a bit different as it is today as the command itself will be printed
in one line, instead of multiple.

Series has been tested here:
v1:
https://github.com/linux-kdevops/kdevops/actions/runs/14773869477
v3:
https://github.com/linux-kdevops/kdevops/actions/runs/14846101950
v4:
https://github.com/linux-kdevops/kdevops/actions/runs/16033723055
v5:
https://github.com/linux-kdevops/kdevops/actions/runs/16506085205

Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
---
Changes in v5:
- Rebase on top of main as of 2025-07-24
- Update the new mmtests and stead_state Makefiles accordingly
- Test gitr and nfstest workflows with nfsd enabled
- Test pynfs workflow with iscsi service
- Fix spelling reported by Chuck
- Fix Ansible WARNING when generating ansible.cfg reported by Chuck.
Revert to specify inventory and target. After all, we can't leverage the
inventory in ansible.cfg as it's not generated yet
- Replace hosts field baseline:dev with iscsi in playbooks/iscsi.yml and
do the same for kdc, krb5 and nfsd, smbd playbooks. This also allows to
remove --limit from their ansible-playbook incantations
- Fix duplicate name field in playbooks/nfstest.yml
- Fix workflows that depend on nfsd, iscsi, smbd, kdc, krb5 guests by
introducing a new group "service", and use it for bringup operations and
SSH wait in $KDEVOPS_PROVISIONED_SSH (.provisioned_once_ssh) target.
Reported by Chuck
- Link to v4: https://lore.kernel.org/r/20250702-ansible_cfg_inventory-v4-0-67a54babd404@samsung.com

Changes in v4:
- Add trailers (from Luis)
- Rebase on top of main
- Link to v3: https://lore.kernel.org/r/20250505-ansible_cfg_inventory-v3-0-a153d93c35c4@samsung.com

Changes in v3:
- Fix LIMIT_HOSTS. When HOSTS="host1" was used, the --limit replacement
did not work anymore because of the quotes where not needed when using
long form arguments
- Fix bootlinux-local limit in linux target.
- Replace all:!localhost with baseline:dev as suggested by Luis. This
allows to include localhost as part of the baseline and/or dev groups
for baremetal workflows
- Allow to configure the ansible.cfg location. This requires to export
the ANSIBLE_CONFIG. This also enables sandboxing
- Fix debug mode when ansible.cfg is created (command was not printed
because of double @)
- Add back KDEVOPS_HOSTS as cli option. KDEVOPS_HOSTS was not part of
the cli before but it was allowed to be overwritten at command line
time. This allows to be explicit and keeps backwards compatibility with
the variable
- Extend ANSIBLE_CFG_FILE help as per Chuck's suggestion
- Move ANSIBLE_CFG_FILE location in Kconfig and place it after
SET_BY_CLI options
- Remove crash_watchdog.py inventory arguments (Reported by Luis)
- Remove inventory arguments from docs, READMEs and remaining Makefiles
- Move ueh_hosts hunk to fix undefined variable in patch "gen_hosts:
templates: add localhost to all hosts"
- Rename CONFIG_KDEVOPS_ANSIBLE_INVENTORY_FILE to CONFIG_ANSIBLE_CFG_INVENTORY
in scripts/lib.sh and kconfigs/Kconfig.ansible_provisioning
- Update cover letter reasoning and commit messages for better clarity
- Link to v2: https://lore.kernel.org/r/20250502-ansible_cfg_inventory-v2-0-d3c19ff4aa6e@samsung.com

Changes in v2:
- Update ANSIBLE_CFG_INVENTORY help description as per Chuck suggestion
- Add docs/kdevops-ansible-configuration.md for extensive module
documentation
- Include fix to avoid generating always the ansible.cfg and hosts
files. Reported by Chuck
The same commit change also includes support to change the ansible.cfg
path.
- Link to v1: https://lore.kernel.org/r/20250501-ansible_cfg_inventory-v1-0-c568bbaa3502@samsung.com

---
Daniel Gomez (12):
      playbooks: fix playbook name for all hosts plays
      playbooks: fix playbook name for localhost plays
      Makefile: use long form of limit argument for clarity
      Makefile: print target when debug
      .github/workflows/fstests.yml: enable make verbosity
      ansible_cfg: add inventory support
      gen_hosts: add service group to inventory templates
      gen_hosts: templates: include localhost in the all group
      Makefile: use inventory from ansible.cfg
      ansible_cfg: add support to change ansible.cfg file location
      docs: ansible_cfg: add documentation
      build.Makefile: fix verbosity of clean target

 .github/workflows/fstests.yml                      |  16 ++--
 MAINTAINERS                                        |   2 +-
 Makefile                                           |  41 +++++----
 Makefile.btrfs_progs                               |   4 +-
 Makefile.build_qemu                                |  12 +--
 Makefile.hypervisor-tunings                        |   3 +-
 Makefile.kdevops                                   |  19 ++--
 Makefile.linux-mirror                              |   6 +-
 Makefile.postfix                                   |   3 +-
 docs/kdevops-ansible-configuration.md              | 102 +++++++++++++++++++++
 docs/kdevops-terraform.md                          |   2 +-
 kconfigs/Kconfig.ansible_cfg                       |  46 ++++++++++
 kconfigs/Kconfig.ansible_provisioning              |   8 +-
 playbooks/blktests.yml                             |   3 +-
 playbooks/bootlinux.yml                            |   3 +-
 playbooks/build_qemu.yml                           |   3 +-
 playbooks/common.yml                               |   3 +-
 playbooks/create_data_partition.yml                |   3 +-
 playbooks/cxl.yml                                  |   3 +-
 playbooks/devconfig.yml                            |   3 +-
 playbooks/fstests.yml                              |   6 +-
 playbooks/gen-pci-kconfig.yml                      |   3 +-
 playbooks/gen_hosts.yml                            |   3 +-
 playbooks/gen_nodes.yml                            |   3 +-
 playbooks/gen_tfvars.yml                           |   3 +-
 playbooks/gitr.yml                                 |   3 +-
 playbooks/hypervisor-tuning.yml                    |   3 +-
 playbooks/install-menuconfig-deps.yml              |   3 +-
 playbooks/install_systemd_journal_remote.yml       |   3 +-
 playbooks/install_systemd_timesyncd.yml            |   3 +-
 playbooks/install_terraform.yml                    |   3 +-
 playbooks/install_vagrant_boxes.yml                |   3 +-
 playbooks/iscsi.yml                                |   3 +-
 playbooks/kdc.yml                                  |   3 +-
 playbooks/kdevops_archive.yml                      |   3 +-
 playbooks/krb5.yml                                 |   3 +-
 playbooks/ktls.yml                                 |   3 +-
 playbooks/libvirt_pcie_passthrough.yml             |   3 +-
 playbooks/libvirt_storage_pool_create.yml          |   3 +-
 playbooks/libvirt_user.yml                         |   3 +-
 playbooks/linux-mirror.yml                         |   3 +-
 playbooks/ltp.yml                                  |   3 +-
 playbooks/nfsd.yml                                 |   3 +-
 playbooks/nfstest.yml                              |   3 +-
 playbooks/pkg.yml                                  |   3 +-
 playbooks/postfix_relay_host.yml                   |   3 +-
 playbooks/pynfs.yml                                |   3 +-
 playbooks/reboot-limit.yml                         |   3 +-
 playbooks/roles/ansible_cfg/tasks/main.yml         |   3 +-
 .../roles/ansible_cfg/templates/ansible.cfg.j2     |   1 +
 playbooks/roles/bootlinux/README.md                |  12 +--
 playbooks/roles/common/README.md                   |   2 +-
 playbooks/roles/devconfig/README.md                |   2 +-
 playbooks/roles/gen_hosts/defaults/main.yml        |   1 -
 playbooks/roles/gen_hosts/tasks/main.yml           |  54 +++++------
 playbooks/roles/gen_hosts/templates/blktests.j2    |   1 +
 playbooks/roles/gen_hosts/templates/cxl.j2         |   1 +
 playbooks/roles/gen_hosts/templates/fstests.j2     |  16 ++++
 playbooks/roles/gen_hosts/templates/gitr.j2        |  10 ++
 playbooks/roles/gen_hosts/templates/hosts.j2       |  11 +++
 playbooks/roles/gen_hosts/templates/ltp.j2         |   1 +
 playbooks/roles/gen_hosts/templates/nfstest.j2     |  10 ++
 playbooks/roles/gen_hosts/templates/pynfs.j2       |   8 ++
 playbooks/roles/gen_hosts/templates/selftests.j2   |   1 +
 playbooks/roles/gen_hosts/templates/sysbench.j2    |   1 +
 playbooks/roles/guestfs/tasks/main.yml             |   6 ++
 playbooks/roles/libvirt_user/README.md             |   4 +-
 playbooks/roles/pkg/README.md                      |   2 +-
 playbooks/roles/update_etc_hosts/tasks/main.yml    |   2 +-
 playbooks/rxe.yml                                  |   3 +-
 playbooks/selftests.yml                            |   3 +-
 playbooks/siw.yml                                  |   3 +-
 playbooks/smbd.yml                                 |   3 +-
 playbooks/sysbench.yml                             |   3 +-
 playbooks/terraform.yml                            |   4 +-
 playbooks/update_etc_hosts.yml                     |   3 +-
 playbooks/update_ssh_config_guestfs.yml            |   3 +-
 playbooks/update_ssh_config_vagrant.yml            |   3 +-
 scripts/archive.Makefile                           |   3 +-
 scripts/build.Makefile                             |   2 +-
 scripts/devconfig.Makefile                         |   8 +-
 scripts/dynamic-pci-kconfig.Makefile               |   3 +-
 scripts/firstconfig.Makefile                       |   5 +-
 scripts/gen-hosts.Makefile                         |   1 -
 scripts/guestfs.Makefile                           |  19 ++--
 scripts/install-menuconfig-deps.Makefile           |   3 +-
 scripts/iscsi.Makefile                             |   1 -
 scripts/journal-server.Makefile                    |  23 +++--
 scripts/kotd.Makefile                              |  16 ++--
 scripts/krb5.Makefile                              |   2 -
 scripts/ktls.Makefile                              |   1 -
 scripts/lib.sh                                     |   2 +-
 scripts/nfsd.Makefile                              |   1 -
 scripts/provision.Makefile                         |   5 +-
 scripts/rdma.Makefile                              |   2 -
 scripts/smbd.Makefile                              |   1 -
 scripts/systemd-timesync.Makefile                  |   8 +-
 scripts/terraform.Makefile                         |   6 +-
 scripts/update_etc_hosts.Makefile                  |   2 +-
 scripts/vagrant.Makefile                           |  10 +-
 scripts/workflows/lib/crash.py                     |   4 +-
 workflows/blktests/Makefile                        |  20 ++--
 workflows/common/Makefile                          |   2 +-
 workflows/cxl/Makefile                             |  14 +--
 workflows/demos/reboot-limit/Makefile              |  32 ++++---
 workflows/fstests/Makefile                         |  40 +++++---
 workflows/gitr/Makefile                            |   8 +-
 workflows/linux/Makefile                           |  60 +++++++-----
 workflows/ltp/Makefile                             |   8 +-
 workflows/mmtests/Makefile                         |  12 +--
 workflows/nfstest/Makefile                         |   8 +-
 workflows/pynfs/Makefile                           |  12 +--
 workflows/selftests/Makefile                       |  11 ++-
 workflows/steady_state/Makefile                    |   8 +-
 workflows/sysbench/Makefile                        |  12 +--
 115 files changed, 601 insertions(+), 323 deletions(-)
---
base-commit: df5f66ca52a8dd0794c4c0ea72c1068643a18279
change-id: 20250430-ansible_cfg_inventory-7955944ce8ff

Best regards,
--  
Daniel Gomez <da.gomez@samsung.com>


^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2025-07-28  5:57 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-24 19:36 [PATCH v5 00/12] Define Ansible inventory in the Ansible Configuration file Daniel Gomez
2025-07-24 19:36 ` [PATCH v5 01/12] playbooks: fix playbook name for all hosts plays Daniel Gomez
2025-07-24 19:36 ` [PATCH v5 02/12] playbooks: fix playbook name for localhost plays Daniel Gomez
2025-07-24 19:36 ` [PATCH v5 03/12] Makefile: use long form of limit argument for clarity Daniel Gomez
2025-07-24 19:36 ` [PATCH v5 04/12] Makefile: print target when debug Daniel Gomez
2025-07-24 19:36 ` [PATCH v5 05/12] .github/workflows/fstests.yml: enable make verbosity Daniel Gomez
2025-07-24 19:36 ` [PATCH v5 06/12] ansible_cfg: add inventory support Daniel Gomez
2025-07-24 19:36 ` [PATCH v5 07/12] gen_hosts: add service group to inventory templates Daniel Gomez
2025-07-24 19:51   ` Luis Chamberlain
2025-07-25  8:13     ` Daniel Gomez
2025-07-24 20:02   ` Chuck Lever
2025-07-25  8:36     ` Daniel Gomez
2025-07-25 14:00       ` Chuck Lever
2025-07-24 19:36 ` [PATCH v5 08/12] gen_hosts: templates: include localhost in the all group Daniel Gomez
2025-07-24 19:36 ` [PATCH v5 09/12] Makefile: use inventory from ansible.cfg Daniel Gomez
2025-07-24 19:36 ` [PATCH v5 10/12] ansible_cfg: add support to change ansible.cfg file location Daniel Gomez
2025-07-24 19:36 ` [PATCH v5 11/12] docs: ansible_cfg: add documentation Daniel Gomez
2025-07-24 19:36 ` [PATCH v5 12/12] build.Makefile: fix verbosity of clean target Daniel Gomez
2025-07-25 14:03 ` [PATCH v5 00/12] Define Ansible inventory in the Ansible Configuration file Chuck Lever
2025-07-28  5:57 ` Daniel Gomez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox