yaml/mako on centos6.x

108 views
Skip to first unread message

MLister2006

unread,
Feb 23, 2013, 9:45:13 PM2/23/13
to salt-...@googlegroups.com
Anyone using yaml|mako on centos 6. I am getting traceback if when  running via master. Here is what I have done, may be I am missing something.

- Installed mako: (on minion and master as well)
  yum --enablerepo=epel install python-mako

- Created test.sls (just asked to render via mako. no mako templating yet)
------------
#!mako|yam

/tmp/test1:
  file.touch
-------------

- locally call from minon
# salt-call state.sls test   (works, w/o problem). Even I could render real mako template lines.

- call from master
# salt 'minion-host-id' state.sls test  (fails w/ traceback)

Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/salt/utils/templates.py", line 129, in render_mako_tmpl
    lookup=lookup
TypeError: __init__() got an unexpected keyword argument 'strict_undefined'

I have no issue if I use default jinja|yaml 
Both master and minions are centos6 and salt version 0.13.1



MLister2006

unread,
Feb 26, 2013, 6:43:44 PM2/26/13
to salt-...@googlegroups.com
It turns out to be an old version out of EPEL repo. Better install latest version from mako (pip install Mako) or compile your own RPM. Latest version of mako works well with salt.
 
I found mako is much richer than jinja2 (default for salt). You can literally use python code blocks with mako, which is pretty cool. I found some limitations with jinja thus looking for mako and loving it!
 
 

Clint Savage

unread,
Feb 26, 2013, 7:26:00 PM2/26/13
to salt-...@googlegroups.com
Consider "yum install 'salt*' --enablerepo=epel-testing". You will
find that 0.13.1 is happily waiting for you. The reason for this is
the EPEL release policy which requires 2 weeks in testing before it
can be released unless enough positive karma is given.

Cheers,

herlo
> --
> You received this message because you are subscribed to the Google Groups
> "Salt-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to salt-users+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

John Albietz

unread,
Feb 27, 2013, 3:36:47 AM2/27/13
to salt-...@googlegroups.com
definitely agree with mako over jinja for the same reasons u mention.

Instead of installing the mako package, I'd recommend installing python-pip and then 'pip install Mako'

To automate this for all your minions, add the following to your salt master config file. It'll allow all your sls files (including the top files) to use Mako:

```yaml
startup_states: sls
sls_list:
  - mako.sls
```

and the contents of mako.sls:

```yaml
mako-pip:
  pip.installed:
    - name: Mako
    - require:
      - pkg: pip-pkg

pip-pkg:
  pkg.installed:
    - name: python-pip
```

works on ubuntu 12.04 and rhel/centos 6.3 with salt 0.13.1

source here:

John Albietz

unread,
Feb 27, 2013, 3:40:46 AM2/27/13
to salt-...@googlegroups.com
Oops forgot one thing that got me with this... if you have ``renderer: mako|yaml`` set in your master file, you'll need to make sure to explicitly set the renderer for the mako.sls file to just ``#!yaml``. Otherwise it'll fail since it'll look for mako before trying to render the sls file using yaml. In general I've chosen to explicitly use the renderer hashbangs at the top of all sls files to remove any confusion. But for this file it is a requirement.

MLister2006

unread,
Feb 27, 2013, 10:45:11 AM2/27/13
to salt-...@googlegroups.com
Clint,
  thanks for your comment. But I was referring to old version of python-mako in EPEL (and not for salt).For salt I use latest from github (lives on the cutting edge ;). python mako version in epel is 0.3.x and the latest from http://www.makotemplates.org/ is 0.7.x that is working well w/ salt now.

MLister2006

unread,
Feb 27, 2013, 10:48:36 AM2/27/13
to salt-...@googlegroups.com
John,
  Wonderful and thanks for your valuable suggestions. Indeed I am going to change my defailt rendered to make|yaml in config files as I am moving from jinja2 -> mako now and avoiding #!mako|yaml per sls file.

--
You received this message because you are subscribed to a topic in the Google Groups "Salt-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/salt-users/Ie9esLMdiNM/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to salt-users+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages