Ansible file module


state : absent, directory, file, hard, link, touch

  1. Change File Attributes
    ansible all -m file -a 'path=/root/bb owner=laconic group=laconic mode=7777'
  2. Create Hard & Symbolic Link & Remove
    ansible all -m file -a 'path=/root/laconic force=yes state=link | hard | absent'
  3. Create Directories
    ansible all -m file -a 'path=/a/b/c state=directory'
  4. Create File
    ansible all -m file -a 'path=/root/bb/cc state=touch mode=7777'  # /root/bb must exists
  5. Recurse
    ansible all -m file -a 'path=/tmp owner=root group=root mode=7777 recurse=yes'