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