欢迎光临
我们一直在努力

3-ansible file模块

ansible file模块主要用于对文件的创建、删除、修改、权限、属性的维护和管理,file模块使用详解:

src ansible端源文件或者目录;
follow 支持link文件拷贝;
force 覆盖远程主机不一致的内容;
group 设定远程主机文件夹的组名;
mode 指定远程主机文件及文件权限;
owner 设定远程主机文件夹的用户名;
path 目标路径,也可以用dest,name代替;
state 状态包括:file、link、directory、hard、touch、absent;
attributes 文件或者目录特殊属性;

1.创建目录

[root@cent79-2 ~]# ansible all -m file -a \”path=/tmp/$(date +%F) state=directory mode=755\”

结果:

2.创建文件

[root@cent79-2 ~]# ansible all -m file -a \”path=/tmp/test.txt state=touch mode=644\”

结果:

<

赞(0)
未经允许不得转载:171主机测评 » 3-ansible file模块
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址