# Running command "when"

**URL:** <https://forum.ansible.com/t/running-command-when/17128>\
**Category:** Ansible Project\
**Created:** [December 22, 2014, 7:07pm UTC](https://forum.ansible.com/t/running-command-when/17128 "2014-12-22T19:07:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dyioulos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dyioulos/32/8363_2.png) [@dyioulos](https://forum.ansible.com/u/dyioulos)\
**Post date:** [December 22, 2014, 7:07pm UTC](https://forum.ansible.com/t/running-command-when/17128/1 "2014-12-22T19:07:36Z")

</div>

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:

---

<div class="post-metadata">

**Author:** ![dyioulos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dyioulos/32/8363_2.png) [@dyioulos](https://forum.ansible.com/u/dyioulos)\
**Post date:** [December 23, 2014, 5:31pm UTC](https://forum.ansible.com/t/running-command-when/17128/2 "2014-12-23T17:31:23Z")

</div>

With some help from IRC channel, the fix was really simple. And, I was able to streamline, too. Here’s the working copy of my playbook:
