ansible windows系统win_file模块创建文件目录删除

摘要: ansible windows系统win_file模块创建文件目录删除,ansible,windows,系统,win_file,模块,linux运维,好用的linux运维指南,您值得拥有

 

参数可选参数作用
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

网友留言评论

0条评论