Ansible 源码安装与基本使用,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











相关内容

    暂无相关文章