I have written a custom module “filter_prefix” that accepts “host” and “prefixes”.
I have a dictionary that looks like this -
d2 = {‘4.4.4.4’:‘10.0.0.0/8’,‘11.0.0.0/8’, ‘5.5.5.5’:‘10.0.0.0/8’}
In the API script, I have -
hosts = d2.keys()
device_inventory = Inventory(hosts)
pb = Runner(
module_name = ‘filter_prefix’,
module_args = ‘host={{ inventory_hostname }} prefixes= ???’,
transport = local,
inventory = device_inventory)
I would like to be able to pass appropriate ‘value’ to prefixes based on ‘host’ from d2 dictionary. I tried using -
prefixes=“d2[ ‘{{ inventory_hostname }}’ ]” but then it doesn’t expand d2.
I am running ansible version 1.9.2.
Any ideas?
Amit