1、准备CentOS环境

yum update && yum upgrade

2、控制服务器与被管理服务器要求

Master:Python 2.6+
Slave:Python 2.4+,最好也是2.6+(CentOS 6.7自带)

3、配置SSH自动登录

配置Master向每一台Slave的SSH无密码登录(在Master上使用ssh-keygen生成密钥对,并将id_rsa.pub加入到每一个Slave的authorized_keys中)

4、使用yum安装ansible

yum install ansible

如果提示没有此安装包,可以加入EPEL扩展包:

yum install epel-release
yum install ansible

5、配置host

默认在/etc/ansible/hosts,加入Slave的ip地址,例如

[Web]
192.168.1.101
192.168.1.102
192.168.1.103

6、测试

ansible all -m ping

成功ping同后显示

192.168.1.101 | success >> {
"changed": false,
"ping": "pong"
} 192.168.1.102 | success >> {
"changed": false,
"ping": "pong"
} 192.168.1.103 | success >> {
"changed": false,
"ping": "pong"
}

基本查看命令:

ansible all -a 'uptime'
ansible all -a 'free -m'

7、使用模块(-m)

command 模块不支持 shell 变量,也不支持管道等,如果需要使用这些功能,可以借助模块

ansible web -m shell -a 'echo $TERM'

拷贝文件模块(-m copy)

ansible web -m copy -a "src=/etc/hosts dest=/tmp/hosts"

文件属性模块

ansible web -m file -a "dest=/srv/foo/b.txt mode=600 owner=mdehaan group=mdehaan"

服务模块

ansible web -m service -a "name=httpd state=started"

具体用法可以参考:

http://docs.ansible.com/ansible/

http://www.ansible.com.cn/docs/

CentOS 6.7安装配置Ansible的更多相关文章

  1. CentOS 7.0安装配置Vsftp服务器

    一.配置防火墙,开启FTP服务器需要的端口 CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop fi ...

  2. CentOS 6.6安装配置LAMP服务器(Apache+PHP5+MySQL)

    准备篇: CentOS 6.6系统安装配置图解教程 http://www.osyunwei.com/archives/8398.html 1.配置防火墙,开启80端口.3306端口 vi /etc/s ...

  3. CentOS 6.5安装配置LNMP服务器(Nginx+PHP+MySQL)

    CentOS 6.5安装配置LNMP服务器(Nginx+PHP+MySQL) 一.准备篇: /etc/init.d/iptables stop #关闭防火墙 关闭SELINUX vi /etc/sel ...

  4. CentOS 6.4安装配置LAMP服务器(Apache+PHP5+MySQL)

    这篇文章主要介绍了CentOS 6.4安装配置LAMP服务器(Apache+PHP5+MySQL)的方法,需要的朋友可以参考下 文章写的不错,很详细:IDO转载自网络: 准备篇: 1.配置防火墙,开启 ...

  5. centOS下yum安装配置samba

     centOS下yum安装配置samba 2010-03-29 15:46:00 标签:samba yum centOS 安装 休闲 注意:本文的原则是只将文件共享应用于内网服务器,并让将要被共享的目 ...

  6. CentOS 7.0安装配置LAMP服务器(Apache+PHP+MariaDB)

    CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop firewalld.service #停止fir ...

  7. CentOS 7.x安装配置

    简述 VMware可以创建多个虚拟机,每个虚拟机上都可以安装各种类型的操作系统.安装方法也有很多种.下面,主要以ISO镜像安装为例,介绍CentOS 7.x的安装过程及相关的参数设置. 简述 创建虚拟 ...

  8. CentOS 6.x安装配置

    简述 VMware可以创建多个虚拟机,每个虚拟机上都可以安装各种类型的操作系统.安装方法也有很多种.下面,主要以ISO镜像安装为例,介绍CentOS 6.x的安装过程及相关的参数设置. 简述 创建虚拟 ...

  9. CentOS 6.3安装配置LAMP服务器(Apache+PHP5+MySQL)

    准备篇: 1.配置防火墙,开启80端口.3306端口 vi /etc/sysconfig/iptables -A INPUT -m state --state NEW -m tcp -p tcp -- ...

随机推荐

  1. Linux下实现定时器Timer的几种方法

    http://blog.csdn.net/lxmky/article/details/7669296 第六章 IO复用:select和poll函数 http://www.cnblogs.com/4ti ...

  2. VC下载文件显示进度条

    VC下载文件显示进度条 逗比汪星人2009-09-18上传   by Koma http://blog.csd.net/wangningyu http://download.csdn.net/deta ...

  3. Android Intent.FLAG_NEW_TASK详解,包括其他的标记的一些解释

    本文大部分参考自 http://blog.csdn.net/mayingcai1987/article/details/6200909 ,对原文中的讲解FLAG_NEW_TASK地方加了一些自己的观点 ...

  4. 【CF】3B Lorry

    这道题目网上有几个题解,均有问题.其实就是简单的贪心+排序,没必要做的那么复杂.一旦tot+curv > v时,显然curv==2, 有三种可能:(1)取出最小的curv==1的pp,装入当前的 ...

  5. WordPress get_allowed_mime_types函数(wp-includes/functions.php)存在跨站脚本漏洞

    漏洞版本: WordPress 3.6 漏洞描述: CVE ID:CVE-2013-5738 WordPress是一种使用PHP语言开发的博客平台,用户可以在支持PHP和MySQL数据库的服务器上架设 ...

  6. 计数方法,博弈论(扫描线,树形SG):HDU 5299 Circles Game

    There are n circles on a infinitely large table.With every two circle, either one contains another o ...

  7. 传输层之UDP

    1.UDP的定义 跟tcp一样,我们把她定义为: 无连接的,不可靠的,用户数据报协议. 从中我们看到了:无连接和不可靠,这是它的缺点也是它的优点,因为他选择了性能,舍弃了部分安全,节约资源,速度快. ...

  8. JavaScript高级程序设计46.pdf

    鼠标按钮 只有在主鼠标按钮被单击(或键盘回车键被按下)是才会触发click事件,对于mousedown和mouseup事件,其event对象存在一个button属性,表示按下或者释放按钮.DOM的bu ...

  9. nginx一致性hash及应用场景。

    考虑一种场景. 多台web服务. 1 后台添加用户,更新用户信息,要求管理员能够实时看到变化. 2 前台用户允许1分钟后生效. nginx 配置一致性hash1. https://github.com ...

  10. Get the largest sum of contiguous subarray in an int array

    When I finished reading this problem,I thought I could solve it by scanning every single subarray in ...