Handlers
示例:
---
- hosts: zabbix
gather_facts: False
tasks: - name: edit server
lineinfile: dest=/usr/local/zabbix/etc/zabbix_agentd.conf backrefs=yes regexp='^Server=.*' line='Server=10.1.32.45,10.3.32.67'
notify: reload zabbix - name: edit serveractive
lineinfile: dest=/usr/local/zabbix/etc/zabbix_agentd.conf backrefs=yes regexp='^ServerActive=.*' line='ServerActive=10.1.32.45,10.3.32.67'
notify: reload zabbix - name: edit iptables
lineinfile: dest=/etc/sysconfig/iptables insertafter='-A INPUT -s 10.1.32.0/24 -p tcp -m tcp --dport 0:65522 -j ACCEPT' line='-A INPUT -s 10.3.32.0/24 -p tcp -m tcp --dport 0:65522 -j ACCEPT'
notify: reload iptables handlers: - name: reload zabbix
service: name=zabbix_agentd state=reloaded - name: reload iptables
service: name=iptables state=reloaded
说明:
handlers是ansible支持的一种状态形式.handler类似于task,但是它只有被task通知后才能运行(notify).
task会触发通知 如果ansible意识到task改变了系统的状态(playbook执行后会返回task是否改变节点系统的状态 是changed=1)
task把handler的名字作为参数来通告handler
只有在所有的task都执行后(如果某个task执行失败 并且没有设置ignore_errors 后续的操作都不会再执行 包括被通告的handlers) handler才运行 而且只会运行一次 即使被多次被通告 handler按照在playbook中的先后顺序执行 而不是被通告的顺序
Handlers的更多相关文章
- A little bit about Handlers in JAX-WS
by Rama Pulavarthi Handlers are message interceptors that can be easily plugged in to the JAX-WS run ...
- (spring-第7回【IoC基础篇】)BeanDefinition的载入与解析&&spring.schemas、spring.handlers的使用
报错信息:Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http: ...
- Creating Icon Overlay Handlers / 创建图标标记 Handlers (翻译自MSDN) / VC++, Windows, DLL, ATL, COM
创建图标标记 Handlers Creating Icon Overlay Handlers 图标标记是放在代表着某个 Shell 对象的图标之左下角的小图像.它们通常被加在一个对象的图标的身上来提供 ...
- 1.6.2 Uploading Data with Index Handlers
1.Uploading Data with Index Handlers 索引处理器就是Request Handlers,用于添加,更新,删除索引中的文档.另外,使用Tika抽取富文档数据,使用Dat ...
- Ehcache(2.9.x) - API Developer Guide, Cache Exception Handlers
About Exception Handlers By default, most cache operations will propagate a runtime CacheException o ...
- A Tour of Go Exercise: HTTP Handlers
Implement the following types and define ServeHTTP methods on them. Register them to handle specific ...
- IIS 7.0, ASP.NET, pipelines, modules, handlers, and preconditions
1.0 What is the IIS Pipeline Conceptually, the IIS pipeline is a state machine with the following st ...
- Registering Shell Extension Handlers
最近在做Windows shell extension 的开发工作,对shell extension handler的注册机制有点疑问,以下摘自MSDN:http://msdn.microsoft.c ...
- WebApi2官网学习记录--HttpClient Message Handlers
在客户端,HttpClient使用message handle处理request.默认的handler是HttpClientHandler,用来发送请求和获取response从服务端.可以在clien ...
随机推荐
- Linux Linux程序练习十四(多进程压力测试)
/* * 题目: * 编程一个基本多进程测试框架,提示用户输入进程数.和每个进程数运行圈数.(fork) * 进行多进程压力测试.(execve) * 要求父进程能监控所有子进程的退出,避免僵尸进程. ...
- PCL 库安装
参考资料: http://www.cnblogs.com/newpanderking/articles/4022322.html VS2010+PCL配置 PCL共有两种安装方式 安全安装版,个人配置 ...
- JS明确指定函数的接受者
由于方法和值为对象的属性值没什么区别,因此很容易提取对象的方法作为回调函数直接传递给高阶函数.但这也很容易忘记应明确指定方法的接受者.例如,一个字符串缓冲对象使用数组来存储字符串. var buffe ...
- Tomcat 项目部署方式
方法一:在Tomcat中的Conf目录中,在Server.Xml中的,<Host/>节点中添加: <Context Path="/Hello"Docbase=&q ...
- lecture8-RNN的训练方法之二三
HInton第8课,之所以说之二三,是因为训练RNN的四种方法之一:长短时记忆在lecture7中介绍过了,这里介绍的是第二和第三种方法:HF优化和Echo (这个字觉得翻译成回声是不是欠妥,所以保留 ...
- nios II--实验1——hello_world硬件部分
hello_world 硬件开发 新建原理图 1.打开Quartus II 11.0,新建一个工程,File -> New Project Wizard…,忽略Introduction,之间单击 ...
- CSS 栅格布局
bootstrap3.0教程之栅格系统原理(布局) http://www.jb51.net/css/152846.html [div+css]栅格化布局样式备用坑 http://www.0773lin ...
- Ubuntu更改右键菜单
方法/步骤1.这是我们在桌面文件夹ubuntugege上打开的右键菜单,你说你在~/.gnome2/nautilus-scripts/添加的右键菜单项目但它就是没有显示呀,于是你觉得Ubuntu 12 ...
- 东大OJ-快速排序
1236: Simple Sort 时间限制: 1 Sec 内存限制: 128 MB 提交: 195 解决: 53 [提交][状态][讨论版] 题目描述 You are given n ...
- android 获取时间
首先,先说下java下可以正常使用的方法: import java.text.DateFormat; import java.text.SimpleDateFormat; import java.ut ...