Ansible 源码安装与基本使用

分类: Ansible   349人阅读  评论(0)  收藏  举报

目录(?)[+]

源码方式安装

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

  1. [root@cos65 ansible]# ansible all -m ping --ask-pass  
  2. SSH password:   
  3.   
  4. paramiko: The authenticity of host '192.168.47.65' can't be established.   
  5. The ssh-rsa key fingerprint is 6a27492ba262aae43fde0cb8c82abe1d.   
  6. Are you sure you want to continue connecting (yes/no)?  
  7. yes  
  8. 192.168.47.65 | success >> {  
  9.     "changed": false,   
  10.     "ping": "pong"  
  11. }  

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

  1. [webservers]  
  2. 192.168.47.65  
  3.   
  4. [dbservers]  
  5. 192.168.47.57  
  6. 192.168.47.160  

远程执行df 命令

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











评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值