Reply

Error when creating host record via Ansible with infoblox-client

[ Edited ]
New Member
Posts: 3
6054     1

First off, I'm new to ansible and infoblox, so my issue may be something really simple, despite many queries online, I've not come across anything to help so far.

 

I've got Ansible Tower set up and set up a python virtual environment for the infoblox-client, I set up a playbook that gets settings from a credentials object, which includes WAPI version (2.10.5), hostname of the Grid master, username, password.  I prompt for input of variables nios_fqdn, nios_shortname, nio_vlan (although this last one is not in use in this test from below, to rule out this as the issue - still struggling with variables within variables, although I probably got it figured out at some point, but because the error persisted, I didn't know).  Here's what I have:

(Ansible 2.9.0)

---
- hosts: all
  connection: local
  vars:
    nios_provider:
      host: "{{ INFOBLOX_HOST }}"
      username: "{{ INFOBLOX_USERNAME }}"
      password: '{{ INFOBLOX_PASSWORD }}'
      wapi_version: "{{ INFOBLOX_WAPI }}"
  tasks:
  - name: create host record
    nios_host_record:
      name: "{{ nios_fqdn }}"
      view: default
      ipv4addrs:
        ipv4addr: "{{ lookup('nios_next_ip', '10.1.2.0/24', provider=nios_provider)[0] }}"
      ttl: 3600
      aliases: "{{ nios_shortname }}"
      comment: Added by "{{ tower_user_name }}"
      state: present
      provider: "{{ nios_provider }}"



pip3 show infoblox-client

Name: infoblox-client

Version: 0.5.0

Summary: Client for interacting with Infoblox NIOS over WAPI

Home-page: https://github.com/infobloxopen/infoblox-client

Author: John Belamaric

Author-email: jbelamaric@infoblox.com

License: Apache

Location: /opt/venv/infoblox/lib/python3.6/site-packages

Requires: requests, urllib3, setuptools, oslo.log, six, oslo.serialization

 

The error I keep getting:

{

    "msg": "An unhandled exception occurred while running the lookup plugin 'nios_next_ip'. Error was a <class 'TypeError'>, original message: argument of type 'ConnectTimeout' is not iterable",

    "_ansible_no_log": false

}

 

Any thoughts on what could be causing this?  I've tried several debug options, but nothing seems to shine any light on this.

 

Thanks,

Jason

Re: Error when creating host record via Ansible with infoblox-client

Adviser
Posts: 65
6055     1

The error message indicates that instead of an iterable list of available IP's you are getting a ConnectionTimeout message when you make the next available IP call.

Can you test the call outside of ansible and see if you are able to get a list of available IPs?

Re: Error when creating host record via Ansible with infoblox-client

Superuser
Posts: 115
6055     1

Here is a great example

 

https://sifbaksh.com/infoblox-and-ansible-using-nios_next_ip/

 

 

Follow me on LinkedIn: https://www.linkedin.com/in/sifbaksh
Twitter: https://twitter.com/sifbaksh

https://sifbaksh.com

Re: Error when creating host record via Ansible with infoblox-client

New Member
Posts: 3
6055     1

Thanks, I had tested this before and it -was- working, but it seems something got messed up with the connection since then.  I tested with python with just a lookup and it fails as well.

Re: Error when creating host record via Ansible with infoblox-client

Superuser
Posts: 115
6055     1

Can you post your Python example?

 

Here is my example

import requests

url = "https://gm/wapi/v2.7/network"
payload="{\n    \"network\": \"func:nextavailablenetwork:10.1.0.0/16,default,24\"\n    }\n\n"
headers = {
  'Content-Type': 'application/json',
}

response = requests.request("POST", url, headers=headers, data=payloadverify=False, auth=('admin', 'infoblox'))

print(response.text)
Follow me on LinkedIn: https://www.linkedin.com/in/sifbaksh
Twitter: https://twitter.com/sifbaksh

https://sifbaksh.com
Showing results for 
Search instead for 
Did you mean: 

Recommended for You