python - Dynamic group assignment for ansible playbook -
i'm working on ansible playbook provision redis cluster. have 3 groups playbook looks in, can't figure out how assign nodes group properly.
the problem arises because have dynamic number of nodes. if 2 nodes requested i'd have groups this:
[redis_master] node1 [redis_slave] node2
in case of 3:
[redis_master] node1 [redis_slave] node2 [redis_sentinel] node3
and in case of 4 etc:
[redis_master] node1 node4 [redis_slave] node2 [redis_sentinel] node3
is there paradigm i'm missing here?
i'm not sure understand situation completely. pre-define involved hosts , arrange them in groups. hosts playbook might process, required defined in inventory. hosts processed playbook more or less fixed. mean by:
if x nodes requested ...
i know can use --limit
limit playbook subset of defined hosts. can use param defined in --extra-vars
pick specific group or set of hosts. still need pre-defined in inventory , seems strange (and error prone) me depend groups , therefore roles (redis master, slave etc) on number of involved hosts.
that being said... think inventory scripts might you're looking for. scripts can generate inventory dynamic. think can't pass params can export vars , read them later script.
Comments
Post a Comment