The ipaddr filter is a Jinja2 filter designed to provide an interface to netaddr. This github repo provides examples with the Ansible template module to augment the ipaddr documentation.
---
- hosts: localhost
connection: local
gather_facts: false
vars:
sean_subnet: "192.168.1.0/24"
tasks:
- template:
src: ./template.j2
dest: ./rendered
Use the ansible-playbook command to run the included playbook.
[sean@rhel7]$ ansible-playbook ipaddr_test.yml
The playbook will create a local file called rendered
which renders the included template.j2
which includes examples with the ipaddr filter.
Click here to view the playbook
The rendered config will provider numerous examples. For example:
Jinja2: What is the range of usable IP address on {{sean_subnet}}? {{ sean_subnet | ipaddr('range_usable') }}
Renders: What is the range of usable IP address on 192.168.1.0/24? 192.168.1.1-192.168.1.254
Click here to view the rendered template
Red Hat® Ansible® Automation includes three products:
-
Red Hat® Ansible® Engine: a fully supported product built on the foundational capabilities of the Ansible project.
-
Red Hat® Ansible® Networking Add-On: provides support for select networking modules from Arista (EOS), Cisco (IOS, IOS XR, NX-OS), Juniper (Junos OS), Open vSwitch, and VyOS.
-
Red Hat® Ansible® Tower: makes it easy to scale automation, manage complex deployments and speed productivity. Extend the power of Ansible with workflows to streamline jobs and simple tools to share solutions with your team.
Want more info? Read this blog post for more info about Engine, the networking add-on and Tower