ganto/python-jinja2-26

Project ID: 17994

Description

RPM package for the jinja2 Python module which an be used by Ansible on RHEL/CentOS 6.

This package is meant to be used with the ansible RPM from EPEL 6 which by defaults only includes python-jinja2-26-2.6-3 from 2011 which is unfortunately missing a lot of nice features often used in Ansible such as the map filter. This repository offers a newer version (currently 2.7.2, same as RHEL/CentOS 7) which should bring the Ansible capabilities of the EPEL 6 package closer to the upstream features.

Spec file sources

github.com: ganto/copr-python-jinja2-26

Installation Instructions

Enable this COPR repository:

# cat <<EOF > /etc/yum.repos.d/copr_ganto-python-jinja2-26.repo [ganto-python-jinja2-26] name=Copr repo for python-jinja2-26 owned by ganto baseurl=https://copr-be.cloud.fedoraproject.org/results/ganto/python-jinja2-26/epel-\$releasever-\$basearch/ skip_if_unavailable=True gpgcheck=1 gpgkey=https://copr-be.cloud.fedoraproject.org/results/ganto/python-jinja2-26/pubkey.gpg enabled=1 enabled_metadata=1 EOF

Details

Default EPEL 6 Ansible:

# ansible --version ansible 2.4.2.0 config file = /etc/ansible/ansible.cfg configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python2.6/site-packages/ansible executable location = /usr/bin/ansible python version = 2.6.6 (r266:84292, Jul 23 2015, 15:22:56) [GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] # rpm -q python-jinja2-26 python-jinja2-26-2.6-3.el6.noarch

Using the Jinja2 map filter to read a value from a list of dictionaries:

# ansible -m debug localhost \ -e "{ 'mylist': [ {'mykey': 'myvalue1'}, {'mykey': 'myvalue2'} ] }" \ -a "msg={{ mylist | map(attribute='mykey') | list }}" [WARNING]: Could not match supplied host pattern, ignoring: all [WARNING]: provided hosts list is empty, only localhost is available localhost | FAILED! => { "msg": "template error while templating string: no filter named 'map'. String: {{ mylist | map(attribute='mykey') | list }}" }

Using ganto/python-jinja2-26 COPR repository:

# rpm -q python-jinja2-26 python-jinja2-26-2.7.2-1.el6.noarch

The Jinja2 map filter works now:

# ansible -m debug localhost \ -e "{ 'mylist': [ {'mykey': 'myvalue1'}, {'mykey': 'myvalue2'} ] }" \ -a "msg={{ mylist | map(attribute='mykey') | list }}" [WARNING]: Could not match supplied host pattern, ignoring: all [WARNING]: provided hosts list is empty, only localhost is available localhost | SUCCESS => { "changed": false, "msg": [ "myvalue1", "myvalue2" ] }

Active Releases

The following unofficial repositories are provided as-is by owner of this project. Contact the owner directly for bugs or issues (IE: not bugzilla).

Release Architectures Repo Download
EPEL 6 i386 (5)*, x86_64 (4)* EPEL 6 (289 downloads)

* Total number of downloaded packages.