ssh - How can I use ansible playbook to reboot a ubuntu server? -
i trying build ansible playbook configure ubuntu vagrant box. playbook pretty working exception of controlling ubuntu box reboot after upgrading kernel.
i have host file ansible follow :
localhost ansible_connection=local dockerhost ansible_ssh_port=2222 ansible_ssh_host=127.0.0.1
the latest iteration tried solve problem follow :
- name: restart server shell: sleep 2s && reboot & executable=/bin/bash - name: wait until virtual machine stop ie: ssh port stop responding local_action: wait_for host={{ansible_ssh_host}} port={{ansible_ssh_port}} state=stopped sudo: false - name: wait server come local_action: wait_for host={{ansible_ssh_host}} port={{ansible_ssh_port}} delay=30 sudo: false
with playbook steps process block waiting ssh port stop responding, until reach timeout , exit playbook, guessing if reboot particularly fast might happen in between polling intervals of wait_for command , miss short time when ssh port down. error returned ansible :
failed: [dockerhost] => {"elapsed": 300, "failed": true} msg: timeout when waiting 127.0.0.1:2222 stop.
at least once managed step ansible wait ssh port available again hung there until timing out. think solution sensitive difference in reboot speed, can vary in virtual environment. ansible version using 1.5.3 ubuntu 12.04lte kernel upgrade 3.8 complete playbook install docker , dependencies.
i tried many variations , ideas found in various web sites never managed control reboot , continue playbook next steps.
i looking simple , fool proof way of rebooting server , continuing next steps in playbook once machine , running
i have not explored possibility of running local vagrant reload because want use same playbook in operation not running vagrant, mentioned vagrant in case creates complexities not aware of. don't want pause 5 minutes , hope server again, point of using kind of tools provision servers in predictable , timely manner , portable environment environment, pause not seem right.
i have looked around ansible module manage requirement comments on ansible web site seem rule out.
thanks
might suggest use bridge or private network. using port forward might tricky. used code private , bridged network worked both.
Comments
Post a Comment