public inbox for kdevops@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH v3 00/10] Define Ansible inventory in the Ansible Configuration file
@ 2025-05-05 21:24 Daniel Gomez
  2025-05-05 21:24 ` [PATCH v3 01/10] playbooks: fix playbook name for all hosts plays Daniel Gomez
                   ` (10 more replies)
  0 siblings, 11 replies; 18+ messages in thread
From: Daniel Gomez @ 2025-05-05 21:24 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.

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, matchin
the 'all' concept in the former configuration 'hosts' file. Except the
bootlinux.yml playbook, 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).

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

Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
---
TODOs in v3:
- Check crash CI script
- Send baremetal support (a separate RFC will be posted after these
series)
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 (10):
      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: 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

 .github/workflows/fstests.yml                      |  16 ++--
 MAINTAINERS                                        |   2 +-
 Makefile                                           |  45 ++++-----
 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-local.yml                      |   3 +-
 playbooks/bootlinux.yml                            |   3 +-
 playbooks/bringup_guestfs.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                              |   5 +-
 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         |   2 +-
 .../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           |  52 +++++------
 playbooks/roles/gen_hosts/templates/blktests.j2    |   1 +
 playbooks/roles/gen_hosts/templates/cxl.j2         |   1 +
 playbooks/roles/gen_hosts/templates/fstests.j2     |   1 +
 playbooks/roles/gen_hosts/templates/gitr.j2        |   1 +
 playbooks/roles/gen_hosts/templates/hosts.j2       |   2 +
 playbooks/roles/gen_hosts/templates/ltp.j2         |   1 +
 playbooks/roles/gen_hosts/templates/nfstest.j2     |   1 +
 playbooks/roles/gen_hosts/templates/pynfs.j2       |   1 +
 playbooks/roles/gen_hosts/templates/selftests.j2   |   1 +
 playbooks/roles/gen_hosts/templates/sysbench.j2    |   1 +
 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                            |   3 +-
 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/devconfig.Makefile                         |   8 +-
 scripts/dynamic-pci-kconfig.Makefile               |   3 +-
 scripts/firstconfig.Makefile                       |   5 +-
 scripts/gen-hosts.Makefile                         |   1 -
 scripts/guestfs.Makefile                           |  17 ++--
 scripts/install-menuconfig-deps.Makefile           |   3 +-
 scripts/iscsi.Makefile                             |   2 +-
 scripts/journal-server.Makefile                    |  23 +++--
 scripts/kotd.Makefile                              |  16 ++--
 scripts/krb5.Makefile                              |   4 +-
 scripts/ktls.Makefile                              |   1 -
 scripts/lib.sh                                     |   2 +-
 scripts/nfsd.Makefile                              |   2 +-
 scripts/provision.Makefile                         |   5 +-
 scripts/rdma.Makefile                              |   2 -
 scripts/smbd.Makefile                              |   2 +-
 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/nfstest/Makefile                         |   8 +-
 workflows/pynfs/Makefile                           |  12 +--
 workflows/selftests/Makefile                       |  11 ++-
 workflows/sysbench/Makefile                        |  12 +--
 113 files changed, 539 insertions(+), 316 deletions(-)
---
base-commit: c95700c3c029d5c1d74d4b112b70747353a8bbfd
change-id: 20250430-ansible_cfg_inventory-7955944ce8ff

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


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

end of thread, other threads:[~2025-05-17 20:34 UTC | newest]

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

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