salt icon indicating copy to clipboard operation
salt copied to clipboard

cmd.script state not working for users

Open thatch45 opened this issue 14 years ago • 9 comments

https://groups.google.com/forum/#!topic/salt-users/40UXMoB_eag%5B1-25%5D

thatch45 avatar Aug 10 '12 05:08 thatch45

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

thatch45 avatar Aug 10 '12 18:08 thatch45

rubbish, subprocess us giving us back a 0 whenever a script is called, this will need a little more digging

thatch45 avatar Aug 20 '12 19:08 thatch45

Isn't the shebang line unnecessary as the script is already being run by bash by default?

unicolet avatar Aug 23 '12 13:08 unicolet

No, the script can be any scripting language

thatch45 avatar Aug 30 '12 05:08 thatch45

this bug is biting me too, is someone working on fix?

alekibango avatar Sep 03 '12 10:09 alekibango

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

thatch45 avatar Sep 04 '12 16:09 thatch45

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)

alekibango avatar Sep 05 '12 11:09 alekibango

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)

alekibango avatar Sep 05 '12 23:09 alekibango

Thanks!

thatch45 avatar Sep 06 '12 14:09 thatch45