- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Ansible lookups
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
08-16-2019 10:58 AM
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.
Re: Ansible lookups
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
08-20-2019 11:19 PM
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
Re: Ansible lookups
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
05-19-2020 03:51 PM
Is there any way to get records from specific dns view instead of getting all the records
Re: Ansible lookups
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
06-03-2020 09:06 AM
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
Re: Ansible lookups
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Like in GUI...how can we do global search using lookup... For a single host i need to get return all the types of records.. including IPV4 , VLAN, network_view, comments and all the DNS related records aswell (a, cname, mx, ipv4, host..etc.)
if i need to decom a server i need find all the entries related a single host/server ..using ansible
Re: Ansible lookups
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2 weeks ago
Hi,
Can you try this and see if this is what you are looking for?
# Search against IP address - name: search for an IP address set_fact: iprecord: "{{ lookup('nios', 'search', filter={'address': '10.10.10.1'}, provider=nios_provider) }}" - name: display all the records associated with this IP address debug: msg: "{{ iprecord}}"
Regards,
Krishna
Re: Ansible lookups
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2 weeks ago - last edited 2 weeks ago
HI Krishna,
sorry its not working im using
ansible --version
ansible 2.9.0
python version = 3.6.8
Method 1 (which you suggestes)
Error:
Failed on object search with url https://infoblox.xxx.net/wapi/v2.1/search?address=10.12.131.81&_max_results=100000: b'{ "Error": "AdmConProtoError: Unknown argument/field: \'address\'", \n "code": "Client.Ibap.Proto", \n "text": "Unknown argument/field: \'address\'"\n}'
Failed on object search with url https://infoblox.xxx.net/wapi/v2.1/search?address=10.12.131.81&_max_results=100000&_proxy_search=GM: b'{ "Error": "AdmConProtoError: Unknown argument/field: \'address\'", \n "code": "Client.Ibap.Proto", \n "text": "Unknown argument/field: \'address\'"\n}'
========================================================
wif ref to
https://ipam.illinois.edu/wapidoc/objects/search.html
i tried Method 2: using ansible uri module GET method as below. this is also not working.
url: "https://infoblox.xxx.net/wapi/v2.1/search?fqdn={{host}}"
user: "{{username}}"
password: "{{password}}"
force_basic_auth: yes
method: get
Error:
fatal: 1/1 [localhost]: FAILED! => {"cache_control": "no-cache, no-store", "changed": false, "connection": "close", "content": "{ \"Error\": \"AdmConProtoError: Unknown argument/field: 'fqdn'\", \n \"code\": \"Client.Ibap.Proto\", \n \"text\": \"Unknown argument/field: 'fqdn'\"\n}", "content_type": "application/json", "date": "Thu, 18 Feb 2021 22:24:59 GMT", "elapsed": 0, "json": {"Error": "AdmConProtoError: Unknown argument/field: 'fqdn'", "code": "Client.Ibap.Proto", "text": "Unknown argument/field: 'fqdn'"}, "msg": "Status code was 400 and not [200]: HTTP Error 400: Bad Request", "pragma": "no-cache", "redirected": false, "set_cookie": "ibapauth=\"client=API,group=READ%20ONLY,ctime=1613687099,timeout=28800,mtime=1613687099,ip=10.0.125.125,auth=TACACS%2B,user=xpctr570068,s0N5+7LTEN1FhBzE3slvjDAin28FRSK58k8\"; httponly; Path=/", "status": 400, "strict_transport_security": "max-age=31536000; includeSubDomains", "transfer_encoding": "chunked", "url": "https://infoblox.xxx.net/wapi/v2.1/search?fqdn=niostest19.xxx.test", "x_content_type_options": "nosniff", "x_frame_options": "SAMEORIGIN", "x_xss_protection": "1; mode=block"}
--------------------------------------------------------
========================================================================
this Method 3: is working with ip address
as like with uri module get method.
url: "https://infoblox.xxx.net/wapi/v2.1/search?address=10.2.6.6
user: "{{username}}"
password: "{{password}}"
force_basic_auth: yes
method: get
but the result is not bringing all the record ..only IP related record its bringing i need to get cname record also. will be easy if work with search?fqdn=
so please help for all the 3 methods.