Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CentOS 6] mapping test not supported, master config cannot be generated #193

Open
blast-hardcheese opened this issue Dec 11, 2015 · 11 comments

Comments

@blast-hardcheese
Copy link
Contributor

Unfortunately, since CentOS 6 only ships with Jinja2 2.2.1, the mapping test is not supported. Looking through the documentation, I don't see anything else equivalent to it (both iterable and sequence test true for dicts and lists), so I'm not sure how to maintian functionality without that test.

Tapping @Sjd-Risca, just in case they have some idea

@blast-hardcheese
Copy link
Contributor Author

Until this is resolved, the last good version that works on CentOS 6 is a33937d

@gravyboat
Copy link
Contributor

Hmm, could we create a flag to include a different file if the os grain is centos 6? I can't remember if it would still get parsed in that situation.

Looks like the latest available from EPEL is also 2.26: https://dl.fedoraproject.org/pub/epel/6/x86_64/repoview/python-jinja2-26.html, and I don't think that has mapping support either.

@0xf10e
Copy link
Contributor

0xf10e commented Feb 8, 2016

Seriously, no one will like this hack, but at least it renders:

{% if 'ext_pillar' in cfg_master %}
{#- workaround for missing mapping test in CentOS 6, part A #}
{%- set is_mapping = {} %}
ext_pillar:
{%- for pillar in cfg_master['ext_pillar'] -%}
  {%- for key in pillar -%}
    {%- if pillar[key] is string %}
  - {{ key }}: {{ pillar[key] }}
    {#- workaround for missing mapping test in CentOS 6, part B #}
    {%- do is_mapping.update({key: type(pillar[key]) == type({})}) %}
    {%- elif pillar[key] is iterable and not is_mapping[key] %}
  - {{ key }}:
      {%- for parameter in pillar[key] %}
    - {{ parameter }}
      {%- endfor -%}
    {#- workaround for missing mapping test in CentOS 6, part C #}
    {%- elif is_mapping[key] and pillar[key] is not string %}

@0xf10e
Copy link
Contributor

0xf10e commented Feb 8, 2016

(I got this hack in a local git-clone of the formula if anyone is interested)

@mchugh19
Copy link

The mapping configs also affect minion runs.

SaltRenderError: Jinja syntax error: no test named 'mapping'; line 671

              ---
              [...]
              ext_pillar:
              {%- for pillar in cfg_minion['ext_pillar'] -%}
                {%- for key in pillar -%}
                  {%- if pillar[key] is string %}
                - {{ key }}: {{ pillar[key] }}
                  {%- elif pillar[key] is iterable and pillar[key] is not mapping %}    <======================

@mchugh19
Copy link

mchugh19 commented Feb 3, 2017

@0xf10e Would you be interested in submitting a PR? The missing jinja mapping logic now breaks RHEL6 minions and masters.

@0xf10e
Copy link
Contributor

0xf10e commented Feb 24, 2017

@mchugh19 Oh, this is still open? Let me see if my diff still applies...

0xf10e added a commit to 0xf10e/salt-formula that referenced this issue Feb 24, 2017
 !!   Not tested with an actual   !!
 !!  configured `ext_pillar` yet  !!

- jinja on RHEL/CentOS 6 has no 'mapping'
  test (see salt-formula issue saltstack-formulas#193)
- {% do ... %} allows no assignment, only
  function calls
- of course, `type(foo) is dict` doesn't
  work because it's no jinja test
- maybe `.isinstance()` would be nicer/more
  reliable
@0xf10e
Copy link
Contributor

0xf10e commented Feb 24, 2017

⚠️ #298 is not tested yet! ⚠️

@0xf10e
Copy link
Contributor

0xf10e commented Feb 24, 2017

As mentions in #298: Only tested basic functionality on CentOS 6.
Not tried CentOS 7, Debian, Ubuntu, *BSD... yet (and won't today).

@tedski
Copy link

tedski commented Mar 29, 2017

#298 breaks Debian latest (isolated to e86e6fc via git bisect):

    Data failed to compile:
----------
    Rendering SLS 'base:salt.gitfs.pygit2' failed: Jinja variable 'dict object' has no attribute 'build_parent_dir'

nareshov pushed a commit to rocket-labs-sysadmins/salt-formula that referenced this issue Sep 25, 2017
 !!   Not tested with an actual   !!
 !!  configured `ext_pillar` yet  !!

- jinja on RHEL/CentOS 6 has no 'mapping'
  test (see salt-formula issue saltstack-formulas#193)
- {% do ... %} allows no assignment, only
  function calls
- of course, `type(foo) is dict` doesn't
  work because it's no jinja test
- maybe `.isinstance()` would be nicer/more
  reliable
@aboe76
Copy link
Member

aboe76 commented Jan 25, 2019

If I look in the changelog file of jinja2 version 2.6 has mapping:
http://jinja.pocoo.org/docs/2.10/changelog/#version-2-6

and the salt repo for centos 6 py27, already ships with jinja2 2.8.1

I don't think this is necessary any more and we can opt for a cleaner map.jinja
maybe something like the apache-formula:

  • map.jinja
  • defaults.yaml
  • osfamilymap.yaml
  • oscodenamemap.yaml
  • osfingermap.yaml

which will in turn keep everything nice and separated. which is easier to maintain and contribute.

myii added a commit that referenced this issue Jan 26, 2019
Simplify map.jinja revert deep_merge solution from #193
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants