# Using variables from custom script

**URL:** <https://forum.ansible.com/t/using-variables-from-custom-script/31213>\
**Category:** Ansible Developer\
**Created:** [September 5, 2019, 8:19pm UTC](https://forum.ansible.com/t/using-variables-from-custom-script/31213 "2019-09-05T20:19:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mikel](https://avatars.discourse-cdn.com/v4/letter/m/e480ec/32.png) [@Mikel](https://forum.ansible.com/u/Mikel)\
**Post date:** [September 5, 2019, 8:19pm UTC](https://forum.ansible.com/t/using-variables-from-custom-script/31213/1 "2019-09-05T20:19:08Z")

</div>

Howdy all

I have a playback that I want to run hourly to check for new hosts and I have a script that returns a variable of new and this host gets the yum update and yum reboot and then come around again this host variable is now old...

My question is how can I get this playbook to run the yum update and reboot when the variable returns as new?

If the variable is old then it skips this

---

<div class="post-metadata">

**Author:** ![Mikel](https://avatars.discourse-cdn.com/v4/letter/m/e480ec/32.png) [@Mikel](https://forum.ansible.com/u/Mikel)\
**Post date:** [September 5, 2019, 8:19pm UTC](https://forum.ansible.com/t/using-variables-from-custom-script/31213/2 "2019-09-05T20:19:50Z")

</div>

Edit for spelling: Playbook

---

<div class="post-metadata">

**Author:** ![Mikel](https://avatars.discourse-cdn.com/v4/letter/m/e480ec/32.png) [@Mikel](https://forum.ansible.com/u/Mikel)\
**Post date:** [September 6, 2019, 5:06pm UTC](https://forum.ansible.com/t/using-variables-from-custom-script/31213/3 "2019-09-06T17:06:41Z")

</div>

Bump?

---

<div class="post-metadata">

**Author:** ![sdoran](https://avatars.discourse-cdn.com/v4/letter/s/47e85d/32.png) [@sdoran](https://forum.ansible.com/u/sdoran)\
**Post date:** [September 9, 2019, 2:49pm UTC](https://forum.ansible.com/t/using-variables-from-custom-script/31213/4 "2019-09-09T14:49:46Z")

</div>

Mikel,

You can use the [reboot plugin](https://docs.ansible.com/ansible/latest/modules/reboot_module.html) with a conditional to control when the system is rebooted.

`

- name: Reboot the system  
reboot:  
when: my\_yum\_variable != ‘new’  
`

This question is better answered on the [Ansible Project mailing list](https://groups.google.com/forum/#!forum/ansible-project) or [#ansible on IRC](https://webchat.freenode.net/#ansible).
