Alternatively to the onlyif: test -d /var/log/backup
approach (that is probably the best one) you can:
1) Wrap everything with a jinja if:
{%- if salt['file.directory_exists' ]('/var/log/backup') %}
backup_log_readable:
acl.present:
- name: /var/log/backup
- acl_type: user
- acl_name: monitor
- perms: rx
- recurse: True
{%- endif %}
2) use the file.exists
state as a requisite:
backup_log_exists:
file.exists:
- name: /var/log/backup
backup_log_readable:
acl.present:
- name: /var/log/backup
- acl_type: user
- acl_name: monitor
- perms: rx
- recurse: True
- require:
- file: backup_log_exists
This way you'll see a failed state in the summary, so it won't be totally transparent as with the onlyif and jinja approaches
3) create the directory before running the acl state:
backup_log_dir:
file.directory:
- name: /var/log/backup
backup_log_readable:
acl.present:
- name: /var/log/backup
- acl_type: user
- acl_name: monitor
- perms: rx
- recurse: True
- require:
- file: backup_log_dir