Hello
In order to specify a host as belonging to two groups I wrote an
inventory plugin to solve this issue. The plugin automatically merges /
appends group variables that are lists.
It's still experimental, but it works, and I use it myself of course.
You can find an example of group merging in the test case roster-14.yml.
https://gitlab.com/ansible-kheops/plugins/roster
Regards,
Julien
On 08.10.2020 11:16, javud wrote:
> hey there,
>
> during the last couple of days I was thinking about how to structure
> multiple systems with groups and child-groups [1].
> In my view, maybe there are two ways how to solve it. You can group by
> logical/physical location (all systems on one base-machine), or you
> can differ between the services running on systems (e.g.
> webserver-systems, vm-basis etc.).
>
> Actually this is fine, if you use ansible without DebOps. But actually
> I would like to use DebOps ;) and this leads me to an unexpected
> behavior.
> The possibility to provide groups variables which will be combined
> with host variables are really nice, if you need to specify more
> details host configurations. But the situation, that a host can be
> part of multiple groups and every group can have special configuration
> does not well.
>
> For example:
> HostA is part of GroupA und GroupB. If you specify apt_install
> 'apt_install__group_packages' for both groups in
> 'inventory/groups_vars/', there is no combination and no easy way to
> find out, which 'apt_install__group_packages' are taken. Furthermore
> there is no easy way to determine what are all group_vars, which will
> be are relevant for a hosts, maybe to detect variable-collisions.
>
> 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.
>
> best and thanks for any conversation : )
> javud
>
> [1]
>
https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html#i...