Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'ansible.vars.hostvars.HostVarsVars object' has no attribute 'ansible_ssh_host' #161

Open
MoralCode opened this issue Apr 17, 2024 · 7 comments · May be fixed by #164
Open

'ansible.vars.hostvars.HostVarsVars object' has no attribute 'ansible_ssh_host' #161

MoralCode opened this issue Apr 17, 2024 · 7 comments · May be fixed by #164

Comments

@MoralCode
Copy link

MoralCode commented Apr 17, 2024

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

@iakkus
Copy link
Member

iakkus commented Apr 17, 2024

@MoralCode
Copy link
Author

oh dang, i was searching for this on SO but i guess not hard enough. i'll make a PR to fix that. thanks!

@MoralCode
Copy link
Author

ansible -i inventory.cfg -m debug -a "var=hostvars[inventory_hostname]" all is a modified version of a debugging command I found here

@MoralCode
Copy link
Author

looks like (per that SO post) ansible_default_ipv4.address may be better to use

@iakkus
Copy link
Member

iakkus commented Apr 23, 2024

Have a look at this reasoning: #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.

@MoralCode
Copy link
Author

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}')

@iakkus
Copy link
Member

iakkus commented Apr 24, 2024

Feel free to try it out and see if you can get it automatically in the config.

@MoralCode MoralCode linked a pull request Apr 29, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants