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. 【LA3523】 Knights of the Round Table (点双连通分量+染色问题?)

    Being a knight is a very attractive career: searching for the Holy Grail, saving damsels in distress ...

  2. ANDROID_MARS学习笔记_S04_002_用AsyncTask实现异步操作

    一.简介 二.代码1.xml(1)activity_main.xml <?xml version="1.0" encoding="utf-8"?> ...

  3. 在KEIL中的模块化程序写法

    在使用KEIL的时候,我们习惯上在一个.c的文件中把自己要写的东西按照自己思路的顺序进行顺序书写.这样是很普遍的写法,当程序比较短的时候比如几十行或者一百多行,是没有什么问题的.但是当程序很长的时候, ...

  4. Android用户界面UI组件--AdapterView及其子类(三) ExpandableListView

    ExpandableListView: List中的每一项可以展开收缩. 一种伸缩式的ListView. android:cacheColorHint="#00000000" 这个 ...

  5. 推荐一个Xcode插件: KSImageNamed (自动补全图片文件名称, 并显示图片大小)

    http://www.csdn.net/article/2014-05-04/2819586-the-best-xcode-plugins 5. KSImageNamed KSImageNamed是一 ...

  6. (转载)1248 - Every derived table must have its own alias

    (转载)http://hi.baidu.com/lylegend13/item/a79f17eb51f5dff7e0a5d43b 1. select count(distinct CName) fro ...

  7. Text Reverse

    Text Reverse Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tota ...

  8. HDOJ/HDU 1180 诡异的楼梯(经典BFS-详解)

    Problem Description Hogwarts正式开学以后,Harry发现在Hogwarts里,某些楼梯并不是静止不动的,相反,他们每隔一分钟就变动一次方向. 比如下面的例子里,一开始楼梯在 ...

  9. JavaScript高级程序设计43.pdf

    事件类型 Web浏览器中有很多事件类型,“DOM3级事件”规定了以下几类事件 UI事件(用户界面),当用户与页面上的元素交互时触发: 焦点事件,当元素获得或失去焦点时触发 鼠标事件,当用户通过鼠标在页 ...

  10. ASP.NET MVC- VIEW Using the TagBuilder Class to Build HTML Helpers Part 3

    The ASP.NET MVC framework includes  a useful utility class named the TagBuilder class that you can u ...