Reply
Accepted Solution

getting 'Exception: IP address for the Host record is missing.' when using Ansible to add host

jnc
Techie
Posts: 3
4900     0

Hi,

I am testing Ansible module and I am able to get host. However, when adding a host, it failed. Here's what I have:

 

Playbook:

=============

 

 

---
- name: query DNS
  hosts: localhost
  connection: local
  gather_facts: no
  strategy: debug
  tasks:
  - name: find out a DNS record
    infoblox:
        server: x.x.x.x
        username: user1
        password: xxxxxx
        api_version: 1.6.1
        action: add_host
        host: testhost1.nonexist.com
        address: 10.20.30.41
        dns_view: default
    register: result
  - name: show output
    debug:
     var: result

error:

========

 

 

ubuntu@ubuntu-xenial:~/ansible/infoblox$ ansible-playbook ./playbooks/infoblox.yaml -vvv
ansible-playbook 2.4.0.0
config file = /home/ubuntu/ansible/infoblox/ansible.cfg
configured module search path = [u'/usr/local/lib/python2.7/dist-packages/ansible/modules']
ansible python module location = /usr/lib/python2.7/dist-packages/ansible
executable location = /usr/bin/ansible-playbook
python version = 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]
Using /home/ubuntu/ansible/infoblox/ansible.cfg as config file
Parsed /home/ubuntu/ansible/infoblox/ansible_inventory inventory source with ini plugin
PLAYBOOK: infoblox.yaml ************************************************************************************************************
1 plays in ./playbooks/infoblox.yaml
PLAY [query DNS] *******************************************************************************************************************
META: ran handlers
TASK [find out a DNS record] *******************************************************************************************************
task path: /home/ubuntu/ansible/infoblox/playbooks/infoblox.yaml:8
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/ansible-module-infoblox-master/infoblox.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: ubuntu
<127.0.0.1> EXEC /bin/sh -c 'echo ~ && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/ubuntu/.ansible/tmp/ansible-tmp-1508532893.25-41509055676241 `" && echo ansible-tmp-1508532893.25-41509055676241="` echo /home/ubuntu/.ansible/tmp/ansible-tmp-1508532893.25-41509055676241 `" ) && sle\
ep 0'
<127.0.0.1> PUT /tmp/tmpbg_Pb9 TO /home/ubuntu/.ansible/tmp/ansible-tmp-1508532893.25-41509055676241/infoblox.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/ubuntu/.ansible/tmp/ansible-tmp-1508532893.25-41509055676241/ /home/ubuntu/.ansible/tmp/ansible-tmp-1508532893.25-41509055676241/infoblox.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python /home/ubuntu/.ansible/tmp/ansible-tmp-1508532893.25-41509055676241/infoblox.py; rm -rf "/home/ubuntu/.ansible/tmp/ansible-tmp-1508532893.25-41509055676241/" > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible__Our2U/ansible_module_infoblox.py", line 2205, in <module>
main()
File "/tmp/ansible__Our2U/ansible_module_infoblox.py", line 1919, in main
host, address, None, comment, ttl, extattrs)
File "/tmp/ansible__Our2U/ansible_module_infoblox.py", line 1068, in create_host_record
return self.invoke("post", "record:host", ok_codes=(200, 201, 400), json=model)
File "/tmp/ansible__Our2U/ansible_module_infoblox.py", line 229, in invoke
raise Exception(payload["text"])
Exception: IP address for the Host record is missing.
fatal: [localhost]: FAILED! => {
"changed": false,
"failed": true,
"module_stderr": "Traceback (most recent call last):\n File \"/tmp/ansible__Our2U/ansible_module_infoblox.py\", line 2205, in <module>\n main()\n File \"/tmp/ansible__Our2U/ansible_module_infoblox.py\", line 1919, in main\n host, address, None, comment,\
ttl, extattrs)\n File \"/tmp/ansible__Our2U/ansible_module_infoblox.py\", line 1068, in create_host_record\n return self.invoke(\"post\", \"record:host\", ok_codes=(200, 201, 400), json=model)\n File \"/tmp/ansible__Our2U/ansible_module_infoblox.py\", line 22\
9, in invoke\n raise Exception(payload[\"text\"])\nException: IP address for the Host record is missing.\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 0
}

