ansible Ad-Hoc

一、file (文件管理)

1、在所有节点/tmp/目录下创建heheha.txt文件
# ansible all -m file -a "dest=/tmp/hehehah.txt state=touch"

2、在所有节点/tmp/目录下创建heheha目录并赋予相应权限
# ansible all -m file -a "dest=/tmp/heheha mode=755 owner=mageedu group=mageedu state=directory"

3、删除所有节点/tmp/目录下的heheha目录
# ansible all -m file -a "dest=/tmp/heheha state=absent"

4、修改所有节点/tmp/hosts文件的权限
# ansible all -m file -a "dest=/tmp/hosts mode=600"

5、修改所有节点/tmp/hosts文件的权限
# ansible all -m file -a "dest=/tmp/hosts mode=755 owner=mageedu group=mageedu"

 二、copy (文件管理)

1、将/etc目录下的hosts文件,拷贝到所有节点的/tmp目录下
# ansible websrvs -m copy -a "src=/etc/hosts dest=/tmp/hosts"

 三、yum (package模块)

1、在所有节点使用yum模块安装nginx服务
ansible all -m yum -a "name=nginx state=present"

2、在所有节点使用service模块启动nginx服务
ansible all -m service -a "name=nginx state=started"

 

 

 

 

  

  

posted @ 2019-03-20 10:35  miclesvic  阅读(277)  评论(0)    收藏  举报