fboender / ansible-cmdb

Generate host overview from ansible fact gathering output
GNU General Public License v3.0
2.33k stars 465 forks source link

Debian 11 can't use default template with ansible-cmdb 1.31 #247

Open itservices-trust opened 2 years ago

itservices-trust commented 2 years ago

Hi, I have a role in Ansible that automates html page creation with ansible-cmdb. I have ansible-cmdb version 1.31.

With Debian 11 upgrade does not work anymore, if I execute: /usr/bin/ansible-cmdb -i /srv/ansible_repos/inventory/all /srv/ansible_out/hosts > /srv/ansible_out/html/index.html

I receive the following error:

Traceback (most recent call last):
  File "_usr_lib_ansible_cmdb_ansiblecmdb_data_tpl_html_fancy_tpl", line 18, in _mako_get_namespace
KeyError: ('_usr_lib_ansible_cmdb_ansiblecmdb_data_tpl_html_fancy_tpl', 'defs')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/ansible-cmdb/mako/lookup.py", line 237, in get_template
    return self._check(uri, self._collection[uri])
KeyError: '/html_fancy_defs.html'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/../lib/ansible-cmdb/ansible-cmdb.py", line 214, in <module>
    output = renderer.render(ansible.get_hosts(), params)
  File "/usr/lib/ansible-cmdb/ansiblecmdb/render.py", line 42, in render
    return self._render_mako(hosts, vars)
  File "/usr/lib/ansible-cmdb/ansiblecmdb/render.py", line 59, in _render_mako
    return template.render(hosts=hosts, **vars)
  File "/usr/lib/ansible-cmdb/mako/template.py", line 443, in render
    return runtime._render(self, self.callable_, args, data)
  File "/usr/lib/ansible-cmdb/mako/runtime.py", line 802, in _render
    _render_context(template, callable_, context, *args,
  File "/usr/lib/ansible-cmdb/mako/runtime.py", line 835, in _render_context
    _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
  File "/usr/lib/ansible-cmdb/mako/runtime.py", line 860, in _exec_template
    callable_(context, *args, **kwargs)
  File "_usr_lib_ansible_cmdb_ansiblecmdb_data_tpl_html_fancy_tpl", line 31, in render_body
  File "_usr_lib_ansible_cmdb_ansiblecmdb_data_tpl_html_fancy_tpl", line 20, in _mako_get_namespace
  File "_usr_lib_ansible_cmdb_ansiblecmdb_data_tpl_html_fancy_tpl", line 23, in _mako_generate_namespaces
  File "/usr/lib/ansible-cmdb/mako/runtime.py", line 545, in __init__
    self.template = _lookup_template(context, templateuri,
  File "/usr/lib/ansible-cmdb/mako/runtime.py", line 769, in _lookup_template
    return lookup.get_template(uri)
  File "/usr/lib/ansible-cmdb/mako/lookup.py", line 245, in get_template
    return self._load(srcfile, uri)
  File "/usr/lib/ansible-cmdb/mako/lookup.py", line 306, in _load
    self._collection[uri] = template = Template(
  File "/usr/lib/ansible-cmdb/mako/template.py", line 321, in __init__
    module = self._compile_from_file(path, filename)
  File "/usr/lib/ansible-cmdb/mako/template.py", line 396, in _compile_from_file
    code, module = _compile_text(
  File "/usr/lib/ansible-cmdb/mako/template.py", line 672, in _compile_text
    code = compile(source, cid, 'exec')
  File "_html_fancy_defs_html", line 97
    def render_var_cols(context,cols_visible=,cols_exclude=):
                                             ^
SyntaxError: invalid syntax

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/../lib/ansible-cmdb/ansible-cmdb.py", line 221, in <module>
    full_err = exceptions.text_error_template().render().replace("\n", "\n    ")
  File "/usr/lib/ansible-cmdb/mako/exceptions.py", line 219, in text_error_template
    return mako.template.Template(r"""
  File "/usr/lib/ansible-cmdb/mako/template.py", line 303, in __init__
    (code, module) = _compile_text(self, text, filename)
  File "/usr/lib/ansible-cmdb/mako/template.py", line 672, in _compile_text
    code = compile(source, cid, 'exec')
  File "memory:0x7f9b3fa85c40", line 18
    def render_body(context,error=,traceback=,**pageargs):
                                  ^
SyntaxError: invalid syntax
itservices-trust commented 2 years ago

Solved installing ansible-cmdb with pip instead of .deb package!

Frank-dbc commented 1 year ago

thanks @itservices-trust a life-saver! after fighting a few days with the .deb package not working, i now have a ansible-cmdb that works!

itservices-trust commented 1 year ago

thanks @itservices-trust a life-saver! after fighting a few days with the .deb package not working, i now have a ansible-cmdb that works!

you're welcome! :+1: