You can do this: when: foo is defined
On Mon, Nov 17, 2014 at 1:29 PM, Simón Muñoz <[email protected]> wrote: > Hi all, > > I'm trying to run a task only if a variable is defined (for example, I > have some groups where it's defined and some others where it's not). I got > to this (adding when: nginx_sites), that seems to work, but just asking in > case there is a better way. > > - name: Enabling nginx sites according to group and host_vars > file: > > src=/etc/nginx/sites-available/{{ item }} > dest=/etc/nginx/sites-enabled/{{ item }} > state=link > with_items: random_var > when: random_var > notify: > - reload nginx > > Thanks in advance! > > -- > 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/a3f9f779-be19-4745-8d57-b51d37359051%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/a3f9f779-be19-4745-8d57-b51d37359051%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/CA%2BnsWgxS7%3DWNwyedu74r9uO2SP%3DxHTPu%3DSASKz%2B6cyy%3D-gG92A%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
