标签:51cto OAO empty ping bee 推送 efault 工具 pass
1.Ansible简介:ansible基于python开发,集合了众多优秀运维工具的优点,实现了批量运行命令、部署程序、配置系统等功能。默认通过SSH协议进行远程命令执行或下发配置,无需部署任何客户端代理软件,从而使得自动化环境部署变得更加简单。可同时支持多台主机并进行管理,使得管理主机更加便捷。主版本大概每2个月发布一次。#This is the default ansible ‘hosts‘ file.
#It should live in /etc/ansible/hosts
#- Comments begin with the ‘#‘ character
#- Blank lines are ignored
#- Groups of hosts are delimited by [header] elements
#- You can enter hostnames or ip addresses
#- A hostname/ip can be a member of multiple groups
#Ex 1: Ungrouped hosts, specify before any group headers.
##green.example.com
##blue.example.com
##192.168.100.1
##192.168.100.10
#Ex 2: A collection of hosts belonging to the ‘webservers‘ group
#[webservers]
##alpha.example.org
##beta.example.org
##192.168.1.100
##192.168.1.110
[webserver] //添加
192.168.252.173 //添加
[mysql] //添加
192.168.252.174 //添加
2)生成密钥对并将公钥推送给被管理端
ssh-keygen -t rsa //以rsa的类型生成密钥对
enerating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): //回车
Created directory ‘/root/.ssh‘.
Enter passphrase (empty for no passphrase): //输入密码
Enter same passphrase again: //再次输入
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:udpIx9U0dKSLCND1RFwGy3PK/ZdczW1fep2AoaO3GGQ root@ansible
The key‘s randomart image is:
+---[RSA 2048]----+
| .. ..o+o+.o |
| .. +.+ o |
| . =.= |
| . +.Ooo .o|
| ESo=.+. B|
| o..o. .ooB|
| .o+. o+=|
| . =+ . o |
| o... |
+----[SHA256]-----+
cd ~
cd .ssh
ssh-copy-id root@192.168.252.173
ssh-copy-id root@192.168.252.174 //将公钥推送给被管理端
ssh-agent bash //免交互
ssh-add
至此ansible安装以及主机清单配置完成。(注:如果连接失败请检查ansibleserver和被管理端是否能ping通,如能ping通,可以删除.ssh下的密钥,重新生成并下发)
标签:51cto OAO empty ping bee 推送 efault 工具 pass
原文地址:http://blog.51cto.com/13842738/2311723