FreeKB - Ansible mode parameter
Ansible - mode parameter

The mode parameter can be used to define the standard permissions of a file or directory. For example, let's say you are using the copy module to copy a file. In this example, the copied file (foo.txt) would be have permissions 775, which is -rwxrwxr-x.

- name: "copy foo.txt to /tmp"
  copy:
    src: "foo.txt"
    dest: "/tmp"
    mode: "0775"

 

Here are the attributes of the copied file (foo.txt).

-rwxrwxr-x. 3 root root 4096 Jun 26 08:21 foo.txt

 

Alternately, the mode option can use the following syntax to add permissions.

- name: "add (+) read write execute (rwx) permsissions for user (u)"
  copy:
    src: "foo.txt"
    dest: "/tmp"
    mode: "u+rwx"

 

Or to remove permissions.

- name: "remove (-) execute (x) permission from other (o)"
  copy:
    src: "foo.txt"
    dest: "/tmp"
    mode: "o-x"

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter a5edf in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |