├── hosts ├── lookup_playbooks ├── group_vars │ └── all ├── get_networkviews.yml └── get_host_record.yml ├── module_playbooks ├── group_vars │ └── all ├── dns_instance.yml ├── host_record.yml ├── dns_view.yml └── configure_network.yml ├── images └── rh-ansible-automation.png ├── ansible.cfg └── README.md /hosts: -------------------------------------------------------------------------------- 1 | localhost 2 | -------------------------------------------------------------------------------- /lookup_playbooks/group_vars/all: -------------------------------------------------------------------------------- 1 | --- 2 | nios_provider: 3 | host: 1.2.3.4 4 | username: admin 5 | password: ansible 6 | -------------------------------------------------------------------------------- /module_playbooks/group_vars/all: -------------------------------------------------------------------------------- 1 | --- 2 | nios_provider: 3 | host: 1.2.3.4 4 | username: admin 5 | password: ansible 6 | -------------------------------------------------------------------------------- /images/rh-ansible-automation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/network-automation/infoblox_ansible/HEAD/images/rh-ansible-automation.png -------------------------------------------------------------------------------- /ansible.cfg: -------------------------------------------------------------------------------- 1 | [defaults] 2 | retry_files_enabled = False 3 | deprecation_warnings=False 4 | host_key_checking = False 5 | inventory = hosts 6 | gathering = explicit 7 | [paramiko_connection] 8 | host_key_auto_add = True 9 | -------------------------------------------------------------------------------- /module_playbooks/dns_instance.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | connection: local 4 | tasks: 5 | - name: configure a dns zone on the system 6 | nios_zone: 7 | name: testhost 8 | state: present 9 | view: ansible-dns 10 | provider: "{{nios_provider}}" 11 | -------------------------------------------------------------------------------- /module_playbooks/host_record.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | connection: local 4 | tasks: 5 | - name: configure an ipv4 host record 6 | nios_host_record: 7 | name: testhost 8 | ipv4: 9 | - address: "192.168.10.200" 10 | state: present 11 | provider: "{{nios_provider}}" 12 | -------------------------------------------------------------------------------- /lookup_playbooks/get_networkviews.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | connection: local 4 | tasks: 5 | - name: fetch all networkview objects 6 | set_fact: 7 | networkviews: "{{ lookup('nios', 'networkview', provider=nios_provider) }}" 8 | 9 | - name: check the networkviews 10 | debug: 11 | var: networkviews 12 | -------------------------------------------------------------------------------- /module_playbooks/dns_view.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | connection: local 4 | tasks: 5 | - name: configure a new dns view instance 6 | nios_dns_view: 7 | name: ansible-dns 8 | network_view: default 9 | comment: this is an example comment 10 | state: present 11 | provider: "{{nios_provider}}" 12 | -------------------------------------------------------------------------------- /module_playbooks/configure_network.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | connection: local 4 | tasks: 5 | - name: set dhcp options for a network 6 | nios_network: 7 | network: 192.168.100.0/24 8 | comment: sean put a comment here 9 | options: 10 | - name: domain-name 11 | value: ansible.com 12 | state: present 13 | provider: "{{nios_provider}}" 14 | -------------------------------------------------------------------------------- /lookup_playbooks/get_host_record.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | connection: local 4 | tasks: 5 | - name: fetch host leaf01 6 | set_fact: 7 | host: "{{ lookup('nios', 'record:host', filter={'name': 'leaf01'}, provider=nios_provider) }}" 8 | 9 | - name: check the leaf01 return variable 10 | debug: 11 | var: host 12 | 13 | - name: debug specific variable (ipv4 address) 14 | debug: 15 | var: host.ipv4addrs[0].ipv4addr 16 | 17 | - name: fetch host leaf02 18 | set_fact: 19 | host: "{{ lookup('nios', 'record:host', filter={'name': 'leaf02'}, provider=nios_provider) }}" 20 | 21 | - name: check the leaf02 return variable 22 | debug: 23 | var: host 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Infoblox Ansible Examples 2 | 3 | This repo contains various examples using Ansible for Infoblox Network Identity Operating System (NIOS). 4 | 5 | # Table of Contents 6 | - [Ansible Module Examples](#ansible-module-examples) 7 | - [Configuring a IPv4 Network with nios_network](#configuring-a-ipv4-network-with-nios_network) 8 | - [Additional Examples](#additional-examples) 9 | - [Ansible Lookup Plugin Examples](#ansible-lookup-plugin-examples) 10 | - [Get a host record](#get-a-host-record) 11 | - [Get a network view object](#get-a-network-view-object) 12 | 13 | ## Ansible Module Examples 14 | 15 | The full list of NIOS modules can be found at the [NIOS module list](https://docs.ansible.com/ansible/latest/modules/list_of_net_tools_modules.html#net-tools-modules) 16 | 17 | In addition there are the following lookup plugins: 18 | 19 | * [nios](https://docs.ansible.com/ansible/latest/plugins/lookup/nios.html) - Query Infoblox NIOS objects 20 | * [nios_next_ip](https://docs.ansible.com/ansible/latest/plugins/lookup/nios_next_ip.html) - Return the next available IP address for a network 21 | 22 | 23 | ### Configuring an IPv4 Network with nios_network 24 | 25 | ```yaml 26 | - name: set dhcp options for a network 27 | nios_network: 28 | network: 192.168.100.0/24 29 | comment: sean put a comment here 30 | options: 31 | - name: domain-name 32 | value: ansible.com 33 | state: present 34 | provider: "{{nios_provider}}" 35 | ``` 36 | 37 | The full playbook can be found here: [module_playbooks/configure_network.yml](module_playbooks/configure_network.yml) 38 | 39 | ### Additional Examples 40 | 41 | There are 3 other playbooks in the **module_playbooks** directory that can be used as examples: 42 | - [module_playbooks/dns_instance.yml](module_playbooks/dns_instance.yml) - configure a dns zone on the system 43 | - [module_playbooks/dns_view.yml](module_playbooks/dns_view.yml) - configure a new dns view instance 44 | - [module_playbooks/host_record.yml](module_playbooks/host_record.yml) - configure an ipv4 host record 45 | 46 | ## Ansible Lookup Plugin Examples 47 | 48 | The full documentation for the NIOS lookup plugin can be found here: [http://docs.ansible.com/ansible/devel/plugins/lookup/nios.html](http://docs.ansible.com/ansible/devel/plugins/lookup/nios.html) 49 | 50 | ### Get a host record 51 | 52 | ```yaml 53 | - name: fetch host leaf01 54 | set_fact: 55 | host: "{{ lookup('nios', 'record:host', filter={'name': 'leaf01'}, provider=nios_provider) }}" 56 | 57 | - name: check the leaf01 return variable 58 | debug: 59 | var: host 60 | ``` 61 | 62 | The full playbook can be found here: [lookup_playbooks/get_host_record.yml](lookup_playbooks/get_host_record.yml) 63 | 64 | ### Get a network view object 65 | 66 | ```yaml 67 | - name: fetch all networkview objects 68 | set_fact: 69 | networkviews: "{{ lookup('nios', 'networkview', provider=nios_provider) }}" 70 | 71 | - name: check the networkviews 72 | debug: 73 | var: networkviews 74 | ``` 75 | 76 | The full playbook can be found here: [lookup_playbooks/get_networkviews.yml](lookup_playbooks/get_networkviews.yml) 77 | 78 | --- 79 | ![Red Hat Ansible Automation](images/rh-ansible-automation.png) 80 | 81 | Red Hat® Ansible® Automation includes three products: 82 | 83 | - [Red Hat® Ansible® Engine](https://www.ansible.com/ansible-engine): a fully supported product built on the foundational capabilities of the Ansible project. 84 | 85 | - [Red Hat® Ansible® Networking Add-On](https://www.ansible.com/ansible-engine): provides support for select networking modules from Arista (EOS), Cisco (IOS, IOS XR, NX-OS), Juniper (Junos OS), Open vSwitch, and VyOS. 86 | 87 | - [Red Hat® Ansible® Tower](https://www.ansible.com/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. 88 | 89 | Want more info? 90 | [Read this blog post for more info about Engine, the networking add-on and Tower](https://www.ansible.com/blog/red-hat-ansible-automation-engine-vs-tower) 91 | --------------------------------------------------------------------------------