标签:
http://sofar.blog.51cto.com/353572/1579894
先做免密码登录,有几台机器就scp几次公钥 ssh-keygen -t rsa -P ‘‘ scp id_rsa.pub 192.168.2.84:/root/.ssh/authorized_keys [root@084-monitor ansible]# bash ansib [root@084-monitor ansible]# cat ansib wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-7.0.tar.gz tar zxvf setuptools-7.0.tar.gz cd setuptools-7.0 python setup.py install cd ../ wget --no-check-certificate https://pypi.python.org/packages/source/p/pycrypto/pycrypto-2.6.1.tar.gz tar zxvf pycrypto-2.6.1.tar.gz cd pycrypto-2.6.1 yum install python-devel python setup.py install cd ../ wget --no-check-certificate http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz tar zxvf yaml-0.1.5.tar.gz cd yaml-0.1.5 ./configure --prefix=/usr/local make --jobs=`cat /proc/cpuinfo|grep processor|wc -l` cd ../ wget --no-check-certificate https://pypi.python.org/packages/source/P/PyYAML/PyYAML-3.11.tar.gz tar zxvf PyYAML-3.11.tar.gz cd PyYAML-3.11 python setup.py install cd ../ wget --no-check-certificate https://pypi.python.org/packages/source/M/MarkupSafe/MarkupSafe-0.9.3.tar.gz tar zxvf MarkupSafe-0.9.3.tar.gz cd MarkupSafe-0.9.3 python setup.py install cd ../ wget --no-check-certificate https://pypi.python.org/packages/source/J/Jinja2/Jinja2-2.7.3.tar.gz tar zxvf Jinja2-2.7.3.tar.gz cd Jinja2-2.7.3 python setup.py install cd ../ wget --no-check-certificate https://pypi.python.org/packages/source/e/ecdsa/ecdsa-0.11.tar.gz tar zxvf ecdsa-0.11.tar.gz cd ecdsa-0.11 python setup.py install cd ../ wget --no-check-certificate https://pypi.python.org/packages/source/p/paramiko/paramiko-1.15.1.tar.gz tar zxvf paramiko-1.15.1.tar.gz cd paramiko-1.15.1 python setup.py install cd ../ wget --no-check-certificate https://pypi.python.org/packages/source/s/simplejson/simplejson-3.6.5.tar.gz tar zxvf simplejson-3.6.5.tar.gz cd simplejson-3.6.5 python setup.py install cd ../ wget --no-check-certificate https://github.com/ansible/ansible/archive/v1.7.2.tar.gz tar zxvf v1.7.2.tar.gz cd ansible-1.7.2/ python setup.py install cd ../ mkdir -p /etc/ansible cat <<EOF > /etc/ansible/ansible.cfg [defaults] hostfile=/etc/ansible/hosts EOF cat <<EOF > /etc/ansible/hosts [aa] 192.168.2.220 192.168.2.221 192.168.2.222 192.168.2.223 192.168.2.224 EOF [root@084-monitor ansible]# ansible aa -m command -a ‘free‘ 192.168.2.224 | success | rc=0 >> total used free shared buffers cached Mem: 1020132 953112 67020 0 134156 541024 -/+ buffers/cache: 277932 742200 Swap: 1675256 6260 1668996 192.168.2.223 | success | rc=0 >> total used free shared buffers cached Mem: 7999632 7717876 281756 0 219012 6540924 -/+ buffers/cache: 957940 7041692 Swap: 3145720 32772 3112948 192.168.2.220 | success | rc=0 >> total used free shared buffers cached Mem: 3923760 3818168 105592 0 239264 2671504 -/+ buffers/cache: 907400 3016360 Swap: 3145720 132888 3012832 192.168.2.221 | success | rc=0 >> total used free shared buffers cached Mem: 1019820 723684 296136 0 138636 104360 -/+ buffers/cache: 480688 539132 Swap: 1675256 736 1674520 192.168.2.222 | success | rc=0 >> total used free shared buffers cached Mem: 1020296 951344 68952 0 69916 218880 -/+ buffers/cache: 662548 357748 Swap: 1675256 161188 1514068
标签:
原文地址:http://www.cnblogs.com/createyuan/p/4218838.html