not currently, what you have is what works. On Wed, Dec 17, 2014 at 6:57 AM, Jon Warbrick <[email protected]> wrote: > Apologies if this is a FAQ, but I haven't found been able to find it > anywhere. > > I keep wanting a pattern where something happens if a variable is true and > something positively doesn't happen if the variable is false (or unset). For > example having a service running or not running. Is there any way to achieve > this other than having pairs of tasks with inverted when clauses? > > e.g: > > - name: be sure openais is running and enabled > service: name=openais state=running enabled=yes > when: enable_service_address is defined and enable_service_address > > - name: be sure openais is NOT running and NOT enabled > service: name=openais state=stopped enabled=no > when: enable_service_address is not defined or not enable_service_address > > Or, as an other example, creating or removing a marker file (which seems to > be further complicated by needing 'copy' for create and 'file' for remove): > > - name: Set standalone marker file > copy: content='' dest=/var/role-standalone > when: '"standalone" in group_names' > > - name: Unset standalone marker file > file: path=/var/role-standalone state=absent > when: '"standalone" not in group_names' > > Jon. > > -- > Jon Warbrick > Information Systems Manager, University of Cambridge Information Services
-- Brian Coca -- 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/CAJ5XC8%3Di6Mh7CyOdpj%3DwiCOrLYXF%2Byq2haJegvr_Tfg62G7Rrw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
