我有一个剧本,应该配置在指定的IP,然后连接到这个应用程序来配置里面的东西。
我有一个问题:在我更改了应用程序配置中的任何内容后,我需要重新启动应用程序,如果我不重新启动应用程序,到它的连接失败(没有连接,因为应用程序对我试图访问的新IP地址的新配置一无所知)。
我目前的攻略:
tasks:
- name: Configure app
template: src=app.conf.j2 dest=/etc/app.conf
notify: restart app
- name: Change data in app
configure_app: host={{new_ip}} data={{data}}
handlers:
- name: restart app
service: name=app state=restarted
如果在执行“更改应用程序中的数据”之前configure_app
发生了变化,我需要强制运行处理程序。
发布于 2015-12-01 20:06:22
如果您希望强制处理程序在两个任务之间运行,而不是在游戏结束时运行,则需要将此放在两个任务之间:
- meta: flush_handlers
取自ansible documentation的例子:
tasks:
- shell: some tasks go here
- meta: flush_handlers
- shell: some other tasks
请注意,这将导致所有挂起的处理程序都在该点运行,而不仅仅是那个特定的处理程序。
https://stackoverflow.com/questions/34018862
复制相似问题