Hi
Please find below my playbook
-
name: Patch the server and Reboot
hosts: tariq-test
tasks: -
name: Patch the server
become: yes
become_user: root
tags: Patch
shell: “yum -y update”
exclude: kernel*,mongo*
register: patchresult -
name: Reboot the server
tags: reboot
become: yes
become_user: root
shell: “sleep 5 && reboot”
async: 1
poll: 0 -
name: Wait for the reboot and reconnect
wait_for:
port: 22
host: ‘{{ (ansible_ssh_host|default(ansible_host))|default(inventory_hostname) }}’
search_regex: OpenSSH
delay: 10
timeout: 60
connection: local -
name: Check the Uptime of the servers
shell: “uptime”
register: Uptime -
debug: var=Uptime
I would like to able to run this via cron, but whenever I try, the job starts, according to the cron log, but doesn’t actually do anything.
I’ve tried allsorts, nothing works.
07 11 * * * /bin/ansible-playbook /etc/ansible/playbooks/reboot.yml >> /var/tmp/reboot.log >/dev/null 2>&1
06 12 * * * if ! out=ansible-playbook /etc/ansible/playbooks/reboot.yml
; then echo $out; fi
14 12 * * * /bin/ansible-playbook /etc/ansible/playbooks/reboot.yml >> /var/tmp/reboot.log >/dev/null 2>&1
Any ideas please?
Regards
Tariq