I am trying to get the number of hosts of a specific group.
Imagine an inventory file, for example:
[maingroup] server-[01:05]
Now in my play I would like to get the number of hosts that are part of the maingroup , which in this case will be 5 , and save this in a variable that should be used in the template in one of the tasks in the book book.
At the moment, I am setting a variable manually, which is far from ideal.
vars: HOST_COUNT: 5
ansible ansible-playbook
Forivin
source share