- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Ansible infoblox.py questions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-01-2017 11:08 AM
I'm new to Ansible so my questions maybe pretty basic.
What is the best way to install/add the infoblox module (https://github.com/xoanmi/ansible-module-infoblox) into Ansible? I pip installed the request module but I wasn't sure about the infoblox.py module.
So I cut/paste the source into /usr/lib/python2.7/site-packages/ansible/modules/extras/cloud/infoblox/infoblox.py.
I created the following playbook by hacking from others examples
cat jontest.yml
---
- name: create
hosts: localhost
gather_facts: no
tasks:
- name: add_host
infoblox:
server: xx.xx.xx.xx
username: yyyyyyyy
password: ppppppppp
api_version: 2.6
action: add_host
host: ansibletest1.na.example.net
dns_view: default
address: 1.1.1.5
register: result
When I run the playbook I get the following. I think there is some error being returned by Infoblox but the infoblox.py is attempting to format it as JSON and maybe it is in JSON format? Any suggestions or hints what error is triggering this?
ansible-playbook -vvv jontest.yml
Using /etc/ansible/ansible.cfg as config file
PLAYBOOK: jontest **************************************************************
1 plays in jontest
PLAY [create] ******************************************************************
TASK [add_host] ****************************************************************
task path: /home/jtanner/git/Ansible-Playbook-Templates/playbooks/jontest:6
Using module file /usr/lib/python2.7/site-packages/ansible/modules/extras/cloud/infoblox/infoblox.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: jtanner
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /tmp/$USER/.ansible/ansible-tmp-1504288306.7-84076120360299 `" && echo ansible-tmp-1504288306.7-84076120360299="` echo /tmp/$USER/.ansible/ansible-tmp-1504288306.7-84076120360299 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmp5981FS TO /tmp/jtanner/.ansible/ansible-tmp-1504288306.7-84076120360299/infoblox.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /tmp/jtanner/.ansible/ansible-tmp-1504288306.7-84076120360299/ /tmp/jtanner/.ansible/ansible-tmp-1504288306.7-84076120360299/infoblox.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python2 /tmp/jtanner/.ansible/ansible-tmp-1504288306.7-84076120360299/infoblox.py; rm -rf "/tmp/jtanner/.ansible/ansible-tmp-1504288306.7-84076120360299/" > /dev/null 2>&1 && sleep 0'
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_iWJ2Cb/ansible_module_infoblox.py", line 2070, in <module>
main()
File "/tmp/ansible_iWJ2Cb/ansible_module_infoblox.py", line 1798, in main
result = infoblox.create_host_record(host, address, None, comment, ttl, extattrs)
File "/tmp/ansible_iWJ2Cb/ansible_module_infoblox.py", line 1007, in create_host_record
object_ref = self.get_host_object(host, address)
File "/tmp/ansible_iWJ2Cb/ansible_module_infoblox.py", line 981, in get_host_object
hosts = self.get_host_by_name(name)
File "/tmp/ansible_iWJ2Cb/ansible_module_infoblox.py", line 974, in get_host_by_name
return self.invoke("get", "record:host", params=params)
File "/tmp/ansible_iWJ2Cb/ansible_module_infoblox.py", line 225, in invoke
raise Exception(response.json())
File "/usr/lib/python2.7/site-packages/requests/models.py", line 866, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib64/python2.7/json/__init__.py", line 338, in loads
return _default_decoder.decode(s)
File "/usr/lib64/python2.7/json/decoder.py", line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib64/python2.7/json/decoder.py", line 384, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
fatal: [localhost]: FAILED! => {
"changed": false,
"failed": true,
"invocation": {
"module_name": "infoblox"
},
"module_stderr": "Traceback (most recent call last):\n File \"/tmp/ansible_iWJ2Cb/ansible_module_infoblox.py\", line 2070, in <module>\n main()\n File \"/tmp/ansible_iWJ2Cb/ansible_module_infoblox.py\", line 1798, in main\n result = infoblox.create_host_record(host, address, None, comment, ttl, extattrs)\n File \"/tmp/ansible_iWJ2Cb/ansible_module_infoblox.py\", line 1007, in create_host_record\n object_ref = self.get_host_object(host, address)\n File \"/tmp/ansible_iWJ2Cb/ansible_module_infoblox.py\", line 981, in get_host_object\n hosts = self.get_host_by_name(name)\n File \"/tmp/ansible_iWJ2Cb/ansible_module_infoblox.py\", line 974, in get_host_by_name\n return self.invoke(\"get\", \"record:host\", params=params)\n File \"/tmp/ansible_iWJ2Cb/ansible_module_infoblox.py\", line 225, in invoke\n raise Exception(response.json())\n File \"/usr/lib/python2.7/site-packages/requests/models.py\", line 866, in json\n return complexjson.loads(self.text, **kwargs)\n File \"/usr/lib64/python2.7/json/__init__.py\", line 338, in loads\n return _default_decoder.decode(s)\n File \"/usr/lib64/python2.7/json/decoder.py\", line 366, in decode\n obj, end = self.raw_decode(s, idx=_w(s, 0).end())\n File \"/usr/lib64/python2.7/json/decoder.py\", line 384, in raw_decode\n raise ValueError(\"No JSON object could be decoded\")\nValueError: No JSON object could be decoded\n",
"module_stdout": "",
"msg": "MODULE FAILURE"
}
Re: Ansible infoblox.py questions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-01-2017 12:38 PM
All you need to do is put the ansible-module-infoblox directory somewhere and add it to the ANSIBLE_LIBRARY environment variable. Ansible will pick it up once that's set.
Re: Ansible infoblox.py questions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-01-2017 02:12 PM
Thank you for the update on the installation. After installing, I get the following error.
Here is my playbook ...
---
- name: create
hosts: localhost
gather_facts: no
tasks:
- name: add_host
infoblox:
server: xx.xx.xx.xx
username: yyyyyyy
password: zzzzzzzzzzzzzzzz
api_version: 2.6
action: get_a_record
name: jontestip.na.steelcase.net
address: 10.80.96.81
register: result
ansible-playbook jontest.yml
PLAY [create] ******************************************************************
TASK [add_host] ****************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ValueError: No JSON object could be decoded
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Traceback (most recent call last):\n File \"/tmp/ansible_t_XqPg/ansible_module_infoblox.py\", line 2070, in <module>\n main()\n File \"/tmp/ansible_t_XqPg/ansible_module_infoblox.py\", line 1693, in main\n result = infoblox.get_a_record(name)\n File \"/tmp/ansible_t_XqPg/ansible_module_infoblox.py\", line 510, in get_a_record\n return self.invoke(\"get\", \"record:a\", params=params)\n File \"/tmp/ansible_t_XqPg/ansible_module_infoblox.py\", line 225, in invoke\n raise Exception(response.json())\n File \"/usr/lib/python2.7/site-packages/requests/models.py\", line 866, in json\n return complexjson.loads(self.text, **kwargs)\n File \"/usr/lib64/python2.7/json/__init__.py\", line 338, in loads\n return _default_decoder.decode(s)\n File \"/usr/lib64/python2.7/json/decoder.py\", line 366, in decode\n obj, end = self.raw_decode(s, idx=_w(s, 0).end())\n File \"/usr/lib64/python2.7/json/decoder.py\", line 384, in raw_decode\n raise ValueError(\"No JSON object could be decoded\")\nValueError: No JSON object could be decoded\n", "module_stdout": "", "msg": "MODULE FAILURE"}
to retry, use: --limit @/home/jtanner/git/Ansible-Playbook-Templates/playbooks/jontest2.retry
PLAY RECAP *********************************************************************
localhost : ok=0 changed=0 unreachable=0 failed=1
In the Infoblox logs, I can see a successful connection. Yet there must be some error being returned that infoblox.py isn't handling correctly?
Re: Ansible infoblox.py questions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-01-2017 03:01 PM
What are you trying to do with this playbook?
Re: Ansible infoblox.py questions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-05-2017 06:05 AM
I'm assuming I've got something incorrect but I don't get any error messages returned. I get a message saying the JSON message is missing or maybe isn't JSON formatted (ValueError: No JSON object could be decoded).
Is there any documentation available for the infoblox.py module? Are you aware of anyone sharing their Ansible/Infoblox playbooks?
Jon Tanner
Steelcase
Server Engineer
Core Infrastructure
+1 616 475 2446
Steelcase.com
Re: Ansible infoblox.py questions
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-05-2017 06:29 PM - edited 09-05-2017 06:33 PM
Edit: I just noticed you said you're running NIOS 7.3.8. You need to change your api_version to 2.3.1. If you open https://<url>/wapidoc on your appliance and look in the upper left corner you will see the WAPI version for your system.
Also, in the above playbook you shouldn't be getting an a record using both a name and an IP, you should just use the name. This playbook works for me:
---
- name: create
hosts: localhost
gather_facts: no
remote_user: brampling
become: true
become_user: root
tasks:
- name: get_a_record
infoblox:
server: 10.60.27.4
username: admin
password: infoblox
api_version: 2.6
action: get_a_record
name: onea.blair.com
dns_view: default
register: result
- debug: var=result
...
ansible-playbook test-gethost.yml
PLAY [create] ******************************************************************
TASK [get_a_record] ************************************************************
ok: [localhost]
TASK [debug] *******************************************************************
ok: [localhost] => {
"result": {
"changed": false,
"result": [
{
"_ref": "record:a/ZG5zLmJpbmRfYSQuX2RlZmF1bHQuY29tLmJsYWlyLG9uZWEsMS4xLjEuMQnea.blair.com/default",
"extattrs": {},
"ipv4addr": "1.1.1.1",
"name": "onea.blair.com",
"use_ttl": false,
"view": "default"
}
]
}
}
PLAY RECAP *********************************************************************
localhost : ok=2 changed=0 unreachable=0 failed=0
Re: Ansible infoblox.py questions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-05-2017 06:36 PM
Unfortunately there is no documentation for the open source Ansible module. Here is an example playbook that will create a Host record in one of three ways. If you specify the network parameter (as in the below example) it will get the next available IP in the speficied network and create a Host record with the name specified in the host parameter. If you comment out network, uncomment start_addr and end_addr, then set those to the start and end of a Range, it will get the next available IP in the range and use that for the Host record. Finally if you uncomment the address parameter (and comment out the start_addr, end_addr, and network parameters) it will use a specified address and not use get next available IP at all.
---
- name: create
hosts: localhost
gather_facts: no
remote_user: brampling
become: true
become_user: root
tasks:
- name: add_host
infoblox:
server: 10.60.27.4
username: admin
password: infoblox
api_version: 2.6
action: add_host
host: ansibletest3.test.com
dns_view: default
# address: 1.1.1.6
# start_addr: 1.1.1.2
# end_addr: 1.1.1.5
network: 1.1.1.0/24
register: result
...
Re: Ansible infoblox.py questions
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
01-11-2018 01:38 PM - edited 01-12-2018 09:02 AM
I resolved my own issue. Please disregard.
Re: Ansible infoblox.py questions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
01-12-2018 11:06 AM
Do you mind sharing the solution for the event that someone else has the same or a similar issue?