Ansible 2.2:使用处理程序名称中的变量重新启动进程 [英] Ansible 2.2 : Restart process using variable in handlers name

查看:23
本文介绍了Ansible 2.2:使用处理程序名称中的变量重新启动进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做这样的事情:

 - copy: 
     src: file{{ item }}.xml
     dest: target_file{{ item }}.xml
   notify: restart process{{ item }}
   with_sequence: start=1 end={{ number_of_process }}

预期结果:只有修改了配置文件target_file1才会重启进程1,只有修改了配置文件target_file2等才会重启进程2.

Expected result : the process 1 is restarted only if configuration file target_file1 has been modified, the process 2 is restarted only if configuration file target_file2 has been modified etc.

真正的结果是修改一个配置文件后所有进程都重启.

Real result is the restart of all process when one configuration file is modified.

任何想法只重启所需的进程?

Any idea to restart only the desired process ?

推荐答案

似乎是一个错误.我已提交问题 #22579.

Seems like a bug. I've filed the issue #22579.

如果您需要解决方法修改ansible/plugins/strategy/__init__.py:

If you need a workaround modify ansible/plugins/strategy/__init__.py:

            for result_item in result_items:
                if '_ansible_notify' in result_item:
                    # if task_result.is_changed(): # comment this line
                    if result_item['changed']:     # add this

这篇关于Ansible 2.2:使用处理程序名称中的变量重新启动进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