Ansible 2.2 : Restart process using variable in handlers name

送分小仙女□ 提交于 2019-12-12 03:09:17

问题


I want to do something like this :

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

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 ?


回答1:


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

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


来源:https://stackoverflow.com/questions/42769314/ansible-2-2-restart-process-using-variable-in-handlers-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!