Hello when attempting to run a ansible play via bash script on a remote RHEL 9 node i am getting "ERROR]: Task failed: Finalization of task args for 'ansible.builtin.set_fact' failed: Error while resolving value for 'infoblox_next_ip': The lookup plugin 'nios_next_ip' failed: a bytes-like object is required, not 'str'". This play is using the infoblox plugin to lookup ip addresses, it works great if i run on the remote node local CLI however when triggered from rundeck to the RHEL 9 node i get this error. From my testing it appears to be related to the password and special characters but im not 100% sure. Any ideas on how to troubleshoot?
Not working(trigger from rundeck): rundeck -> shell script -> ansible-playbook -> infoblox module
Working(local CLI on RHEL Node): ansible-playbook -> infoblox module
250 - name: Get next available IP address in given subnet with exclusions
251 ansible.builtin.set_fact:
252 infoblox_next_ip: >-
^ column 23
<<< caused by >>>
a bytes-like object is required, not 'str'
fatal: [localhost]: FAILED! => {
"changed": false,
"msg": "Task failed: Finalization of task args for 'ansible.builtin.set_fact' failed: Error while resolving value for 'infoblox_next_ip': The lookup plugin 'nios_next_ip' failed: a bytes-like object is required, not 'str'"
}
Page 1 / 1
Hi
A few quick checks/fixes that typically resolve this:
- Compare environments (Rundeck vs local CLI):
- ansible --version
- python3 --version
- ansible-galaxy collection list | grep -E 'infoblox|community.general'
- python3 -c "import infoblox_client,sys;print('infoblox-client',getattr(infoblox_client,'version','unknown'));print(sys.executable)"
- Use the fully qualified plugin name:
- Use infoblox.nios_modules.nios_next_ip in your lookup, not the community.general redirect (the redirect doesn’t work on Ansible 2.9).
- Example:
ipaddr: "{{ lookup('infoblox.nios_modules.nios_next_ip', '192.168.10.0/24',
provider={'host': 'nios01', 'username': 'admin', 'password': ib_password}) }}"
- Ensure the Infoblox dependency is in the Rundeck Python env:
- infoblox-client must be installed where Rundeck runs ansible-playbook (controller).
- Don’t pass the password via shell args (special chars can get mangled):
- Put credentials in an Ansible vars file or Vault and reference as variables in the provider dict.
- Set encoding in the Rundeck step:
- LANG=en_US.UTF-8, LC_ALL=en_US.UTF-8, PYTHONIOENCODING=UTF-8
- Check proxy variables:
- If Rundeck has http_proxy/https_proxy set, try disabling or add Infoblox to no_proxy.
If it still fails, please run with -vvvv and share the traceback so you can see exactly where the TypeError is thrown (plugin vs HTTP layer). Official plugin docs here for reference: infoblox.nios_modules.nios_next_ip and general lookup behavior: Lookup plugins.
Hope this helps, enjoy your day!
Login to PagerDuty Commons
No account yet? Create an account
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.