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

salt.minion fails with syntax error: no test named 'mapping' RHEL6/Jinja 2.2.1 #170

Closed
bradthurber opened this issue Aug 12, 2015 · 13 comments

Comments

@bradthurber
Copy link
Contributor

It looks like mapping test requires Jinja2 v2.6 or higher and I'm on 2.2.1 - which is the best RHEL 6 provides.

          ID: salt-minion
    Function: file.recurse
        Name: /etc/salt/minion.d
      Result: False
     Comment: #### /etc/salt/minion.d/f_defaults.conf ####
              Unable to manage file: Jinja syntax error: no test named 'mapping'
              /var/cache/salt/minion/files/base/salt/formulas.jinja(14):
              ---
              [...]

              {%- macro formulas_git_opt(env, opt) -%}
              {%- set value = salt['pillar.get']('salt_formulas:git_opts:{0}:{1}'.format(env, opt),
                   salt['pillar.get']('salt_formulas:git_opts:default:{0}'.format(opt),
                     defaults[opt])) -%}
              {%- if value is mapping -%}    <======================
              {{ value|yaml }}
              {%- else -%}
              {{ value }}
              {%- endif -%}
              {%- endmacro -%}
# salt-master --versions
           Salt: 2015.5.3
         Python: 2.6.6 (r266:84292, Nov 21 2013, 10:50:32)
         Jinja2: 2.2.1
       M2Crypto: 0.20.2
 msgpack-python: 0.4.6
   msgpack-pure: Not Installed
       pycrypto: 2.0.1
        libnacl: Not Installed
         PyYAML: 3.10
          ioflo: Not Installed
          PyZMQ: 14.5.0
           RAET: Not Installed
            ZMQ: 4.0.5
           Mako: 0.3.4
        Tornado: Not Installed
@bradthurber
Copy link
Contributor Author

It looks like I'm not the first to run into this: saltstack/salt#11267

Maybe a "This formula requires jinja2 2.6.0 or later" notice could be put at the top of this formula's README.rst file so others don't go down this rabbit hole?

@puneetk
Copy link
Contributor

puneetk commented Aug 12, 2015

@bradthurber yes, good call, could you send a pull to the readme with that notice. Also i recommend trying to add jinja 2.6 your deployment, not sure what other features are missing.

@pgporada
Copy link

On centos 6, you can install python-jinja2-26 from the EPEL repo. However, the problem is then figuring out how to make salt use python-jinja2-26 instead of python-jinja2. Does anyone know how to do this?

@gravyboat
Copy link
Contributor

@pgporada You'd have to repackage salt and make that the requirement instead of python-jinja2, I highly recommend against that. Can you not simply host the python-jinja2 package internally?

@pgporada
Copy link

Gravyboat, I'm not exactly sure how to do that. Would that be hosting my own yum repository?

@gravyboat
Copy link
Contributor

@pgporada Yep! Or if you wanted you could create a local yum repo: https://wiki.centos.org/HowTos/CreateLocalRepos obviously this isn't as clean or as flexible as a full blown repo, but it's easier to set up.

@iggy
Copy link
Contributor

iggy commented Aug 27, 2015

Or we could just take that mapping test out of the formula...

@gravyboat
Copy link
Contributor

@iggy I figured people didn't want to do that otherwise they would have just forked and done it themselves.

@iggy
Copy link
Contributor

iggy commented Aug 27, 2015

That's what I did. I just never got around to pushing it back upstream. Guess I've got one more thing I need to do before I move on.

@gravyboat
Copy link
Contributor

#173 should fix this one. Please confirm and we'll close this. Thanks @iggy.

@bradthurber
Copy link
Contributor Author

Confirmed salt.minion working now with latest version of formula and Jinja 2.2.1

@gravyboat
Copy link
Contributor

Thanks for confirming @bradthurber!

@keesbos
Copy link

keesbos commented Nov 24, 2015

BTW. This is what I did for RedHat 6 etc to update jinja2:

su -
cd /tmp
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | python
easy_install -U jinja2
python -c 'import jinja2;print jinja2.__version__'
rm -f setuptools-18.5.zip
service salt-minion restart

Note that this changes the use of jinja2 system wide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants