Run per subnet list not per host

Hello,

I need to let Ansible run a playbook that loops through a list of subnets (these can be read from Excel or file)
but then it needs to connect to several different machines. This is completely different then the normal behaviour of looping through a list of devices.
The workflow is:

  • read a list of subnets from a file or Excel, including extra parameters (like switch)
  • then Ansible need to connect to the switch (read from above) and configure the specified subnet
  • then Ansible needs to connect to Infoblox (IPAM) to register the subnet and create a DHCP scope
  • then Ansible needs to add the subnet to Sites/Subnets in Active Directory on the PDC (if possible)
  • then Ansible needs to change a local file on the system and add the subnet to the file
  • then Ansible needs to send an email to notify admin

Is this even possible ?

regards,
Geert

Hello,

I need to let Ansible run a playbook that loops through a list of subnets
(these can be read from Excel or file)
but then it needs to connect to several different machines. This is
completely different then the normal behaviour of looping through a list of
devices.
The workflow is:
- read a list of subnets from a file or Excel, including extra parameters
(like switch)

File yes, Excel no.

- then Ansible need to connect to the switch (read from above) and
configure the specified subnet

Not a problem, you have the add_host module, switch modules and last resort expect module.

- then Ansible needs to connect to Infoblox (IPAM) to register the subnet
and create a DHCP scope

I don't know what Infobox is, but if it has an interface one way or another I would say it doable.

- then Ansible needs to add the subnet to Sites/Subnets in Active Directory
on the PDC (if possible)

I don't use Windows, but I guess it's possible.

- then Ansible needs to change a local file on the system and add the
subnet to the file

No problem with that one, you have templates, lineinfile and blockinfile

- then Ansible needs to send an email to notify admin

You have the mail module for that.

Is this even possible ?

I would say yes, the only uncertainty is the Windows part.

ok, now i got it. The missing link was that i can run a simple playbook on the server host without looping through any inventory by starting it with:

  • hosts: localhost

connection: local

gather_facts: false

become: false