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

generate intended config and jinja2 include #899

Open
milan2655 opened this issue Feb 24, 2025 · 2 comments
Open

generate intended config and jinja2 include #899

milan2655 opened this issue Feb 24, 2025 · 2 comments

Comments

@milan2655
Copy link

Environment

  • Python version: 3.12.8
  • Nautobot version: 2.3.13
  • nautobot-golden-config version: 2.2.2

generate intended config

An error occurred:

Error rendering Jinja template: Subtask: GENERATE CONFIG (failed)

Steps to Reproduce

we are using include in our jinja2 templates to break large templates into smaller logical units that are based on features. parsing of jinja2 templates woks with Generate Intended Configurations JOB, but not with Generate Intended Configuration. We get next exception:

Traceback (most recent call last):
  File "/opt/nautobot/.local/lib/python3.12/site-packages/nornir/core/task.py", line 98, in start
    r = self.task(self, **self.params)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/nautobot/.local/lib/python3.12/site-packages/nornir_jinja2/plugins/tasks/template_file.py", line 43, in template_file
    text = t.render(host=task.host, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/jinja2/environment.py", line 1304, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.12/site-packages/jinja2/environment.py", line 939, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "/opt/nautobot/git/configjinja_templates/catalyst/base.j2", line 4, in top-level template code
    {% include 'catalyst/generic/aaa_config.j2' %}
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/jinja2/loaders.py", line 207, in get_source
    raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: catalyst/generic/aaa_config.j2
@itdependsnetworks
Copy link
Contributor

itdependsnetworks commented Feb 24, 2025

@gsnider2195 do we have a different root folder on the Generate Intended Configuration code?

@milan2655
Copy link
Author

i just check and root folders are different.

root folder in job is:

jinja_root_path=settings.jinja_repository.filesystem_path,

settings.jinja_repository.filesystem_path -> '/git/configjinja_templates'

and in Generate Intended Configuration:

jinja_root_path=filesystem_path.parent,

filesystem_path.parent -> PosixPath('/git/configjinja_templates/catalyst')

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

No branches or pull requests

3 participants