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

Jinja2 filter strftime stopped working in salt-ssh 2018.3 #46668

Closed
anlutro opened this issue Mar 22, 2018 · 1 comment
Closed

Jinja2 filter strftime stopped working in salt-ssh 2018.3 #46668

anlutro opened this issue Mar 22, 2018 · 1 comment
Assignees
Labels
Bug broken, incorrect, or confusing behavior fixed-pls-verify fix is linked, bug author to confirm fix P2 Priority 2 severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around
Milestone

Comments

@anlutro
Copy link
Contributor

anlutro commented Mar 22, 2018

I'm using salt-ssh from a virtualenv and a checked out git repository. It worked fine using 2017.7, but 2018.3 fails because at least one Jinja filter no longer seems to be present:

$ salt-ssh odin state.apply
[ERROR   ] Can't find varstack master_top
[ERROR   ] Rendering exception occurred
Traceback (most recent call last):
  File "/home/andreas/code/contrib/salt/salt/utils/templates.py", line 378, in render_jinja_tmpl
    template = jinja_env.from_string(tmplstr)
  File "/home/andreas/code/contrib/salt/.venv/lib/python3.5/site-packages/jinja2/environment.py", line 880, in from_string
    return cls.from_code(self, self.compile(source), globals, None)
  File "/home/andreas/code/contrib/salt/.venv/lib/python3.5/site-packages/jinja2/environment.py", line 591, in compile
    self.handle_exception(exc_info, source_hint=source_hint)
  File "/home/andreas/code/contrib/salt/.venv/lib/python3.5/site-packages/jinja2/environment.py", line 780, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/andreas/code/contrib/salt/.venv/lib/python3.5/site-packages/jinja2/_compat.py", line 37, in reraise
    raise value.with_traceback(tb)
  File "<unknown>", line 4, in template
  File "/home/andreas/code/contrib/salt/.venv/lib/python3.5/site-packages/jinja2/environment.py", line 543, in _generate
    optimized=self.optimized)
  File "/home/andreas/code/contrib/salt/.venv/lib/python3.5/site-packages/jinja2/compiler.py", line 82, in generate
    generator.visit(node)
  File "/home/andreas/code/contrib/salt/.venv/lib/python3.5/site-packages/jinja2/visitor.py", line 38, in visit
    return f(node, *args, **kwargs)
  File "/home/andreas/code/contrib/salt/.venv/lib/python3.5/site-packages/jinja2/compiler.py", line 754, in visit_Template
    self.blockvisit(node.body, frame)
  File "/home/andreas/code/contrib/salt/.venv/lib/python3.5/site-packages/jinja2/compiler.py", line 378, in blockvisit
    self.visit(node, frame)
  File "/home/andreas/code/contrib/salt/.venv/lib/python3.5/site-packages/jinja2/visitor.py", line 38, in visit
    return f(node, *args, **kwargs)
  File "/home/andreas/code/contrib/salt/.venv/lib/python3.5/site-packages/jinja2/compiler.py", line 1371, in visit_Assign
    self.visit(node.node, frame)
  File "/home/andreas/code/contrib/salt/.venv/lib/python3.5/site-packages/jinja2/visitor.py", line 38, in visit
    return f(node, *args, **kwargs)
  File "/home/andreas/code/contrib/salt/.venv/lib/python3.5/site-packages/jinja2/compiler.py", line 70, in new_func
    return f(self, node, frame, **kwargs)
  File "/home/andreas/code/contrib/salt/.venv/lib/python3.5/site-packages/jinja2/compiler.py", line 1578, in visit_Filter
    self.fail('no filter named %r' % node.name, node.lineno)
  File "/home/andreas/code/contrib/salt/.venv/lib/python3.5/site-packages/jinja2/compiler.py", line 315, in fail
    raise TemplateAssertionError(msg, lineno, self.name, self.filename)
jinja2.exceptions.TemplateAssertionError: no filter named 'strftime'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/andreas/code/contrib/salt/salt/utils/templates.py", line 169, in render_tmpl
    output = render_str(tmplstr, context, tmplpath)
  File "/home/andreas/code/contrib/salt/salt/utils/templates.py", line 400, in render_jinja_tmpl
    tmplstr)
salt.exceptions.SaltRenderError: Jinja syntax error: no filter named 'strftime'; line 4

---
# This state ensures that there is a daily backup in the form of a tarball in
# /var/backups/yyyy-mm-dd.tar.

{% set date = none | strftime('%Y-%m-%d') %}    <======================
{% set backup_dir = '/var/backups' %}
{% set script_path = '/usr/local/sbin/backup' %}

{{ backup_dir }}:
  file.directory:
[...]
$ salt-ssh --versions
Salt Version:
           Salt: 2018.3.0-260-g2e1f7c3
 
Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: Not Installed
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.10
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.5.6
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 3.5.3 (default, Jan 19 2017, 14:11:04)
   python-gnupg: Not Installed
         PyYAML: 3.12
          PyZMQ: 17.0.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.5.3
            ZMQ: 4.1.6
 
System Versions:
           dist: debian 9.4 
         locale: UTF-8
        machine: x86_64
        release: 4.9.0-6-amd64
         system: Linux
        version: debian 9.4
@garethgreenaway garethgreenaway added this to the Approved milestone Mar 22, 2018
@garethgreenaway garethgreenaway added Bug broken, incorrect, or confusing behavior severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around P2 Priority 2 labels Mar 22, 2018
@garethgreenaway garethgreenaway self-assigned this Mar 27, 2018
@garethgreenaway garethgreenaway added the fixed-pls-verify fix is linked, bug author to confirm fix label Mar 27, 2018
@anlutro
Copy link
Contributor Author

anlutro commented Mar 29, 2018

Can confirm this is fixed 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior fixed-pls-verify fix is linked, bug author to confirm fix P2 Priority 2 severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around
Projects
None yet
Development

No branches or pull requests

2 participants