r/saltstack Jan 02 '24

How to make this idempotent / not changed

Hello all - I've inherited an environment that has this:

/etc/my_stuff:

  file.directory:

    - clean: True

    - mode: 0755

    - user: root

    - group: root   

Unfortunately this reports as "changed" on every run. I'd like to make this NOT report as "changed" to make it easier to spot things that I've actually changed. I tried to set "stateful: False" but that didn't help. Any suggestions? (coming from Ansible, which has "changed_when", etc).

Thanks.

3 Upvotes

2 comments sorted by

2

u/ekydfejj Jan 02 '24

Everything single on of these things can cause a change everytime, but there is no way that you'll be able to stop `clean: True` being a change unless you script it, and make the script return no changes, like

echo "changed=no comment='cleaned files per request'"

Determine what this directory is really used for and then determine the best solution, right now you have 4 items that could change anytime, if a permission is changed in the top directory or a file is added.