debug output:

================

 

(debug) p task.args
{u'action': u'add_host',
 u'address': u'10.20.30.41',
 u'api_version': u'1.6.1',
 u'dns_view': u'default',
 u'host': u'testhost1.nonexist.com',
 u'password': u'xxxxx',
 u'server': u'x.x.x.x',
 u'username': u'user1'}

Any help would be greatly appreciated!

Re: getting 'Exception: IP address for the Host record is missing.' when using Ansible to add host

jnc
Techie
Posts: 3
4901     0

I think I know what happened.

This is the infoblox API:

{"name":"host.info.com",
"ipv4addrs":
[{"ipv4addr":"172.26.1.20",
"mac":"aa:bb:cc:11:22:21"}]}

This is the code in infoblox.py module. 

 

    def create_host_record(self, host, address, network_ref=None, comment=None, ttl=None, extattrs=None):
 ...<snip>...
        model = {_NAME_PROPERTY: host, _IPV4_ADDRESS_PROPERTY: [{_IPV4_ADDRESS_PROPERTY: address}],
                 _VIEW_PROPERTY: self.dns_view,
                 _COMMENT_PROPERTY: comment, _EXT_ATTR_PROPERTY: extattrs}
...<snip>...

Seems the model wasn't built correctly.  It builds a record like this: "ipv4addr": [{"ipv4adr": "x.x.x.x"}]

Re: getting 'Exception: IP address for the Host record is missing.' when using Ansible to add host

jnc
Techie
Posts: 3
4901     0

I modified infoblox.py and it's working for me now so I consider this is resolved.

However, there are other functions that might be affected by this too. I am going to open a bug. 

Re: getting 'Exception: IP address for the Host record is missing.' when using Ansible to add host

davisionz
Techie
Posts: 1
4901     0

@jnc, can you elaborate on what was changed?  we're coming across the same issue 

Re: getting 'Exception: IP address for the Host record is missing.' when using Ansible to add host

yangjef2
Techie
Posts: 3
4901     0

same here. updates on the issue please.

Re: getting 'Exception: IP address for the Host record is missing.' when using Ansible to add host

GHorne Community Manager
Community Manager
Posts: 254
4901     0

there was a typo in the python.

 

it was creating an 'ipv4addr' record instead of an 'ipv4addrs' record.

Re: getting 'Exception: IP address for the Host record is missing.' when using Ansible to add host

[ Edited ]
yangjef2
Techie
Posts: 3
4901     0

 simply replacing the first var should work, right?

model = {_NAME_PROPERTY: host, "ipv4addrs": [{_IPV4_ADDRESS_PROPERTY: address}],
_VIEW_PROPERTY: self.dns_view,
_COMMENT_PROPERTY: comment, _EXT_ATTR_PROPERTY: extattrs}

 

I'm still getting

The full traceback is:
Traceback (most recent call last):
File "/var/folders/s3/6yq90n310_92ls_253mjpqj94cvtx4/T/ansible_Y5nh9C/ansible_module_infoblox.py", line 2203, in <module>
main()
File "/var/folders/s3/6yq90n310_92ls_253mjpqj94cvtx4/T/ansible_Y5nh9C/ansible_module_infoblox.py", line 1917, in main
host, address, None, comment, ttl, extattrs)
File "/var/folders/s3/6yq90n310_92ls_253mjpqj94cvtx4/T/ansible_Y5nh9C/ansible_module_infoblox.py", line 1066, in create_host_record
return self.invoke("post", "record:host", ok_codes=(200, 201, 400), json=model)
File "/var/folders/s3/6yq90n310_92ls_253mjpqj94cvtx4/T/ansible_Y5nh9C/ansible_module_infoblox.py", line 228, in invoke
raise Exception(payload["text"])
Exception: IP address for the Host record is missing.

