blob: 6622b64a0ced8d0331973556f9a891908c107f2a [file] [log] [blame]
# This ansible script will restart a bot if it is not currently running a swarming task.
---
- hosts: all
remote_user: chrome-bot
become_user: root
become: yes
become_method: sudo
tasks:
- name: Check for a running swarming task.
shell: ps aux | grep task_runner | wc -l
register: process_count
# If there is a running task, ansible reports 3 (or more) results from ps
# I believe this to because the grep command itself has "task_runner" in it
# and the ansible shell part that triggers the command has "task_runner" in it
# so 2 is the baseline, 3 or more means swarming added 1 (or more) lines
- name: Reboot if there is not a running task
command: reboot
ignore_errors: yes
when: process_count.stdout|int <= 2