|
[root@cobbler ~]# ansible all -a 'uptime' #all所有节点, -a用于指定命令,‘uptime’执行的命令,如果命令有参数一定要用引号;ansible默认使用command模块,所以可以不用指定。
10.0.0.130 | success | rc=0 >>
11:31:50 up 2:01, 1 user, load average: 0.00, 0.00, 0.00
10.0.0.129 | success | rc=0 >>
11:31:50 up 2:02, 1 user, load average: 0.00, 0.00, 0.00
10.0.0.128 | success | rc=0 >>
11:31:50 up 2:05, 1 user, load average: 0.00, 0.00, 0.00
[root@cobbler ~]# ansible-doc -l #查看ansible的所有模块
acl Sets and retrieves file ACL information.
add_host add a host (and alternatively a group) to the ansible-playbo
airbrake_deployment Notify airbrake about app deployments
apt Manages apt-packages
[root@cobbler ~]# ansible-doc yum #查看指定模块的文档
> YUM
Installs, upgrade, removes, and lists packages and groups with the
`yum' package manager.
[root@cobbler ~]# ansible all -m yum -a "name=httpd state=present" #用yum模块给各节点安装httpd。name指定安装包名,state指定动作:安装可以用present和latest,卸载使用absent。
10.0.0.128 | success >> {
"changed": false,
"msg": "",
"rc": 0,
"results": [
"httpd-2.2.15-30.el6.centos.x86_64 providing httpd is already installed"
]
}
10.0.0.130 | success >> {
"changed": false,
"msg": "",
"rc": 0,
"results": [
"httpd-2.2.15-30.el6.centos.x86_64 providing httpd is already installed"
]
}
10.0.0.129 | success >> {
"changed": false,
"msg": "",
"rc": 0,
"results": [
"httpd-2.2.15-30.el6.centos.x86_64 providing httpd is already installed"
]
} |
|
|