linux cpu占用率如何看
278
2022-11-13
RHEL 6.6下安装ansible
ansible是新出现的自动化运维工具,基于Python开发,集合了众多运维工具(puppet、cfengine、chef、func、fabric)的优点,实现了批量系统配置、批量程序部署、批量运行命令等功能。(百度百科),2015年redhat收购ansible。
主机环境:
OS:Red Hat Enterprise Linux Server release 6.6 (Santiago) x86_64 IP:172.16.10.180 Python 2.6.6 注:操作系统最小化安装
节点:
OS:Oracle Linux Server release 5.8 IP:172.16.10.10、172.16.10.200 Python 2.4.3
1、安装开发工具:
# yum -y groupinstall "Development tools"
2、安装epel、six、yaml
epel安装请参考:http://fedoraproject.org/wiki/EPEL,six、yaml在yum源里没找到,单独下载安装。
# rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/epel/6/x86_64/epel-release-6-8.noarch.rpm # rpm -ivh python-six-1.9.0-1.el6.pp.noarch.rpm # rpm -ivh python-yaml-3.09-3.el6.rf.x86_64.rpm
3、安装ansible
# yum install ansible 注:受控节点需要安装python-simplejson
4、生成秘钥文件
# ./sshUserSetup.sh -user root -hosts "172.16.10.10 172.16.10.200" 输入yes和两台主机的root密码即可完成172.16.10.180->172.16.10.10、172.16.10.180->172.16.10.200的验证 或者: # ssh-keygen -t rsa -P '' 在/root/.ssh/下生成文件id_rsa.pub,拷贝到所有受控机并执行以下操作: # cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys # chmod 600 /root/.ssh/authorized_keys
5、修改hosts文件
# cd /etc/ansible/ # cat /etc/ansible/hosts ... [dbservers] 172.16.10.10 172.16.10.200
6、修改ansible.cfg文件
# cat /etc/ansible/ansible.cfg ... remote_port = 22 ... private_key_file = /root/.ssh/id_rsa
7、测试
# ansible all -m ping # all指所有定的主机 172.16.10.10 | SUCCESS => { "changed": false, "ping": "pong" } 172.16.10.200 | SUCCESS => { "changed": false, "ping": "pong" } # ansible dbservers -m ping 172.16.10.200 | SUCCESS => { "changed": false, "ping": "pong" } 172.16.10.10 | SUCCESS => { "changed": false, "ping": "pong" }
8、常见错误:
A、"msg": "Error: ansible requires the stdlib json or simplejson module, neither was found!" 受控端需要安装python-simplejson B、FAILED => module command not found in configured module paths. Additionally, core modules are missing. If this is a checkout, run 'git submodule update --init --recursive' to correct this problem. 安装过程有问题,重新安装 C、FAILED => to use the 'ssh' connection type with passwords, you must install the sshpass program 安装sshpass
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~