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 ...
随机推荐
- UML类图归纳
作为一个程序员,掌握UML类图是开发和阅读程序的基础. 转载请注明地址http://www.cnblogs.com/zrtqsk/p/3739288.html,谢谢! 一.基本介绍 UML是一种标准的 ...
- 2014-10-28——iframe多层嵌套时获取元素总结
同域: 父页面获取子页面元素: 注意:onload事件 jQuery获取:$("iframe").contents().find("holder")...... ...
- Eclipse调试常用技巧(转)
Eclipse调试常用技巧 转自http://daimojingdeyu.iteye.com/blog/633824 1. 条件断点 断点大家都比较熟悉,在Eclipse Java 编辑区的行头双击就 ...
- PAT 1067. Sort with Swap(0,*)
1067. Sort with Swap(0,*) (25) Given any permutation of the numbers {0, 1, 2,..., N-1}, it is easy ...
- Qt Creator 常用快捷键
多行注释模式 Ct ...
- 也议 js闭包和ie内存泄露原理
可以, 但小心使用. 闭包也许是 JS 中最有用的特性了. 有一份比较好的介绍闭包原理的文档. 有一点需要牢记, 闭包保留了一个指向它封闭作用域的指针, 所以, 在给 DOM 元素附加闭包时, 很可能 ...
- 最短判断IE的办法
if(!!-[1,]){ return }; 无意中看到这样一行代码,经查是用来判断IE的代码,非常精简,原理如下: [1,],这是一个数组,IE和标准浏览器对这样一个数组的解析是不一样的 alert ...
- poj 1324 Holedox Moving
poj 1324 Holedox Moving 题目地址: http://poj.org/problem?id=1324 题意: 给出一个矩阵中,一条贪吃蛇,占据L长度的格子, 另外有些格子是石头, ...
- android开发------Activity生命周期
这几天工作比较忙,基本没有什么时间更新播客了. 趁着今晚有点时间,我们来简单说一下什么是Activity生命周期和它们各阶段的特征 什么是生命周期 在还没有接触android开发的时候,听到有人说Ac ...
- Hibernate原生SQL映射MySQL的CHAR(n)类型到String时出错
今天在用Hibernate通过原生SQL和ResultTransformer映射时,出现数据类型不匹配的错误.但是通过Entity映射,没有问题.在网上找了好多答案,终于解决了. 核心代码: Stri ...