Re: [ansible-project] Set variable to some value if undefined

2019-05-24 Thread Tuyen Nguyen
Thank you!  This worked perfectly!!

On Monday, May 13, 2019 at 9:49:29 AM UTC-4, Brian Coca wrote:
>
> That is what the `default` filter is for: 
>
> when: install_office|default('n') == 'y' 
>
>
>
> -- 
> -- 
> 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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f8ec0387-e207-42d2-ac47-3597279693d7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Set variable to some value if undefined

2019-05-14 Thread Tuyen Nguyen
Hi

Thanks.  I will try this.  I think this should work.

On Monday, May 13, 2019 at 9:49:29 AM UTC-4, Brian Coca wrote:
>
> That is what the `default` filter is for: 
>
> when: install_office|default('n') == 'y' 
>
>
>
> -- 
> -- 
> 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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/7d5f3121-ae52-405c-b4b6-27d54adaf4e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Set variable to some value if undefined

2019-05-13 Thread Brian Coca
That is what the `default` filter is for:

when: install_office|default('n') == 'y'



-- 
--
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CACVha7fufu3U%3DTN7i-G2L_798t2-k-EBBabjMKeYtQbAbkAWZw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Set variable to some value if undefined

2019-05-13 Thread Tuyen Nguyen
Hi

I have a playbook whereby I pass variables in such as install_office == 
'y', and I have tasks where it would only include_tasks for a task file to 
install Office (for example) when install_office == 'y'

eg.

  tasks:
  - name: Install Office
include_tasks: installoffice.yml
when: install_office == 'y'

And when I did not want Office installed, I needed to explicitly define a 
variable to install_office == 'n' (or anything else other than y would work 
as well), else Ansible tells me that install_office variable is not defined.

How can I set it so that if I do not define the variable, it will default 
to 'n'?  Right now I am using include_vars: to include a file defining each 
of the variables, and for each variable, I set it as 'y' or 'no' based on 
whether I want to include the task to my main playbook or not.  It would be 
more simpler if I can just define the ones I want to include as 'y' and let 
everything else that my playbook expects but is not defined to be set to 
'n'.

Please let me know what I can do?  Thanks!!

 

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/3818cd43-a9b3-4f6c-9230-3ca941e557e7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.