4

How to work around Recursive directory management doesn't preserve permissions?

I want to copy all files in (local) /monitoring/files/etc to /etc on the minion.

copy_files_in_etc:
  file.recurse:
    - source:
      - salt://monitoring/files/etc
    - name: /etc
    - template: jinja

Above snippets works, but I am missing the executable bit for some files.

For example scripts in /etc/cron.daily should be executable.

What is the most simple way to work around this?

I search a way to make all files matching this expression to be executable:

/etc/cron.(daily|hourly|monthly|weekly/)

2 Answers 2

5

It looks like this was fixed.

copy_files_in_etc:
  file.recurse:
    - source:
    - salt://monitoring/files/etc
    - name: /etc
    - template: jinja
    - file_mode: keep

Search for file_mode at the following link: https://docs.saltstack.com/en/latest/ref/states/all/salt.states.file.html#salt.states.file.recurse

This will cause the files to have the same mode as on the salt master.

1
  • file_mode: keep for file.recurse
    – Dereckson
    Nov 22, 2017 at 3:41
1

You can use file_mode and dir_mode. In your case, file_mode should be enough.

copy_files_in_etc:
  file.recurse:
    - source:
      - salt://monitoring/files/etc
    - name: /etc
    - template: jinja
    - file_mode: '0755'
2
  • Yes, this would set the executable bit for all files in /etc/cron.(daily|hourly|monthly|weekly/), but it would set it on all other files in /etc, too.
    – guettli
    Nov 28, 2016 at 13:09
  • Perhaps it's better to make different ids (sections) in one SLS file, which each manages a subsection. Having one SLS for the entire /etc will also make it hard to roll out changes in a controlled manner. Your monitoring.sls could have the id cron_files, nagios_files, misc_daemon_files, etc.
    – Halfgaar
    Nov 28, 2016 at 14:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .