Using variables from custom script

20 views
Skip to first unread message

Mikel

unread,
Sep 5, 2019, 4:19:08 PM9/5/19
to Ansible Development
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

Mikel

unread,
Sep 5, 2019, 4:19:50 PM9/5/19
to Ansible Development
Edit for spelling: Playbook

Mikel

unread,
Sep 6, 2019, 1:06:42 PM9/6/19
to Ansible Development
Bump?

Sam Doran

unread,
Sep 9, 2019, 10:49:46 AM9/9/19
to Ansible Development
Mikel,

You can use the reboot plugin 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 or #ansible on IRC.

Reply all
Reply to author
Forward
0 new messages