saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Install Salt from the Salt package repositories here:
https://docs.saltproject.io/salt/install-guide/en/latest/
Apache License 2.0
14.19k stars 5.48k forks source link

GitFS mountpoint option fails on Jinja imports #49783

Closed joni1993 closed 6 years ago

joni1993 commented 6 years ago

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 https://github.com/saltstack/salt/issues/39881 and https://github.com/saltstack/salt/issues/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: