ansible03 命令格式

ansible  <host-pattern> [options]


1.检查所有主机,是否以“root”用户创建了ansible 管理的主机可访问的环境。

ansible all -m ping -u  root

2.以当前用户,在远程主机上执行“echo hello”

ansible all  -a  "/bin/echo hello"

3.复制文件

复制文件hosts  到 t1组内所有主机 /tmp/下

ansible  t1  -m copy -a "src=/etc/hosts dest=/tmp/"

4.安装包

ansible t1  -m yum -a "name=httpd state=present"

5.添加用户

ansible t1 -m user -a "name=foo password="""

6.下载git仓库

ansible t1 -m git -a  "repo=git://foo.example.org/repo.git dest=/srv/myappversion=HEAD"

7.启动服务

ansible t1 -m servie -a "name=network state=restart"     ### started  

8.并行执行

ansible   1b -a "/sbin/reboot" -f 10

9.查看远程主机的全部系统信息

ansible all -m setup










  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值