Skip to content

Error undefined variable dict object #414

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

Closed
Stoutscientist opened this issue Jun 15, 2022 · 5 comments
Closed

Error undefined variable dict object #414

Stoutscientist opened this issue Jun 15, 2022 · 5 comments

Comments

@Stoutscientist
Copy link

Stoutscientist commented Jun 15, 2022

So I have been trying to setup internet-pi on my Pi 3b and after running ansible-playbook main.yml I get the error
"
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible.errors.AnsibleUndefinedVariable: 'dict object' has no attribute 'default_ipv4' fatal: [xxx.xxx.x.xxx]: FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 'dict object' has no attribute 'default_ipv4'"}
"
I'm new to Raspberry Pi's and Docker so sorry if this is a stupid question

@Stoutscientist
Copy link
Author

I also ran ansible-playbook main.yml -vvv and this is the full traceback.

`The full traceback is:
Traceback (most recent call last):
File "/home/stout/.local/lib/python3.9/site-packages/ansible/template/init.py", line 1160, in do_template
res = j2_concat(rf)
File "", line 25, in root
File "/home/stout/.local/lib/python3.9/site-packages/jinja2/runtime.py", line 852, in _fail_with_undefined_error
raise self._undefined_exception(self._undefined_message)
jinja2.exceptions.UndefinedError: 'dict object' has no attribute 'default_ipv4'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/stout/.local/lib/python3.9/site-packages/ansible/plugins/action/template.py", line 150, in run
resultant = templar.do_template(template_data, preserve_trailing_newlines=True, escape_backslashes=False)
File "/home/stout/.local/lib/python3.9/site-packages/ansible/template/init.py", line 1199, in do_template
raise AnsibleUndefinedVariable(e)
ansible.errors.AnsibleUndefinedVariable: 'dict object' has no attribute 'default_ipv4'
fatal: [xxx.xxx.x.xxx]: FAILED! => {
"changed": false,
"msg": "AnsibleUndefinedVariable: 'dict object' has no attribute 'default_ipv4'"
}`

@martinbrose
Copy link
Contributor

You might have a problem with your inventory.ini?
What changes did you perform?

@Stoutscientist
Copy link
Author

Stoutscientist commented Jun 27, 2022

[internet_pi]
10.0.100.52 ansible_user=pi

Comment out the previous line and uncomment this to run inside Raspberry Pi.
127.0.0.1 ansible_connection=local ansible_user=pi

(there is a # where it says comment out the previous line it just confused github)
^ I changed 127.0.0.1 to my pi's IP

@martinbrose
Copy link
Contributor

martinbrose commented Jun 27, 2022

Ok, this might be your problem.

There are two options:

  1. You run it from another machine and remotely install on the Pi, then you change the second line in inventory.ini. For example, your Pi's IP is 192.168.0.5, then your inventory.ini would be:
[internet_pi]
192.168.0.5 ansible_user=pi

# Comment out the previous line and uncomment this to run inside Raspberry Pi.
# 127.0.0.1 ansible_connection=local ansible_user=pi

Just changing the IP address 10.0.100.52 to 192.168.0.5.

  1. Or you install locally while logged into your PI, your inventory.ini would be:
[internet_pi]
# 10.0.100.52 ansible_user=pi

# Comment out the previous line and uncomment this to run inside Raspberry Pi.
127.0.0.1 ansible_connection=local ansible_user=pi

Commenting out the second line and uncommenting the last line, without changing 127.0.0.1 (localhost).

@Stoutscientist
Copy link
Author

Thanks! And sorry for the late reply I cought covid lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants