您的位置:首页 > 其它

Ansible 源码安装与基本使用

2014-07-21 23:28 781 查看


源码方式安装

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ansible