Hi, all.
I'm an Ansible newbie trying to create a playbook which will: 1) update all
packages on a CentOS 6 box via yum, and 2) reboot the server if the kernel
has been updated. Here's my palybook:
---
- hosts: all
tasks:
- name: yum update
yum: name=* state=latest
- name: Check for reboot hint.
shell: if [ `rpm -qa --last|grep kernel-2.6| cut -d'-' -f2- | awk
'{print $1}' | head -n 1` != `uname -r` ]; then echo "reboot"; else echo
"no"; fi
ignore_errors: true
register: reboot_hint
- name: Rebooting ...
command: shutdown -r now "Yum kernel update applied"
when: reboot_hint.stdout.find('reboot') == 'reboot'
async: 0
poll: 0
ignore_errors: true
register: rebooting
(the last "register" is meaningless for the time being)
The "Check for reboot hint" works, as tested against machines requiring a
reboot and those not, via a test bash script. However, no matter wheat I
put in my "when" conditional in the playbook, it fails with "error while
evaluating conditional".
Help would be greatly appreciated.
Dimitri
--
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/9b706258-5fbf-47c9-a956-9ca13cca8743%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.