Skip to content

Instantly share code, notes, and snippets.

@slavafomin
Last active July 22, 2016 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slavafomin/7daa6247b47fed3ccf71 to your computer and use it in GitHub Desktop.
Save slavafomin/7daa6247b47fed3ccf71 to your computer and use it in GitHub Desktop.

Ansible recipes

Run task only when file is missing (present)

http://serverfault.com/q/610322/227777

tasks:
  - stat: path=/etc/somefile.conf
    register: st
  - template: src=somefile.j2 dest=/etc/somefile.conf
    when: not st.stat.exists

Set ACL permissions for user

tasks:
  - name: Removing all ACL entries
    shell: setfacl -R --remove-all {{ path }}

  - name: Adding ACL entries
    shell: setfacl -R -m u:{{ username }}:rX {{ path }}

  - name: Adding default ACL entries
    shell: setfacl -d -R -m u:{{ username }}:rX {{ path }}
@slmingol
Copy link

slmingol commented Jul 22, 2016

Ansible provides an actual module, acl, that is probably better to use than doing these in shells: http://docs.ansible.com/ansible/acl_module.html.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment