ansible windows系统win_file模块创建文件目录删除
参数 | 可选参数 | 作用 |
path | 文件路径 | |
state | 完成的操作 | |
absent | 归删除目录,并删除文件。 | |
directory | 如不存在,这创建目录 | |
file | 如果文件不存在,则不会创建该文件 | |
touch | 创建空文件 |
c、移动文件
[root@localhost ansible]# ansible win7 -m raw -a "cmd /c 'move /y d:\issue c:\issue'"
172.16.3.188 | SUCCESS | rc=0 >>
1 file(s) moved
d、创建文件夹
ansible windows -m raw -a "mkdir c:\\tst"
e、删除文件或目录
删除文件
ansible windows -m win_file -a "path=C:\issue state=absent"
f、结束某程序
先通过 tasklist获取运行程序信息
[root@localhost ansible]# ansible win7 -m raw -a "taskkill /F /IM QQ.exe /T"
172.16.3.188 | SUCCESS | rc=0 >>
SUCCESS: The process with PID 3504 (child process of PID 2328) has been terminated
playbook:
- name: 创建文件,如不存在,则创建;如果存在,则更新修改时间
win_file:
path: C:\Temp\foo.conf
state: touch
- name: 删除文件
win_file:
path: C:\Temp\foo.conf
state: absent
- name: 创建目录
win_file:
path: C:\Temp\folder\subfolder
state: directory
- name: 删除目录
win_file:
path: C:\Temp
state: absent
本文由 帝一博客 原创发布。用户在本站发布的原创内容(包括但不仅限于回答、文章和评论),著作权均归用户本人所有。独家文章转载,请联系邮箱:17762131@qq.com。获得授权后,须注明本文地址: https://bubukou.com/linuxyunwei/1826.html
-
一个小时学会搭建和使用 kubernetes
2021-12-07 17:36
-
linux生成公钥私钥ssh远程实现直接免密登录
2021-05-11 10:31
-
linux(centos)安装lrzsz上传下载软件rz,s...
2021-01-25 17:58
-
linux mkfs.ext4命令格式化硬盘
2021-01-15 14:54
-
查看linux系统增加根目录空间不足
2020-12-31 11:28
-
linux下如何tightvncserver安装使用图形化访...
2020-12-28 19:03
-
centos7中 yum跟python的安装【附带pytho...
2020-12-08 20:57
-
Centos 7.4系统Filebeat + Kafka +...
2020-12-07 10:45
-
CentOS 7系统搭建Rsyslog+LogAnalyze...
2020-12-03 22:12
-
linux groups命令显示指定用户帐户的组群成员身份
2020-11-29 15:52
网友留言评论