Hi Alexander,
you put me in the right direction. I'd like to give a short example for my
solution:
---
- name: show return value of command yum
hosts: e-stage
tasks:
- name: command
command: yum update-minimal --advisory RHSA-2016:1234
register: yumlog
- command: reboot NOW
when: '"Completed!" in "{{ yumlog.stdout_lines[-1] }}"'
With "{{ yumlog.stdout_lines[-1] }}" I got the last item from the list and
do not have to think about the case when it occures somewhere else in the
output.
Greetz
Joerg
Am Mittwoch, 14. September 2016 19:40:42 UTC+2 schrieb Jörg Kastning:
>
> Hello,
>
> I would like to write a playbook to install Red Hat Security Advisory on
> my hosts. The idea is to put the published information about the advisories
> with their Numbers (e.g. RHSA-2016:1234) in a variable and run the
> following playbook on all hosts:
> ---
> - hosts: all
>
> tasks:
> - name: Group by OS
> group_by: key=os_{{ ansible_distribution }}
> changed_when: False
>
> - hosts: os_RedHat
> vars:
> RHSA: "RHSA-2016:1633, RHSA-2016:1626"
> tasks:
> - name: Install Red Hat Security Advisory
> command: yum update-minimal --advisory {{ RHSA }}
> register: yumoutput
>
> - name: Reboot if packages were updated
> command: reboot NOW
> when: yumoutput = ???
>
> As you could see I would like to reboot a host only in case packages were
> updated. As far as I know the last line in the yum output on the host
> should be "Complete!". But I have trouble to get only the last line from
> the output and use it in the conditional when clause.
>
> Could someone help me here, please?
>
> Because english is not my first language I may have difficulties to make
> my point. Please bare with me and ask for more details or points I have to
> make more clear.
>
> Kind regards,
> Joerg
>
--
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/476fc140-3d81-4ea7-bdfa-8745b4e180bb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.