Sorry, I'm being messy here.  If i try this, "select('search',
'!OpenJDK|Java\(TM\)')|", I get output like this:

somehost.mydomain.com
anotherhost.mydomain.com
['java version "1.7.0_71"', 'Java(TM) SE Runtime Environment (build
1.7.0_71-b14)', 'Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed
mode)']

On Tue, May 4, 2021 at 7:34 AM Dimitri Yioulos <
dimitri.yiou...@endurance.com> wrote:

> OK, almost got this!  And, I probably didn't explain what I'm after very
> well.  Based on the code you just provided, this is the output, e.g.:
>
> somehost.mydomain.com
> ['java version "1.7.0_65"', 'OpenJDK Runtime Environment
> (rhel-2.5.1.2.el6_5-x86_64 u65-b17)', 'OpenJDK 64-Bit Server VM (build
> 24.65-b04, mixed mode)']
>
> anotherhost.mydomain.com
> ['java version "1.7.0_71"', 'Java(TM) SE Runtime Environment (build
> 1.7.0_71-b14)', 'Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed
> mode)']
>
> However, I only want records containing "Java(TM)" returned.  How do I
> adjust the code to do that?
>
> On Tue, May 4, 2021 at 7:15 AM Vladimir Botka <vbo...@gmail.com> wrote:
>
>> On Tue, 4 May 2021 04:00:25 -0700 (PDT)
>> Dimitri Yioulos <dimitri.yiou...@endurance.com> wrote:
>>
>> > This:
>> >
>> > myserver1.mydomain.com
>> > ['java version "1.7.0_71"', 'Java(TM) SE Runtime Environment (build
>> > 1.7.0_71-b14)', 'Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01,
>> mixed
>> > mode)']
>> >
>> > myserver2.mydomain.com
>> > ['java version "1.7.0_71"', 'Java(TM) SE Runtime Environment (build
>> > 1.7.0_71-b14)', 'Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01,
>> mixed
>> > mode)']
>>
>> Try this
>>
>>         content: |
>>           {% for host in ansible_play_hosts %}
>>           {% set present = hostvars[host].java_one.stderr_lines|
>>                            select('search', 'OpenJDK|Java\(TM\)')|
>>                            list|length > 0 %}
>>           {{ host }}
>>           {% if present %}{{ hostvars[host].java_one.stderr_lines
>>         }}{% endif %}
>>
>>           {% endfor %}
>>
>> For details see https://jinja.palletsprojects.com/en/master/
>>
>> --
>> Vladimir Botka
>>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAP6aXgKWwBMz29ZM5V9O9KcaDFZWJNL-hWqXy%2BjyrKaaTesmMw%40mail.gmail.com.

Reply via email to