Hey ho,

> You can't say "when:" twice, but you can feed it a list.
> 
> when:
>    - item.useApplication
>    - other_conditional

perfect!

> What you are doing with building a variable name in a conditional is a little 
> weird, and this doesn't work.
> 
> Rather, register when used with "with_items" will return an array, which you 
> can easily debug:
> 
>  - stat: path=/etc/.git
>    register: stats 
>    with_items: hosts
>    when: item.useApplication
> 
> - debug: var=stats
> 
> Though ultimately, it looks like you should drop the lineinfile and just 
> include your logic in a template, and it will be much cleaner and easier.

I do that with templates but I want to unzip, move and copy some files to 
create a perfect application environment. Perhaps your return of an array will 
solve my problem^^.

As soon as I tried this solution I will give you an answer! Thanks for the 
moment!


> On Mon, Aug 25, 2014 at 4:46 AM, Bastian Bringenberg 
> <[email protected]> wrote:
> Hey ho,
> 
> I would like to deploy an application to several vhosts is 
> item.useApplication exists. I am possible to do that, download files and so 
> on and so on. But I get a problem as soon as I want to do an action if the 
> application is never installed.
> 
> Normally:
> 
> - stat: path=/etc/.git
>   register: exists_git
>   ignore_errors: yes
> 
> - lineinfile: dest=/etc/rkhunter.conf line='ALLOWHIDDENDIR="/etc/.git"' 
> owner=root group=root mode=0644
>   when: exists_git.stat.exists
> 
> But how is it possible for me to do this combined with "with_items"? One 
> approach, that (untested) will not work in my opinion:
> 
>  - stat: path=/etc/.git
>   register: exists_git_{{ item.name }}
>   with_items: hosts
>   when: item.useApplication
>   ignore_errors: yes
> 
> - lineinfile: dest=/etc/rkhunter.conf line='ALLOWHIDDENDIR="/etc/.git"' 
> owner=root group=root mode=0644
>   with_items: hosts
>   when: item.useApplication
>   when: exists_git_{{ item.name }}.stat.exists
> 
> Is someone able to help me here?
> 
> Have a nice week,
> Greetings from Bochum, RuhrArea, Germany,
> 
> Bastian
> 
> 
> PS: rkhunter is just a demonstration how I do this normally^^.
> 
> -- 
> 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/2ced1119-8fda-4ace-a27b-db3879280f55%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
> 
> 
> -- 
> You received this message because you are subscribed to a topic in the Google 
> Groups "Ansible Project" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/ansible-project/ZP5szDnH0iI/unsubscribe.
> To unsubscribe from this group and all its topics, 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%2BnsWgxWa3O298BBd6c2NqRPbQ0%3Da8PeaX8FquF7mdNin%2BgK-w%40mail.gmail.com.
> 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/55594D8D-3F7B-4FF3-94BF-0C096BE35CAA%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to