Skip to content

[BUG] use of tpldir variable does not allow the formula to be wrapped #295

Description

@eedgar

Your setup

Formula commit hash / release tag

starting from e2e1be1

Versions reports (master & minion)

Salt Version:
Salt: 3002.1

Dependency Versions:
cffi: Not Installed
cherrypy: Not Installed
dateutil: 2.7.3
docker-py: Not Installed
gitdb: 2.0.6
gitpython: 3.0.7
Jinja2: 2.10.1
libgit2: Not Installed
M2Crypto: Not Installed
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.6.2
mysql-python: Not Installed
pycparser: Not Installed
pycrypto: Not Installed
pycryptodome: 3.6.1
pygit2: Not Installed
Python: 3.8.5 (default, Jul 28 2020, 12:59:40)
python-gnupg: 0.4.5
PyYAML: 5.3.1
PyZMQ: 18.1.1
smmap: 2.0.5
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.3.2

System Versions:
dist: ubuntu 20.04 focal
locale: utf-8
machine: x86_64
release: 5.4.0-52-generic
system: Linux
version: Ubuntu 20.04 focal

Pillar / config used

trying to extend the formula by creating a new www/init.sls and having the contents look like this
{% from "apache/map.jinja" import apache with context %}
include:

  • apache
    apache-config-custom-global:
    file.managed:
    • name: {{ apache.confdir }}/custom-global.{{ apache.confext }}
    • source: salt://www/files/custom-global.conf
    • mode: 644
    • makedirs: True
    • template: {{ apache.get('template_engine', 'jinja') }}
    • context:
      apache: {{ apache|json }}
    • require:
      • pkg: apache-package-install-pkg-installed
    • watch_in:
      • module: apache-service-running-restart
    • require_in:
      • module: apache-service-running-restart
      • module: apache-service-running-reload
      • service: apache-service-running

gives this error
local:
Data failed to compile:
----------
Rendering SLS 'base:www' failed: Jinja error: www/defaults.yaml
/var/cache/salt/minion/files/base/apache/map.jinja(5):
---
# -- coding: utf-8 --
# vim: ft=jinja

{%- set tplroot = tpldir.split('/')[0] %}
{%- import_yaml tplroot ~ "/defaults.yaml" as default_settings %}    <======================
{%- import_yaml tplroot ~ "/osarchmap.yaml" as osarchmap %}
{%- import_yaml tplroot ~ "/osfamilymap.yaml" as osfamilymap %}
{%- import_yaml tplroot ~ "/osmap.yaml" as osmap %}
{%- import_yaml tplroot ~ "/osfingermap.yaml" as osfingermap %}
{%- import_yaml tplroot ~ "/oscodenamemap.yaml" as oscodename %}
[...]

the workaround

{% set curr_tpldir = tpldir %}
{% set tpldir = 'apache' %}
{% from "apache/map.jinja" import apache with context %}
{% set tpldir = curr_tpldir %}
include:

  • apache
    apache-config-custom-global:
    file.managed:
    • name: {{ apache.confdir }}/custom-global.{{ apache.confext }}
    • source: salt://www/files/custom-global.conf
    • mode: 644
    • makedirs: True
    • template: {{ apache.get('template_engine', 'jinja') }}
    • context:
      apache: {{ apache|json }}
    • require:
      • pkg: apache-package-install-pkg-installed
    • watch_in:
      • module: apache-service-running-restart
    • require_in:
      • module: apache-service-running-restart
      • module: apache-service-running-reload
      • service: apache-service-running

Bug details

Describe the bug

replace the tpldir/tplroot logic with hardcoded apache paths

Steps to reproduce the bug

Expected behaviour

Attempts to fix the bug

Additional context

Activity

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

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