Skip to content

[BUG] Jinja2 TemplateNotFound error with using salt-ssh #83

@MemoryLeak55

Description

@MemoryLeak55

Your setup

Formula commit hash / release tag

Commit hash: 90500f9 (master branch, at 2020/06/29)

Versions reports (master & minion)

salt-ssh 3001 (From the ubuntu focal repos)
salt-minion 3000.3 (From pip)

salt-ssh is run from ubuntu 20.04 desktop
salt-minion is run on a minimal 20.04 focal image for LXC containers.

Pillar / config used

Nothing relevant here. Bug relates to formula itself. When server.sls tries to render redis-3.2-ng.conf.jinja a file not found error appears relating to map.jinja


Bug details

Describe the bug

If you try use the redis formula with salt-ssh it fails with a file not found error (the file is there). The command

salt-ssh -i <minion> state.apply redis.server

fails with

          ID: redis_config
    Function: file.managed
        Name: /etc/redis/redis.conf
      Result: False
     Comment: Unable to manage file: Jinja error: redis/map.jinja
              Traceback (most recent call last):
                File "/var/tmp/.salt_e05380_salt/pyall/salt/utils/templates.py", line 400, in render_jinja_tmpl
                  output = template.render(**decoded_context)
                File "/var/tmp/.salt_e05380_salt/pyall/jinja2/environment.py", line 1090, in render
                  self.environment.handle_exception()
                File "/var/tmp/.salt_e05380_salt/pyall/jinja2/environment.py", line 832, in handle_exception
                  reraise(*rewrite_traceback_stack(source=source))
                File "/var/tmp/.salt_e05380_salt/pyall/jinja2/_compat.py", line 28, in reraise
                  raise value.with_traceback(tb)
                File "<template>", line 4, in top-level template code
                File "/var/tmp/.salt_e05380_salt/pyall/salt/utils/jinja.py", line 204, in get_source
                  raise TemplateNotFound(template)
              jinja2.exceptions.TemplateNotFound: redis/map.jinja

              ; line 4

              ---
              #
              # This file is managed by salt. Do not edit by hand.
              #
              {% from "redis/map.jinja" import redis_settings with context %}    <======================
              ################################## INCLUDES ###################################
              {% if redis_settings.include is defined %}
              {%- for include in redis_settings.include %}
              include {{ include }}
              {%- endfor %}
              [...]
              ---
     Started: 10:17:55.643913
    Duration: 98.964 ms
     Changes:

The "redis/map.jinja" file is there.

Steps to reproduce the bug

Just try using the redis formula with salt-ssh in any way.

Expected behaviour

Installed redis, with appropriately rendered config

Attempts to fix the bug

Some other formulas have the same issue. I cannot recall which ones, but quite a few mainstream ones do fail in the same way with the map.jinja error. The formula works fine with regular salt command

Additional context

N/A, ask and I will do my best to answer

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions