Skip to content

GitFS mountpoint option fails on Jinja imports #49783

@joni1993

Description

@joni1993

Description of Issue/Question

When using the mointpoint option with public formulas (e.g. https://github.com/saltstack-formulas/salt-formula), the formula fails when importing in a jinja template.

For example i want to include the salt-formula but i want to use it from a specific mountpoint (e.g. services.control.salt instead of just salt).

This issue is probably related to #39881 and #19564 but it happens with "salt" and not "salt-ssh".

Setup

Master configuration

fileserver_backend:
  - git
  - roots
file_roots:
  base:
    - /srv/salt/test

Master GitFS Remote Config A

gitfs_remotes:
  - ssh://git@github.com:saltstack-formulas/salt-formula.git:
    - base: master
    - root: salt
    - mountpoint: salt://services/control/salt/

Master GitFS Remote Config B

gitfs_remotes:
  - ssh://git@github.com:saltstack-formulas/salt-formula.git:
    - base: master
    - mountpoint: salt://services/control/salt/

Top File A (with root option)

base:
  '*':
    - services.control.salt.pkgrepo
    - services.control.salt.master
    - services.control.salt.minion

Top File B (Without root option)

base:
  '*':
    - services.control.salt.salt.salt-formula.salt.pkgrepo
    - services.control.salt.salt.master
    - services.control.salt.salt.minion

Steps to Reproduce Issue

  1. Configure gitfs remote on master
  2. Setup Topfile
  3. Run "salt "*" state.highstate
    4A. Result with Config A is:
     Data failed to compile:
----------
    Rendering SLS 'base:services.control.salt.master' failed: Jinja error: salt/map.jinja
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/utils/templates.py", line 389, in render_jinja_tmpl
    output = template.render(**decoded_context)
  File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 989, in render
    return self.environment.handle_exception(exc_info, True)
  File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 754, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "<template>", line 1, in top-level template code
  File "/usr/lib/python2.7/dist-packages/salt/utils/jinja.py", line 140, in get_source
    raise TemplateNotFound(template)
TemplateNotFound: salt/map.jinja

; line 1

---
{% from "salt/map.jinja" import salt_settings with context %}    <======================

salt-master:
{% if salt_settings.install_packages %}
  pkg.installed:
    - name: {{ salt_settings.salt_master }}
[...]
---
----------
    Rendering SLS 'base:services.control.salt.minion' failed: Jinja error: salt/map.jinja
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/utils/templates.py", line 389, in render_jinja_tmpl
    output = template.render(**decoded_context)
  File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 989, in render
    return self.environment.handle_exception(exc_info, True)
  File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 754, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "<template>", line 1, in top-level template code
  File "/usr/lib/python2.7/dist-packages/salt/utils/jinja.py", line 140, in get_source
    raise TemplateNotFound(template)
TemplateNotFound: salt/map.jinja

; line 1

---
{% from "salt/map.jinja" import salt_settings with context %}    <======================

{% if salt_settings.install_packages and grains.os == 'MacOS' and salt_settings.salt_minion_pkg_source != '' and salt_settings.version != '' %}
{# only download IF we know where to get the pkg from and if we know what version to check the current install (if installed) against #}
{# e.g. don't download unless it appears as though we're about to try and upgrade the minion #}
download-salt-minion:
[...]
---
----------
    Rendering SLS 'base:services.control.salt.pkgrepo.debian' failed: Jinja error: salt/map.jinja
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/utils/templates.py", line 389, in render_jinja_tmpl
    output = template.render(**decoded_context)
  File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 989, in render
    return self.environment.handle_exception(exc_info, True)
  File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 754, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "<template>", line 1, in top-level template code
  File "/usr/lib/python2.7/dist-packages/salt/utils/jinja.py", line 140, in get_source
    raise TemplateNotFound(template)
TemplateNotFound: salt/map.jinja

; line 1

---
{% from "salt/map.jinja" import salt_settings with context %}    <======================

saltstack-pkgrepo:
  pkgrepo.managed:
    - humanname: SaltStack Debian Repo
    - name: {{ salt_settings.pkgrepo }}
[...]
---

4B. Result with Config B is:

   Data failed to compile:
----------
    Rendering SLS 'base:services.control.salt.salt.pkgrepo.debian' failed: Jinja error: salt/map.jinja
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/utils/templates.py", line 389, in render_jinja_tmpl
    output = template.render(**decoded_context)
  File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 989, in render
    return self.environment.handle_exception(exc_info, True)
  File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 754, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "<template>", line 1, in top-level template code
  File "/usr/lib/python2.7/dist-packages/salt/utils/jinja.py", line 140, in get_source
    raise TemplateNotFound(template)
TemplateNotFound: salt/map.jinja

; line 1

---
{% from "salt/map.jinja" import salt_settings with context %}    <======================

saltstack-pkgrepo:
  pkgrepo.managed:
    - humanname: SaltStack Debian Repo
    - name: {{ salt_settings.pkgrepo }}
[...]
---
----------
    Rendering SLS 'base:services.control.salt.salt.master' failed: Jinja error: salt/map.jinja
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/utils/templates.py", line 389, in render_jinja_tmpl
    output = template.render(**decoded_context)
  File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 989, in render
    return self.environment.handle_exception(exc_info, True)
  File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 754, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "<template>", line 1, in top-level template code
  File "/usr/lib/python2.7/dist-packages/salt/utils/jinja.py", line 140, in get_source
    raise TemplateNotFound(template)
TemplateNotFound: salt/map.jinja

; line 1

---
{% from "salt/map.jinja" import salt_settings with context %}    <======================

salt-master:
{% if salt_settings.install_packages %}
  pkg.installed:
    - name: {{ salt_settings.salt_master }}
[...]
---
----------
    Rendering SLS 'base:services.control.salt.salt.minion' failed: Jinja error: salt/map.jinja
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/utils/templates.py", line 389, in render_jinja_tmpl
    output = template.render(**decoded_context)
  File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 989, in render
    return self.environment.handle_exception(exc_info, True)
  File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 754, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "<template>", line 1, in top-level template code
  File "/usr/lib/python2.7/dist-packages/salt/utils/jinja.py", line 140, in get_source
    raise TemplateNotFound(template)
TemplateNotFound: salt/map.jinja

; line 1

---
{% from "salt/map.jinja" import salt_settings with context %}    <======================

{% if salt_settings.install_packages and grains.os == 'MacOS' and salt_settings.salt_minion_pkg_source != '' and salt_settings.version != '' %}
{# only download IF we know where to get the pkg from and if we know what version to check the current install (if installed) against #}
{# e.g. don't download unless it appears as though we're about to try and upgrade the minion #}
download-salt-minion:
[...]
---

Versions Report

Salt Version:
           Salt: 2018.3.2
 
Dependency Versions:
           cffi: 1.10.0
       cherrypy: 3.7.0
       dateutil: 2.4.2
      docker-py: Not Installed
          gitdb: 0.6.4
      gitpython: 1.0.1
          ioflo: Not Installed
         Jinja2: 2.8
        libgit2: 0.24.0
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: 1.0.3
   msgpack-pure: Not Installed
 msgpack-python: 0.4.6
   mysql-python: Not Installed
      pycparser: 2.14
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: 0.24.0
         Python: 2.7.12 (default, Dec  4 2017, 14:50:18)
   python-gnupg: 0.3.8
         PyYAML: 3.11
          PyZMQ: 15.2.0
           RAET: Not Installed
          smmap: 0.9.0
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.1.4
 
System Versions:
           dist: Ubuntu 16.04 xenial
         locale: UTF-8
        machine: x86_64
        release: 4.4.0-135-generic
         system: Linux
        version: Ubuntu 16.04 xenial

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions