How to control when notify gets triggered by i.e. command

27 views
Skip to first unread message

Jonas Rottmann

unread,
May 6, 2015, 9:33:39 AM5/6/15
to ansible...@googlegroups.com
Hi,

I have for an example an task which enables modules in apache2 in debian with the command a2enmod.

So I have:

- name: Debian | Apache | Enable Basic Mods
  command: a2enmod {{ item }}
  with_items:
    - rewrite
    - ssl
  when: "ansible_os_family == 'Debian'"
  tags: apache
  notify:
    - restart apache2

Now I don't wan't to get apache restarted every single time, only if it really enabled an module. I can handle such a task as failed with:

register: command_result
failed_when: "'Enabling module' in command_result.stderr"
I would need that but for success not for failing.
Is this possible?

thanks

Brian Coca

unread,
May 6, 2015, 11:12:39 AM5/6/15
to ansible...@googlegroups.com
so you have changed_when, which will control notify the handler, also
you have the apache2_module which might make this much easier.


--
Brian Coca

Jonas Rottmann

unread,
May 7, 2015, 2:10:23 AM5/7/15
to ansible...@googlegroups.com
Thanks, the changed_when was what I was looking for.
Reply all
Reply to author
Forward
0 new messages