Ansible 源码安装与基本使用

源码方式安装

rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
yum install -y gcc
yum install python-paramiko -y
yum install PyYAML -y
yum install python-jinja2-26 -y
yum install python-httplib2 -y
yum install -y git
git clone git://github.com/ansible/ansible.git
source ./ansible/hacking/env-setup


基本功能


mkdir -p /etc/ansible
echo '192.168.47.65' > /etc/ansible/hosts

执行ping : ansible all -m ping --ask-pass

[root@cos65 ansible]# ansible all -m ping --ask-pass
SSH password: 

paramiko: The authenticity of host '192.168.47.65' can't be established. 
The ssh-rsa key fingerprint is 6a27492ba262aae43fde0cb8c82abe1d. 
Are you sure you want to continue connecting (yes/no)?
yes
192.168.47.65 | success >> {
    "changed": false, 
    "ping": "pong"
}

修改/etc/ansible/hosts (INI格式) 文件如下

[webservers]
192.168.47.65

[dbservers]
192.168.47.57
192.168.47.160

远程执行df 命令

[root@cos65 ansible]# ansible webservers -a "df -h" --ask-pass   
SSH password: 
192.168.47.65 | success | rc=0 >>
Filesystem                    Size  Used Avail Use% Mounted on
/dev/mapper/vg_cos65-lv_root  3.1G  1.3G  1.7G  44% /
tmpfs                         1.9G     0  1.9G   0% /dev/shm
/dev/sda1                     485M   33M  427M   8% /boot











  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值