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

Fix for 'str object' has no attribute 'name' #61

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

filviu
Copy link
Contributor

@filviu filviu commented Aug 16, 2022

I started seeing the following error:

TASK [rossmcdonald.telegraf : Set templatized Telegraf configuration] *************************************************************************************************************************************************
task path: /home/user/.ansible/roles/rossmcdonald.telegraf/tasks/configure.yml:14
The full traceback is:
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.10/site-packages/ansible/template/__init__.py", line 1116, in do_template
    res = ansible_concat(rf)
  File "/home/user/.local/lib/python3.10/site-packages/ansible/template/native_helpers.py", line 88, in ansible_concat
    return ''.join([to_text(v) for v in nodes])
  File "/home/user/.local/lib/python3.10/site-packages/ansible/template/native_helpers.py", line 88, in <listcomp>
    return ''.join([to_text(v) for v in nodes])
  File "<template>", line 231, in root
  File "/home/user/.local/lib/python3.10/site-packages/ansible/template/__init__.py", line 268, in wrapper
    ret = func(*args, **kwargs)
  File "/home/user/.local/lib/python3.10/site-packages/ansible/template/__init__.py", line 647, in _ansible_finalize
    return thing if _fail_on_undefined(thing) is not None else ''
  File "/home/user/.local/lib/python3.10/site-packages/ansible/template/__init__.py", line 619, in _fail_on_undefined
    elif is_sequence(data):
  File "/home/user/.local/lib/python3.10/site-packages/ansible/module_utils/common/collections.py", line 94, in is_sequence
    if not include_strings and is_string(seq):
  File "/home/user/.local/lib/python3.10/site-packages/jinja2/runtime.py", line 852, in _fail_with_undefined_error
    raise self._undefined_exception(self._undefined_message)
jinja2.exceptions.UndefinedError: 'str object' has no attribute 'name'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/.local/lib/python3.10/site-packages/ansible/plugins/action/template.py", line 138, in run
    resultant = templar.do_template(template_data, preserve_trailing_newlines=True, escape_backslashes=False)
  File "/home/user/.local/lib/python3.10/site-packages/ansible/template/__init__.py", line 1153, in do_template
    raise AnsibleUndefinedVariable(e)
ansible.errors.AnsibleUndefinedVariable: 'str object' has no attribute 'name'
fatal: [dev17.smartkyc.com]: FAILED! => changed=false 
  msg: 'AnsibleUndefinedVariable: ''str object'' has no attribute ''name'''

I am not sure at which point this started happening - I only discovered when I wanted to add a new telegraf plugin to my infrastructure. By the looks of it the result of the old style concatenation results in a string now instead of a list. This fixes the issue for me but I didn't test more than this.

@@ -76,6 +76,6 @@ telegraf_plugins_base:
interfaces:
- "eth0"

telegraf_plugins: "{{ telegraf_plugins_base }} + {{ telegraf_plugins_extra | default([]) }}"
telegraf_plugins: "{{ telegraf_plugins_base + telegraf_plugins_extra | default([]) }}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixed the issue for me

filviu and others added 6 commits January 30, 2023 09:38
keyname changed also for yum repos to influxdata-archive_compat.key
Add telegraf_configuration_backup
telegraf_configuration_backup
Update influxdata.repo.j2 fix for RPM based OS
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

Successfully merging this pull request may close these issues.

3 participants