0

How to rewrite shell task in to file module task

For example

  - name: Change permissions.
    shell: "chown -R {{ project_user }}:{{ project_user }} {{ project_root }}"

How to rewrite above code with the help of file module ?

Artem Bernatskyi
  • 4,185
  • 2
  • 26
  • 35
  • 1
    Possible duplicate of [Ansible - Mode 755 for directories and 644 for files recursively](http://stackoverflow.com/questions/28778738/ansible-mode-755-for-directories-and-644-for-files-recursively) – Zlemini Feb 22 '17 at 18:00

1 Answers1

3

That's pretty simple:

- file:
    path: "{{ project_root }}"
    owner: "{{ project_user }}"
    group: "{{ project_user }}"
    recurse: true

Have a look at the examples: https://docs.ansible.com/ansible/file_module.html#id3

flxPeters
  • 1,476
  • 12
  • 21