Ansible batch automated management tool-file module topic (5)

Create a directory and set permissions: (support recursion)

ansible all_remote -m file -a 'name=/tmp/dir1/test state=directory mode=0777'

Delete directory:

ansible all_remote -m file -a 'name=/tmp/dir1 state=absent'

Create a new file:

 ansible all -m file -a 'name=/tmp/file.txt state=touch mode=0777'

Delete Files:

 ansible all -m file -a 'name=/tmp/file.txt state=absent'

Create a soft connection:

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目录下

Insert picture description here

Delete soft connection:

ansible all -m file -a 'dest=/home/wb-user/tmp.link state=absent'

Create a file to specify the owner, permissions:

ansible all -m file -a ‘path=/root/a.sh owner=liych mode=755’

Guess you like

Origin blog.csdn.net/weixin_43010385/article/details/113062562