Ansible 安装与简单使用
Ansible 安装与简单使用 2014-04-06 17:20:38转自:http://blog.chinaunix.net/xmlrpc.php?r=blog/index&uid=29253247&sid=191677&pattern=list&page=1
======================================================================================
一、安装
[*] $ pip install ansible
[*] #for debian
[*] $ sudo apt-add-repository ppa:rquillo/ansible
[*] $ sudo apt-get update
[*] $ sudo apt-get install ansible
[*] #for centos
[*] $ sudo yum install ansible
二、环境说明
1. 控制主机为 ubuntu 13.10
2. 被控端为 2台 ubuntu 12.04 虚拟机 和 一台 centos 6.4 虚拟机
3. 通过ssh 密钥认证
三、初试牛刀
[*] ansible all -m ping #内建的 ping 模块
http://blog.chinaunix.net/attachment/201404/6/29253247_1396775618jvJ5.png
[*] ansible all -a "/bin/echo hello, world" #执行命令
[*] ansible all -m command -a "/bin/echo hello, world"
[*] #以上两条命令结果是一样的,因为默认调用 command模块,所以可以省略, all 表示所有节点, -a 后面是参数
http://blog.chinaunix.net/attachment/201404/6/29253247_1396776007BZ1h.png
http://blog.chinaunix.net/attachment/201404/6/29253247_13967784742z2u.png
[*] ansible all -m shell -a "ping baidu.com -c 1" # shell 模块
http://blog.chinaunix.net/attachment/201404/6/29253247_13967798219z3f.png
## 转载请注明出处!
转自:http://blog.chinaunix.net/xmlrpc.php?r=blog/index&uid=29253247&sid=191677&pattern=list&page=1
页:
[1]