Skip to content

Instantly share code, notes, and snippets.

@pcn
Forked from wongster80/gist:d246f28a1c713186387c
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pcn/aa724e00e58a1727c7e9 to your computer and use it in GitHub Desktop.
Save pcn/aa724e00e58a1727c7e9 to your computer and use it in GitHub Desktop.
This used to work on 2014.1.13 but fails on 2015.5.0 and 2015.5.2:
state init.sls file content:
{% set TEST_SYMLINK = '/opt/test_symlink' %}
{% if 0 == salt['cmd.retcode']('test -h '~ TEST_SYMLINK ~' ') %}
{{ TEST_SYMLINK }}:
file.symlink:
- target: /opt/yp
- force: True
{% endif %}
running salt-call on the state:
local:
Data failed to compile:
----------
Rendering SLS 'aidandev:test_state' failed: Jinja error: execve() argument 1 must be encoded string without NULL bytes, not str
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/salt/utils/templates.py", line 306, in render_jinja_tmpl
output = template.render(**decoded_context)
File "/usr/lib64/python2.6/site-packages/jinja2/environment.py", line 669, in render
return self.environment.handle_exception(exc_info, True)
File "<template>", line 18, in top-level template code
File "/usr/lib/python2.6/site-packages/salt/modules/cmdmod.py", line 1099, in retcode
use_vt=use_vt)
File "/usr/lib/python2.6/site-packages/salt/modules/cmdmod.py", line 387, in _run
proc = salt.utils.timed_subprocess.TimedProc(cmd, **kwargs)
File "/usr/lib/python2.6/site-packages/salt/utils/timed_subprocess.py", line 25, in __init__
self.process = subprocess.Popen(args, **kwargs)
File "/usr/lib64/python2.6/subprocess.py", line 642, in __init__
errread, errwrite)
File "/usr/lib64/python2.6/subprocess.py", line 1234, in _execute_child
raise child_exception
TypeError: execve() argument 1 must be encoded string without NULL bytes, not str
; line 18
---
[...]
- file: /tmp/dependent_file
- watch:
- file: managed_dependent_file
# If CDH parcels have been deployed create necessary symlinks
{% if 0 == salt['cmd.retcode']('test -h '~ TEST_SYMLINK ~' ') %} <======================
{{ TEST_SYMLINK }}:
file.symlink:
- target: /opt/yp
- force: True
{% endif %}
[...]
---

Tried the above with a slight change:

minion:

ubuntu@ip-10-233-137-171:~$ touch /tmp/bar
ubuntu@ip-10-233-137-171:~$ ln -s /tmp/bar /tmp/foo

master:

buntu@ip-10-181-82-107:/srv/salt$ sudo salt 'cassandradatanode3' state.sls foo
cassandradatanode3:
----------
          ID: /tmp/foo
    Function: file.symlink
      Result: True
     Comment: Created new symlink /tmp/foo -> /opt/yp
     Started: 01:01:10.309921
    Duration: 2.263 ms
     Changes:
              ----------
              new:
                  /tmp/foo

Summary
------------
Succeeded: 1 (changed=1)
Failed:    0
------------
Total states run:     1
ubuntu@ip-10-233-137-171:~$ salt-minion --version
salt-minion 2015.5.0 (Lithium)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment