You could first check if the package is installed and register a variable to that effect.
- shell: dpkg -l foo changed_when: False failed_when: False register: foo_installed - service: name=foo enabled=no state=stopped when: foo_installed.rc == 0 On 21 December 2014 at 01:38, Kevin Burton <[email protected]> wrote: > I need the opposite of notify. > > Basically, I have a 'foo-off' role to turn services / daemons off for a > specific host. > > So if foo is the service, I want to stop foo , then apt-get remove it. > > - service: name=foo state=stopped > > ... because the second time it's run the daemon isn't present because the > package is removed. > > So what I need is kind of a notify that runs BEFORE a task. > > So something like > > - name: apt-get remove foo > apt: name=foo state=absent > before: > - stop foo > > ... is this possible? I guess I could stat the init script first but that > adds more complexity. > > -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/37211c6a-2e21-4a92-9e9a-59d6b8afd4b9%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/37211c6a-2e21-4a92-9e9a-59d6b8afd4b9%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAAnNz0MBfBJ%3DY8yR-U8VScQw8mT%3D43eo6bKmFTsd9X%2BbYA88%3DQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
