I am doing some operations with Kafka via salt, and using scripts to perform them.

My current SLS file looks roughly like:

    - source: salt://blah/blah

Run script:
    - name: /tmp/script.sh

delete /tmp/script.sh:
    - name: /tmp/script.sh

script.sh is idempotent itself. But I always get a changed=2 status report at the end of applying the state, because of it putting the script down and then deleting it.

Is there a more idiomatic way in Salt to have temporary scripts that don't live on the target box? Or do people usually just leave them in /tmp so that they don't see a reported change when applying a state.

1 Answer 1


You might want to consider adding an unless or onlyif requisite in the first directive - especially if script.sh is particularly complicated or expensive. With unless or onlyif, you will use the reults of several BASH commands to determine if you need to push down and execute your script. If your system is out of plumb only then is the state enforced. If everything checks out OK, then the script will never be pushed and executed preventing changed=2 in the final status report. You will want to use a require requisite for the second and third directives to prevent them from running if the script is not pushed by file.managed otherwise you will get to errors instead of two changes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.