'ansible.vars.hostvars.HostVarsVars object' has no attribute 'ansible_ssh_host'
When trying to set up KNIX via ansible, i noticed the following error in the debug section of the riak.log file:
The task includes an option with an undefined variable. The error was: {{ hostvars[groups['riak'][0]].ansible_ssh_host }}: 'ansible.vars.hostvars.HostVarsVars object' has no attribute 'ansible_ssh_host'\n\nThe error appears to be in '[REDACTED]/deploy/ansible/riak.yaml': line 75, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - debug:\n ^ here\n
this seems to cause a generic failure with not a lot of logs visible in make after the failure of TriggersFrontend to build (see #160), but :
ansible-playbook -e "@settings.json" riak.yaml 2>&1 >riak.log.tmp
/usr/lib/python3/dist-packages/paramiko/transport.py:237: CryptographyDeprecationWarning: Blowfish has been deprecated
"class": algorithms.Blowfish,
BECOME password:
[WARNING]: Consider using 'become', 'become_method', and 'become_user' rather
than running su
make: *** [Makefile:42: riak.log] Error 2
Could this maybe be some issue with newer versions of ansible?
im using ansible 2.10.8 with python 3.10.12 on a linux host
I guess you may be right.
https://stackoverflow.com/questions/40027847/accessing-inventory-host-variable-in-ansible-playbook#40029455
oh dang, i was searching for this on SO but i guess not hard enough. i'll make a PR to fix that. thanks!
ansible -i inventory.cfg -m debug -a "var=hostvars[inventory_hostname]" all is a modified version of a debugging command I found here
looks like (per that SO post) ansible_default_ipv4.address may be better to use
Have a look at this reasoning: https://github.com/knix-microfunctions/knix/pull/118
It looks like the ansible_default_ipv4.address was creating problems with hosts with multiple network devices, where the cluster was communicating internally.
But that was a long time ago and I don't recall exactly what was really wrong.
ah ok. i ran into issues trying to put a hostname into the (updated) ansible_host var in inventory.cfg (was getting an error like "<hostname>:8098" cannot be converted to a(n) IP in one of the services that was causing it to fail to start).
Maybe it would be nice to include the snippet of code from #118 in the cfg file as a comment? or maybe somehow automate the creation of that variable if it isnt present?
[riak]
knix-1 ansible_ssh_host=$(ping knix-1 -c 1 | head -1 | awk '{print $3}' | awk 'BEGIN {FS="[()]"}; {print $2}')
Feel free to try it out and see if you can get it automatically in the config.