saltstack-formulas / logrotate-formula

http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html
Other
23 stars 71 forks source link

'is mapping' work around? #14

Closed zanhsieh closed 9 years ago

zanhsieh commented 9 years ago

Hi, I encounter this issue on salt 2015.5.0 @ CentOS 6:

[root@master /]# salt 'minion1' state.highstate saltenv=os_tb
minion1:
    Data failed to compile:
----------
    No matching sls found for 'logrotate.conf' in env 'os_tb'
----------
    Rendering SLS 'os_tb:logrotate.jobs' failed: Jinja syntax error: no test named 'mapping'; line 22

---
[...]
    - require:
      - pkg: logrotate
    - watch_in:
      - service: {{ logrotate.service }}
    - context:
      {% if value is mapping %}    <======================
      path: {{ value.get('path', key) }}
      data: {{ value.get('config', []) }}
      {% else %}
      path: {{ key }}
      data: {{ value }}
[...]

---
[root@master /]# salt-master --versions
           Salt: 2015.5.0
         Python: 2.6.6 (r266:84292, Jan 22 2014, 09:42:36)
         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.3.1
           RAET: Not Installed
            ZMQ: 3.2.5
           Mako: Not Installed

Besides upgrade jinja2 per this link, just wonder if there's anyway to go around. Thanks.

zanhsieh commented 9 years ago

My other configuration in case it's needed:

/srv/salt/os/tb/top.sls
os_tb:
  '*':
    - logrotate.conf
    - logrotate.jobs

/srv/pillar/os/tb/top.sls
os_tb:
  '*':
    - logrotate

/srv/pillar/os/tb/logrotate.sls
# vim: sts=2 ts=2 sw=2 et ai
logrotate:
  lookup:
    pkg: logrotate
    service: crond
  jobs:
    yum:
      path: /var/log/yum.log
      config:
        - missingok
        - notifempty
        - yearly
        - create 0600 root root
iggy commented 9 years ago

Your best bet is to upgrade jinja probably. You might be able to roll back to a version before that was introduced (try git checkout 8f64b9ab0333c5d6fe934e94b2e31108a7a17ec6 )

zanhsieh commented 9 years ago

Problem indeed solved after rollback to 8f64b9a. I will close this issue.

grizo commented 8 years ago

@zanhsieh rather than rolling back, i ended up updating Jinja2 via pip then restarting the minion on el6 nodes. just incase anyone else runs into this issue.