ansible 安装

rpm -ql

/etc/ansible

/etc/ansible/ansible.cfg

/etc/ansible/hosts

/etc/ansible/roles

/usr/bin/ansible

/usr/bin/ansible-console

/usr/bin/ansible-doc

/usr/bin/ansible-galaxy

/usr/bin/ansible-playbook

/usr/bin/ansible-pull

/usr/bin/ansible-vault

Ansible中文全威指南(网页版)

http://www.ansible.com.cn/docs/playbooks_intro.html#about-playbooks

1Ansible基础安装

(1)python2.7安装

https://www.python.org/ftp/python/2.7.8/Python-2.7.8.tgz

#tar xvzf Python-2.7.8.tgz

# cdPython-2.7.8

#./configure --prefix=/usr/local

#make --jobs=`grep processor/proc/cpuinfo | wc -l`

#make install

 

## python头文件拷贝到标准目录,以避免编译ansible时,找不到所需的头文件

# cd/usr/local/include/python2.7

# cp-a ./* /usr/local/include/

 

## 备份旧版本的python,并符号链接新版本的python

# cd/usr/bin

# mvpython python2.6

# ln-s /usr/local/bin/python

 

## 修改yum脚本,使其指向旧版本的python,已避免其无法运行

#vim /usr/bin/yum

#!/usr/bin/python  -->  #!/usr/bin/python2.6

 

(2)setuptools模块安装

https://pypi.python.org/packages/source/s/setuptools/setuptools-7.0.tar.gz

#tar xvzf setuptools-7.0.tar.gz

# cdsetuptools-7.0

#python setup.py install

 

(3)pycrypto模块安装

https://pypi.python.org/packages/source/p/pycrypto/pycrypto-2.6.1.tar.gz

#tar xvzf pycrypto-2.6.1.tar.gz

# cdpycrypto-2.6.1

#python setup.py install

 

(4)PyYAML模块安装

http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz

#tar xvzf yaml-0.1.5.tar.gz

# cdyaml-0.1.5

#./configure --prefix=/usr/local

#make --jobs=`grep processor/proc/cpuinfo | wc -l`

#make install

 

https://pypi.python.org/packages/source/P/PyYAML/PyYAML-3.11.tar.gz

#tar xvzf PyYAML-3.11.tar.gz

# cdPyYAML-3.11

#python setup.py install

 

(5)Jinja2模块安装

https://pypi.python.org/packages/source/M/MarkupSafe/MarkupSafe-0.9.3.tar.gz

#tar xvzf MarkupSafe-0.9.3.tar.gz

# cdMarkupSafe-0.9.3

#python setup.py install

 

https://pypi.python.org/packages/source/J/Jinja2/Jinja2-2.7.3.tar.gz

#tar xvzf Jinja2-2.7.3.tar.gz

# cdJinja2-2.7.3

#python setup.py install

 

(6)paramiko模块安装

https://pypi.python.org/packages/source/e/ecdsa/ecdsa-0.11.tar.gz

#tar xvzf ecdsa-0.11.tar.gz

# cdecdsa-0.11

#python setup.py install

 

https://pypi.python.org/packages/source/p/paramiko/paramiko-1.15.1.tar.gz

#tar xvzf paramiko-1.15.1.tar.gz

# cdparamiko-1.15.1

#python setup.py install

 

(7)simplejson模块安装

https://pypi.python.org/packages/source/s/simplejson/simplejson-3.6.5.tar.gz

#tar xvzf simplejson-3.6.5.tar.gz

# cdsimplejson-3.6.5

#python setup.py install

 

(8)ansible安装

https://github.com/ansible/ansible/archive/v1.7.2.tar.gz

#tar xvzf ansible-1.7.2.tar.gz

# cdansible-1.7.2

#python setup.py install

 

2Ansible配置

(1)SSH免密钥登录设置

## 生成公钥/私钥

#ssh-keygen -t rsa -P ''


 

## 写入信任文件(将/root/.ssh/id_rsa_storm1.pub分发到其他服务器,并在所有服务器上执行如下指令):

#cat /root/.ssh/id_rsa_storm1.pub >> /root/.ssh/authorized_keys

#chmod 600 /root/.ssh/authorized_keys

 

 

 

++++++++++++++++++++++++++++++++++++

ansible的基本使用

1. 安装软件yum install ansible -y # 对应的软件在 epel 仓库中也可自己手动编译  

2. #源码地址 https://pypi.python.org/packages/source/a/ansible/ansible-1.5.tar.gz 

 

1. 2、定义Host Inventory 

2. # vim /etc/ansible/hosts  

3. [webhosts]  

4. 172.16.10.22 ansible_ssh_user=root ansible_ssh_pass=guoting 

5. 172.16.10.33 ansible_ssh_user=root ansible_ssh_pass=guoting 

6. 解释  

7. #ansible_ssh_user=root 是ssh登陆用户  

8. #ansible_ssh_pass=guoting 是ssh登陆密码3、测试各个模块  

9. # 注意每个模块的用法可以使用 ansible-doc MOD 来查看例如ansible-doc copy  

10.   

11. ansible命令最常用的用法  

12. ansible <Host-partten> -m MOE -a 'MOD_ARV'所支持的模块可以使用ansible-doc -l来查看 

 

 

 

 

分割线
感谢打赏
江西数库信息技术有限公司
YWSOS.COM 平台代运维解决方案
 评论
 发表评论
姓   名:

Powered by AKCMS