Skip to content

[BUG] Salt-formula don't render pillar from imported yaml map file #508

@schirka

Description

@schirka

Your setup

Formula commit hash / release tag

1.8.5

Versions reports (master & minion)

salt-master:

Salt Version:
          Salt: 3002.6
 
Dependency Versions:
          cffi: Not Installed
      cherrypy: Not Installed
      dateutil: Not Installed
     docker-py: Not Installed
         gitdb: 0.6.4
     gitpython: 1.0.1
        Jinja2: 3.0.1
       libgit2: Not Installed
      M2Crypto: 0.35.2
          Mako: Not Installed
       msgpack: 1.0.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: Not Installed
      pycrypto: Not Installed
  pycryptodome: 3.10.1
        pygit2: Not Installed
        Python: 3.6.8 (default, Nov 16 2020, 16:55:22)
  python-gnupg: Not Installed
        PyYAML: 5.4.1
         PyZMQ: 22.1.0
         smmap: 0.9.0
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.4
 
System Versions:
          dist: centos 7 Core
        locale: UTF-8
       machine: x86_64
       release: 3.10.0-1160.25.1.el7.x86_64
        system: Linux
       version: CentOS Linux 7 Core

Salt-minion

Salt Version:
          Salt: 3002.6
 
Dependency Versions:
          cffi: Not Installed
      cherrypy: Not Installed
      dateutil: Not Installed
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 3.0.1
       libgit2: Not Installed
      M2Crypto: 0.35.2
          Mako: Not Installed
       msgpack: 1.0.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: Not Installed
      pycrypto: Not Installed
  pycryptodome: 3.10.1
        pygit2: Not Installed
        Python: 3.6.8 (default, Nov 16 2020, 16:55:22)
  python-gnupg: Not Installed
        PyYAML: 5.4.1
         PyZMQ: 22.1.0
         smmap: Not Installed
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.4
 
System Versions:
          dist: centos 7 Core
        locale: UTF-8
       machine: x86_64
       release: 3.10.0-1160.25.1.el7.x86_64
        system: Linux
       version: CentOS Linux 7 Core

Pillar / config used

/etc/salt/master

gitfs_provider: gitpython
gitfs_remotes:
  - https://github.com/saltstack-formulas/salt-formula

pillar_roots:
  base:
  - /srv/pillar
---

Bug details

Describe the bug

salt['pillar.get'] is not rendered by import_yaml

map.jinja(line 6,7.8)

...
{% import_yaml "salt/osfamilymap.yaml" as osfamilymap %}
{% import_yaml "salt/osmap.yaml" as osmap %}
{% import_yaml "salt/osfingermap.yaml" as osfingermap %}
...

<osfamilymap.yaml(line 5)>
...
{%- set py_ver_repr = salt['pillar.get']('salt:py_ver', '') %}
...


<osmap.yaml(line 5)>
...
{%- set py_ver_repr = salt['pillar.get']('salt:py_ver', '') %}
...

<osfingermap.yaml(line 5)>
...
{%- set py_ver_repr = salt['pillar.get']('salt:py_ver', '') %}
...

Steps to reproduce the bug

 $ salt-call state.apply salt.minion -l debug

> local:
>     Data failed to compile:
> ----------
>     Rendering SLS 'base:salt.minion' failed: Jinja variable 'salt' is undefined
> /var/cache/salt/minion/files/base/salt/osfamilymap.yaml(5):
> ---
> # -*- coding: utf-8 -*-
> # vim: ft=yaml
> ---
> 
> {%- set py_ver_repr = salt['pillar.get']('salt:py_ver', '') %}    <======================
> 
> {%- set osrelease = salt['grains.get']('osrelease', '') %}
> {%- set salt_release = salt['pillar.get']('salt:release', 'latest') %}
> {%- if salt_release.split('.')|length >= 3 %}
> {%-   set salt_release = 'archive/' ~ salt_release %}
> [...]
> ---
> ----------

Expected behaviour

Expect the formula to render

Attempts to fix the bug

For salt['pillar.get'] to be rendered by import_yaml, it needs with context

map.jinja(line 6,7.8)

...
{% import_yaml "salt/osfamilymap.yaml" as osfamilymap with context %}
{% import_yaml "salt/osmap.yaml" as osmap with context %}
{% import_yaml "salt/osfingermap.yaml" as osfingermap with context %}
...

Additional context

salt-formula is now rendering properly.

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