创建目录,并设置权限:(支持递归)
ansible all_remote -m file -a 'name=/tmp/dir1/test state=directory mode=0777'
删除目录:
ansible all_remote -m file -a 'name=/tmp/dir1 state=absent'
创建新文件:
ansible all -m file -a 'name=/tmp/file.txt state=touch mode=0777'
删除文件:
ansible all -m file -a 'name=/tmp/file.txt state=absent'
创建软连接:
ansible all_remote -m file -a 'src=/tmp dest=/home/wb-user/tmp.link state=link'
【参数】
目标: /tmp
软连接:/home/wb-user/tmp.link
意思: 访问/home/wb-user/tmp.link直接跳转到/tmp目录下
删除软连接:
ansible all -m file -a 'dest=/home/wb-user/tmp.link state=absent'
创建文件指定所有者,权限:
ansible all -m file -a ‘path=/root/a.sh owner=liych mode=755’