cmd.script state not working for users
https://groups.google.com/forum/#!topic/salt-users/40UXMoB_eag%5B1-25%5D
I found that retcode is always 0 even if script actually returns non-zero code
state file:
salt://init.sh:
cmd:
- script
script:
#!/bin/bash
exit 2
salt version: 0.10.2
Regards, Marat
rubbish, subprocess us giving us back a 0 whenever a script is called, this will need a little more digging
Isn't the shebang line unnecessary as the script is already being run by bash by default?
No, the script can be any scripting language
this bug is biting me too, is someone working on fix?
it is not being actively worked on, I have run into some issues fixing it and have temporarily put it off. Any help would be appreciated
ok, trying to identify the problem, i found out that:
salt-call state.sls state_with_script gives wrong stdout/stderr/retcode
salt call cmd.script salt://script.sh works right.
Later i will dig into this deeper. but i would like to start with test! i would like to write test which will fail and then patch the source to make the test pass. Someone please help a bit with issue #1920 (Write tutorial on how to do test driven development with salt)
i fixed the problem locally only to find out that its fixed in git already: 24dcfa03e883151f902c4d7b91fe0a38219f57d8
You can close this issue. this is the relevant code from salt/modules/cmdmod.py:
if template:
- fn_ = __salt__['cp.get_template'](source, path, template, env, **kwargs)
+ __salt__['cp.get_template'](source, path, template, env, **kwargs)
else:
fn_ = __salt__['cp.cache_file'](source, env)
+ shutil.copyfile(fn_, path)
Thanks!