saltstack: creating directory only if does not exists

cmidi picture cmidi · Jun 25, 2015 · Viewed 22.6k times · Source

Currently I have the following rule for creating a directory

/init/dir:
  file.recurse:
    - source:  salt://init_dir/init
    - user:  name
    - group:  group
    - name:  /path/init
    - dir_mode: 2775
    - file_mode: 777

Now I want to create a directory on new minions only if the directory does not exists already.

Answer

Utah_Dave picture Utah_Dave · Jun 27, 2015

While your example does work, it's not necessary. file.directory will only attempt to create the directory if it doesn't exist.