Learn How We Can Help You Keep Teleworkers Protected During the COVID-19 Crisis

API & Integration

Reply
Highlighted

Ansible lookups

Techie
Posts: 1
269     0

Hi all,

 

I'm trying to use Infoblox with Ansible for both A-Record and PTR. How can I do this? I'm trying to find a fqdn from an ip, or an ip from a fqdn.

 

Thanks.

 

 

Highlighted

Re: Ansible lookups

Adviser
Posts: 136
269     0

Hi,

 

You can do so by using the lookup plugins in your playbook as below.

---

- hosts: localhost
  vars:
    nios_provider:
      host: grid-master
      username: admin
      password: infoblox

  connection: local
  tasks:
# Get the list of A records
   - name: get member list
     set_fact:
       arecords: "{{ lookup('nios', 'record:a', provider=nios_provider) }}"
   - name: display all A records
     debug:
       msg: "{{ arecords}}"
# Get an A record using its name
   - name: get A record
     set_fact:
       arecord: "{{ lookup('nios', 'record:a', filter={'name': 'a.demo.com'}, provider=nios_provider) }}"
   - name: display A record a.demo.com
     debug:
       msg: "{{ arecord}}"
# Get an A record using its IP address
   - name: get A record
     set_fact:
       arecord: "{{ lookup('nios', 'record:a', filter={'ipv4addr': '192.168.1.2'}, provider=nios_provider) }}"
   - name: display A record for 192.168.1.2
     debug:
       msg: "{{ arecord}}"
# Get all PTR records
   - name: get all PTR records
     set_fact:
       ptrrecord: "{{ lookup('nios', 'record:ptr', provider=nios_provider) }}"
   - name: display list of PTR records
     debug:
       msg: "{{ ptrrecord}}"
# Get PTR record using its name
   - name: get PTR record
     set_fact:
       ptrrecord: "{{ lookup('nios', 'record:ptr', filter={'ptrdname': 'a.demo.com'}, provider=nios_provider) }}"
   - name: display PTR record a.demo.com
     debug:
       msg: "{{ ptrrecord}}"

Hope this helps,

Krishna Vasudevan

Highlighted

Re: Ansible lookups

Techie
Posts: 1
269     0

Is there any way to get records from specific dns view instead of getting all the records

Highlighted

Re: Ansible lookups

Adviser
Posts: 136
270     0

Hi,

 

You can add it as part of filters.

# Get an A record in a view
   - name: get A record
     set_fact:
       arecord: "{{ lookup('nios', 'record:a', filter={'view': 'test'}, provider=nios_provider) }}"
   - name: display A records in view test
     debug:
       msg: "{{ arecord}}"

Hope this helps,

Krishna

Showing results for 
Search instead for 
Do you mean 

Recommended for You