Dynamic groups based on ip range in Ansible groups -


how create variable group based on ip address-range in ansible inventory groups ? have 2 groups of servers in different location. want create groups every time playbook playbook run on updated list of servers. groups based on distribution, prod, dev, test, qa ,dr in host inventory.

thanks in advance

you can scan hosts @ beginning , group them how want, e.g. network:

- hosts:   tasks:     - group_by: key=network_{{ ansible_default_ipv4.network }} 

this create many groups names network_<network> many different networks have. keep in mind need gather facts hosts, depending on count of hosts , speed of connections can require significant time. facts caching speed things, anyway...

if manage inventory file hand, consider manually specifying regional groups well.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -