Bootstrap FreeKB - Ansible - mode parameter
Ansible - mode parameter

Updated:   |  Ansible articles

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"

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


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