Search code examples
linuxsalt-project

saltstack: is there a way to stop updating cron files every time state.highstate is run


Currently I have the following cron.file formula

date > system_cron:
  cron.file:
    - name:  salt://crons/cron_jobs
    - source_hash:  "md5sum=895dcbbddd27bfa77056ef8c8340549a"
    - user:  security

But this updates the crontab each time the highstate is run event though the cron_jobs file has not changed and hence the state is the same. Is there a way to stop creating temp crontab file each time highstate is run when using cron.file


Solution

  • I found that this happens when you have blank lines at the end of the file, or if you have dos line endings instead of unix line endings. Once this has been changed, the file will only be updated when it has changed.

    Please note: as you have placed the file in "salt://", you don't need source_hash. This is only required for remote (i.e. http) files.