On paź 08, javud wrote:
Now I am wondering, what are your 'best practices' to manage
your
groups/group_vars. Are you only using groups_vars for services and never for
locations. But how will you even handle this problem there. What if your
systems are base machine, which are in group [debops_service_libvirtd] and
you want to additionally install libvirt extensions with 'apt_install' and
parallel the same systems are in [debops_service_mount] and you want to
'apt_install' extensions there too.
One possibility is to just use a dynamic inventory script and handle the
variables in that script. You can either write your own or use an existing
implementation. But this might be relatively easier than wrestling with YAML
in the Ansible inventory and merging multiple variables by hand.
If you care only about APT package installation itself, there's a trick in
DebOps you can use to your advantage. All DebOps roles have a special variable
for listing additional packages to install, usually named
'<role>__packages'.
Based on your example, if you want to install some packages on all hosts with
the 'libvirtd' service, you can add them into the role group variables:
---
# ansible/inventory/group_vars/debops_service_libvirtd
libvirtd__packages:
- 'zsh'
- 'tmux'
With this, the additional packages will be installed when you execute the
'libvirtd' role.
-- Maciej