首页 > 其他 > 详细

ansible自动化工具安装和简单使用

时间:2018-07-31 14:47:49      阅读:151      评论:0      收藏:0      [点我收藏+]

ansible自动化工具安装和简单使用

1.安装

ansible依赖于Python 2.6或更高的版本、paramiko、PyYAML及Jinja2。

2.1 编译安装

解决依赖关系

# yum -y install python-jinja2 PyYAML python-paramiko python-babel python-crypto

# yum install ansible

在node1(Master):
# ssh-keygen -t rsa   
# ssh-copy-id -i /root/.ssh/id_rsa.pub root@node2    
# ssh-copy-id -i /root/.ssh/id_rsa.pub root@node3    
# ssh-copy-id -i /root/.ssh/id_rsa.pub root@node5
在node2 (slave):
# ssh-keygen -t rsa   
# ssh-copy-id -i /root/.ssh/id_rsa.pub root@node1    
# ssh-copy-id -i /root/.ssh/id_rsa.pub root@node3    
# ssh-copy-id -i /root/.ssh/id_rsa.pub root@node5

常用命令:
ping 主机
ansible web -a ‘ping‘
查看磁盘挂载
ansible web -a ‘df -h‘


远程传送文件
ansible web -m copy -a "src=/root/1.txt dest=/root/"
修改文件
ansible web -m lineinfile -a ‘path=/root/1.txt regexp="^12334" line="test text" ‘

 

ansible自动化工具安装和简单使用

原文:https://www.cnblogs.com/zoulixiang/p/9395370.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!