salt icon indicating copy to clipboard operation
salt copied to clipboard

Schedule a job to run "once" with timelib is not working

Open monofumado opened this issue 7 years ago • 3 comments

Description of Issue/Question.

I saw #49686 but it's already closed so I open a new one

When I try to set a schedule to run once using the format described in Jinja filters {{ "tomorrow"|strftime }} it can't be run from the master but it's working correctly using salt-call, when trying to run from the master I receive the following error:

minion01:
 Data failed to compile:
 ----------
 Rendering SLS 'base:schedule' failed: Jinja error: Unable to parse tomorrow. Consider installing timelib
 Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/utils/templates.py", line 393, in render_jinja_tmpl
    output = template.render(**decoded_context)
  File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 1008, in render
    return self.environment.handle_exception(exc_info, True)
  File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 780, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python2.7/dist-packages/jinja2/_compat.py", line 37, in reraise
    raise value.with_traceback(tb)
  File "<template>", line 1, in top-level template code
  File "/usr/lib/python2.7/dist-packages/salt/utils/dateutils.py", line 89, in strftime
    return date_cast(date).strftime(format)
  File "/usr/lib/python2.7/dist-packages/salt/utils/dateutils.py", line 60, in date_cast
    'Unable to parse {0}. Consider installing timelib'.format(date))
 RuntimeError: Unable to parse tomorrow. Consider installing timelib

; line 1

---
{% set tomorrow = "tomorrow" | strftime() %}    <======================

test:
  schedule.present:
    - name: test
[...]

Setup

The state I use to set the schedule (schedule.sls) is the following:

   {% set tomorrow = "tomorrow" | strftime() %}
   test:
      schedule.present:
        - name: test
        - function: test.ping
        - once:
            - {{ tomorrow }}

Steps to Reproduce Issue

When I apply the state (salt 'minion01' state.apply schedule) I receive the error mentioned above but if I apply via salt-call is set correctly. I run master and minion in the same machine.

Versions Report

Salt Version:
   Salt: 2018.3.3

Dependency Versions:
   cffi: Not Installed
  cherrypy: Not Installed
  dateutil: 2.5.3
 docker-py: Not Installed
      gitdb: 2.0.0
  gitpython: 2.1.1
     ioflo: Not Installed
     Jinja2: 2.9.4
    libgit2: Not Installed
   libnacl: Not Installed
  M2Crypto: Not Installed
      Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.8
  mysql-python: Not Installed
  pycparser: Not Installed
   pycrypto: 2.6.1
   pycryptodome: Not Installed
    pygit2: Not Installed
    Python: 2.7.13 (default, Sep 26 2018, 18:42:22)
  python-gnupg: Not Installed
    PyYAML: 3.12
     PyZMQ: 16.0.2
      RAET: Not Installed
     smmap: 2.0.1
   timelib: 0.2.4
    Tornado: 4.4.3
       ZMQ: 4.2.1

System Versions:
   dist: debian 9.5 
 locale: UTF-8
machine: x86_64
release: 4.9.0-8-amd64
 system: Linux
version: debian 9.6

monofumado avatar Jan 09 '19 14:01 monofumado

@monofumado do you have timelib installed on both master and minion?

dwoz avatar Jan 09 '19 19:01 dwoz

@dwoz , as said before, I run master and minion in the same machine and you can see in the output of salt --versions that timelib is installed, version (0.2.4)

monofumado avatar Jan 10 '19 11:01 monofumado

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

stale[bot] avatar Jan 09 '20 09:01 stale[bot]