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

Broken on Ansible 2.11.6 / Jinja2 3.0.3? #50

Open
Kariton opened this issue Nov 10, 2021 · 2 comments
Open

Broken on Ansible 2.11.6 / Jinja2 3.0.3? #50

Kariton opened this issue Nov 10, 2021 · 2 comments

Comments

@Kariton
Copy link

Kariton commented Nov 10, 2021

Hey,

I just cloned the master branch and discovered that the deployment of the hosts file failed:

I execute the role as the following:

# ansible-playbook playbook/hostsfile.yml -e "hosts_inventory_to_hosts=true"

The Error:

TASK [system_hosts : Edits the hosts file in /etc] ****************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible.errors.AnsibleUndefinedVariable: 'dict object' has no attribute 'ipv4'
fatal: [host1.example.com]: FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 'dict object' has no attribute 'ipv4'"}
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible.errors.AnsibleUndefinedVariable: 'dict object' has no attribute 'ipv4'
fatal: [host2.example.com]: FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 'dict object' has no attribute 'ipv4'"}

The full traceback is:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/ansible/template/__init__.py", line 1100, in do_template
    res = j2_concat(rf)
  File "<template>", line 108, in root
  File "/usr/local/lib/python3.6/site-packages/ansible/template/__init__.py", line 265, in wrapper
    ret = func(*args, **kwargs)
  File "/opt/ansible/collections/ansible_collections/ansible/netcommon/plugins/filter/ipaddr.py", line 560, in ipaddr
    elif not value or value is True:
  File "/usr/local/lib/python3.6/site-packages/jinja2/runtime.py", line 903, in _fail_with_undefined_error
    raise self._undefined_exception(self._undefined_message)
jinja2.exceptions.UndefinedError: 'dict object' has no attribute 'ipv4'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/ansible/plugins/action/template.py", line 146, in run
    resultant = templar.do_template(template_data, preserve_trailing_newlines=True, escape_backslashes=False)
  File "/usr/local/lib/python3.6/site-packages/ansible/template/__init__.py", line 1137, in do_template
    raise AnsibleUndefinedVariable(e)
ansible.errors.AnsibleUndefinedVariable: 'dict object' has no attribute 'ipv4'
fatal: [host1.example.com]: FAILED! => {
    "changed": false,
    "msg": "AnsibleUndefinedVariable: 'dict object' has no attribute 'ipv4'"
}

Removing cached facs or direktly trigger ansible.builtin.setup as pre_tasks changed nothing.

Proof that the dict object exists:

# ansible -m setup --tree facts/ GROUP
# cat facts/host1.example.com | jq . -C | grep '"ipv4"' -A 5
      "ipv4": {
        "address": "172.28.20.41",
        "broadcast": "172.28.20.255",
        "netmask": "255.255.255.0",
        "network": "172.28.20.0"
      },
--
      "ipv4": {
        "address": "127.0.0.1",
        "broadcast": "",
        "netmask": "255.0.0.0",
        "network": "127.0.0.0"
      },
# ansible --version
ansible [core 2.11.6]
  python version = 3.6.8 (default, Sep 12 2021, 04:40:35) [GCC 8.4.1 20200928 (Red Hat 8.4.1-1)]
  jinja version = 3.0.3
  libyaml = True

Can anyone reproduce this error?

@Kariton
Copy link
Author

Kariton commented Nov 10, 2021

Downgraded Jinja2 to jinja version = 2.11.0 - changed nothing

@Kariton
Copy link
Author

Kariton commented Nov 12, 2021

I think my problem is related to different interface names

  • one hosts (engine) = eth0
  • the other (node) = enp1s0

In my case this are an oVirt node and oVirt engine.

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

1 participant