Skip to content

Instantly share code, notes, and snippets.

@aslafy-z
Created May 18, 2023 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aslafy-z/76d5584583189bb2ba010a5043d99ba0 to your computer and use it in GitHub Desktop.
Save aslafy-z/76d5584583189bb2ba010a5043d99ba0 to your computer and use it in GitHub Desktop.
Extract subnet list from a supernet with ansible
- hosts: localhost
vars:
supernet: "10.3.0.0/22"
subnet_cidr: 24
subnet_size: "{{ supernet | ipsubnet(subnet_cidr) }}"
subnet_list: []
tasks:
- set_fact:
subnet_list: "{{ subnet_list }} + ['{{ ip | ipsubnet(subnet_cidr, item) }}']"
with_sequence: "0-{{ subnet_size | int-1}}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment