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. user模式下编译android 代码被proguard优化导致类和变量丢失

    在Android项目中用到JNI,当用了proguard后,发现native方法找不到很多变量,原来是被produard优化掉了.所以,在JNI应用中该慎用progurad啊. 解决办法: 1.在An ...

  2. Android开源项目发现---Layout 篇(持续更新)

    1. achartengine 强大的图标绘制工具 支持折线图.面积图.散点图.时间图.柱状图.条图.饼图.气泡图.圆环图.范围(高至低)条形图.拨号图/表.立方线图及各种图的结合 项目地址:http ...

  3. Android 删除指定文件代码

    package com.tware.pdfdrop; import java.io.File; import android.app.Activity; import android.graphics ...

  4. Web Development Terms

    I've come across lots of terms while learning web development. I'm feeling myself overwhelmed. Here ...

  5. redis的图形界面管理工具:phpredisadmin

    大部分人都知道redis是一款用在缓存服务器上的软件,它与memcache类似,都可以存储海量的数据,用在大访问量的web网站.聊天记录存放等方面,但是又与memcache不同: 1.缓存数据可以持久 ...

  6. 2.6.1 使用toast显示提示信息框

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout ...

  7. Yii处理流程

    Yii的应用程序处理流程 用户访问URL http://www.example.com/blog/index.php?r=site/contact 1.入口脚本被网站服务器执行以处理此请求. 2.一个 ...

  8. (转载)C++中将构造函数或析构函数定义为private

    (转载)http://www.blogjava.net/fhtdy2004/archive/2009/05/30/278971.html C++中将构造函数或析构函数定义为private 很多情况下要 ...

  9. HDU-4300 Clairewd’s message

    http://acm.hdu.edu.cn/showproblem.php?pid=4300 很难懂题意.... Clairewd’s message Time Limit: 2000/1000 MS ...

  10. Js 时间轴和拓扑图

    http://code.csdn.net/news/2819345 http://visjs.org/