Brian,
I did comment out that msg, and re-ran the playbook. Seems to point now to an issue connecting to the API.
admin@host$ ansible-playbook cust_nbx_create_region.yaml -vvv
ansible-playbook [core 2.12.1]
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/admin/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
ansible collection location = /home/admin/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible-playbook
python version = 3.8.10 (default, Nov 26 2021, 20:14:08) [GCC 9.3.0]
jinja version = 3.0.3
libyaml = True
Using /etc/ansible/ansible.cfg as config file
host_list declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
script declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
auto declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Parsed /etc/ansible/hosts inventory source with ini plugin
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.
PLAYBOOK: cust_nbx_create_region.yaml **********************************************************************************************************************************************************************
1 plays in cust_nbx_create_region.yaml
PLAY [Created Static Region in Customer Netbox] ************************************************************************************************************************************************************
META: ran handlers
TASK [Example state: present - Update] *********************************************************************************************************************************************************************
task path: /home/admin/cust_nbx_create_region.yaml:9
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: admin
<127.0.0.1> EXEC /bin/sh -c 'echo ~admin && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/admin/.ansible/tmp `"&& mkdir "` echo /home/admin/.ansible/tmp/ansible-tmp-1641753792.1518397-33237-180578382023952 `" && echo ansible-tmp-1641753792.1518397-33237-180578382023952="` echo /home/admin/.ansible/tmp/ansible-tmp-1641753792.1518397-33237-180578382023952 `" ) && sleep 0'
Using module file /home/admin/.ansible/collections/ansible_collections/netbox/netbox/plugins/modules/netbox_region.py
<127.0.0.1> PUT /home/admin/.ansible/tmp/ansible-local-332328zbsaejw/tmpqsebk_8v TO /home/admin/.ansible/tmp/ansible-tmp-1641753792.1518397-33237-180578382023952/AnsiballZ_netbox_region.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/admin/.ansible/tmp/ansible-tmp-1641753792.1518397-33237-180578382023952/ /home/admin/.ansible/tmp/ansible-tmp-1641753792.1518397-33237-180578382023952/AnsiballZ_netbox_region.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python3 /home/admin/.ansible/tmp/ansible-tmp-1641753792.1518397-33237-180578382023952/AnsiballZ_netbox_region.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/admin/.ansible/tmp/ansible-tmp-1641753792.1518397-33237-180578382023952/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
File "/tmp/ansible_netbox_region_payload__t5bh25v/ansible_netbox_region_payload.zip/ansible_collections/netbox/netbox/plugins/module_utils/netbox_utils.py", line 604, in _connect_netbox_api
self.full_version = nb.status().get("netbox-version")
fatal: [localhost]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"cert": null,
"data": {
"name": "California",
"parent_region": null,
"slug": "california"
},
"netbox_token": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"netbox_url": "
https://hostname",
"query_params": null,
"state": "present",
"validate_certs": true
}
},
"msg": "Failed to establish connection to NetBox API"
}
PLAY RECAP *************************************************************************************************************************************************************************************************
localhost : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
So, now I'm not sure that I have ansible working correctly for this or not. The playbook is defined to only run on localhost, but connect to the defined URL. The URL is working just fine from a browser, also created a small python file to verify that it works on that host to connect to the netbox API
cat nbxconnect.py
#!/usr/bin/env python3
import sys, json
import pynetbox
netboxsvr=pynetbox.api('
https://hostname', token='token', threading=True)
print(netboxsvr)
Execute the file:
./nbxconnect.py
<pynetbox.core.api.Api object at 0x7fefab555b20>
So, still trying to narrow down where in the communication chain this is broken.