Re: getting 'Exception: IP address for the Host record is missing.' when using Ansible to add host

cmccarth
Techie
Posts: 1
4901     0

I am getting the same error, can someone provide some guidance?

 

here is my playbook...

 

 

- name: "Add host record to Infoblox"

hosts: localhost

gather_facts: false

become: false

vars_files:

- vars/infoblox_vars.yml

 

tasks:

- name: "Add host"

infoblox:

server: "{{ infoblox_server }}"

username: "{{ infoblox_username }}"

password: "{{ infoblox_password }}"

action: add_host

dns_view: "{{ infoblox_dns_view }}"

address: 10.147.252.2

host: testhostname

api_version: 2.5

delegate_to: localhost

register: response

 

- name: "Print Response"

debug:

var: response

 

 

 

 

 

 

Here is the error...

 

 

 

PLAY [Add host record to Infoblox] ************************************************************************************************************************

 

TASK [Add host] *******************************************************************************************************************************************

fatal: [localhost -> localhost]: FAILED! => {"changed": false, "failed": true, "module_stderr": "/usr/lib/python2.7/site-packages/urllib3/connectionpool.py:858: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings\n  InsecureRequestWarning)\n/usr/lib/python2.7/site-packages/urllib3/connectionpool.py:858: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings\n  InsecureRequestWarning)\n/usr/lib/python2.7/site-packages/urllib3/connectionpool.py:858: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings\n  InsecureRequestWarning)\nTraceback (most recent call last):\n  File \"/tmp/ansible_f_J4k2/ansible_module_infoblox.py\", line 2205, in <module>\n    main()\n  File \"/tmp/ansible_f_J4k2/ansible_module_infoblox.py\", line 1919, in main\n    host, address, None, comment, ttl, extattrs)\n  File \"/tmp/ansible_f_J4k2/ansible_module_infoblox.py\", line 1068, in create_host_record\n    return self.invoke(\"post\", \"record:host\", ok_codes=(200, 201, 400), json=model)\n  File \"/tmp/ansible_f_J4k2/ansible_module_infoblox.py\", line 229, in invoke\n    raise Exception(payload[\"text\"])\nException: IP address for the Host record is missing.\n", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 0}

 

PLAY RECAP ************************************************************************************************************************************************

localhost                  : ok=0    changed=0    unreachable=0    failed=1

Re: getting 'Exception: IP address for the Host record is missing.' when using Ansible to add host

[ Edited ]
sri
Techie
Posts: 1
4901     0

I am facing with the same issue 

 

IP address for the Host record is missing.

 

 

- name: Create A Record
uri:
url: 'https://{{infoblox_host}}/wapi/v2.2/record:host'
method: POST
validate_certs: no
follow_redirects: all
password: "{{ pass }}"
user: "{{ user }}"
#body: { "credentials": { "username": "{{user}}","password": "{{pass}}" } }
host_key_checking: False
#use_proxy: False
force_basic_auth: yes
status_code: 201, 200
#return_content: False
timeout: 30
body_format: json
body: {"ipv4addr": "{{ipv4_addr}}","view": "{{DNS_Region}}","name":"{{DNS_Name}}"}
headers:
Authorization: "Basic U1BhcmltaTI6SUBtQGdvYTE5OTA"
Content-Type: "application/json"
register: "infoblox"

 

"Error": "AdmConProtoError: IP address for the Host record is missing.",
"code": "Client.Ibap.Proto",
"text": "IP address for the Host record is missing."

 

"msg": "Status code was not [201, 200]: HTTP Error 400: Bad Request",
"pragma": "no-cache",
"redirected": false,
"set_cookie": "ibapauth=\"client=API,group=UCC_DIGITS,ctime=1518825823,timeout=60000,mtime=1518825823,ip=10.253.31.119,auth=RADIUS,user=SParimi2,jxTtE/RX1zChzVHpGK4HAlNVv5/wAajsax0\"; httponly; Path=/; secure",
"status": 400,

 

 

Showing results for 
Search instead for 
Do you mean 

Recommended for You