{"id":28614,"date":"2018-06-07T09:54:59","date_gmt":"2018-06-07T07:54:59","guid":{"rendered":"https:\/\/mamchenkov.net\/wordpress\/?p=28614"},"modified":"2018-06-07T09:54:59","modified_gmt":"2018-06-07T07:54:59","slug":"reboot-and-wait-for-reboot-to-complete-in-ansible-playbook","status":"publish","type":"post","link":"https:\/\/mamchenkov.net\/wordpress\/2018\/06\/07\/reboot-and-wait-for-reboot-to-complete-in-ansible-playbook\/","title":{"rendered":"Reboot and wait for reboot to complete in Ansible playbook"},"content":{"rendered":"<!-- google_ad_section_start -->\n<p><a href=\"https:\/\/www.jeffgeerling.com\/\">Jeff Geerling<\/a> shares a handy tip on how to implement the <a href=\"https:\/\/www.jeffgeerling.com\/blog\/2018\/reboot-and-wait-reboot-complete-ansible-playbook\">configure-reboot-configure pattern in an Ansible playbook<\/a>.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n---\r\n- name: Do something that requires a reboot when it results in a change.\r\n  ...\r\n  register: task_result\r\n\r\n- name: Reboot immediately if there was a change.\r\n  shell: &quot;sleep 5 &amp;&amp; reboot&quot;\r\n  async: 1\r\n  poll: 0\r\n  when: task_result is changed\r\n\r\n- name: Wait for the reboot to complete if there was a change.\r\n  wait_for_connection:\r\n    connect_timeout: 20\r\n    sleep: 5\r\n    delay: 5\r\n    timeout: 300\r\n  when: task_result is changed\r\n\r\n...\r\n<\/pre>\n<!-- google_ad_section_end -->\n","protected":false},"excerpt":{"rendered":"<!-- google_ad_section_start -->\n<p>Jeff Geerling shares a handy tip on how to implement the configure-reboot-configure pattern in an Ansible playbook. &#8212; &#8211; name: Do something that requires a reboot when it results in a change. &#8230; register: task_result &#8211; name: Reboot immediately if there was a change. shell: &quot;sleep 5 &amp;&amp; reboot&quot; async: 1 poll: 0 when: task_result &hellip; <a href=\"https:\/\/mamchenkov.net\/wordpress\/2018\/06\/07\/reboot-and-wait-for-reboot-to-complete-in-ansible-playbook\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Reboot and wait for reboot to complete in Ansible playbook<\/span><\/a><\/p>\n<!-- google_ad_section_end -->\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"Reboot and wait for reboot to complete in Ansible playbook #SysAdmin #Ansible #DevOps #hosting","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_links_to":"","_links_to_target":""},"categories":[1,6,133,62,1334],"tags":[3383,2289],"keyring_services":[],"class_list":["post-28614","post","type-post","status-publish","format-standard","hentry","category-general","category-linux","category-sysadmin","category-technology","category-web-work","tag-ansible","tag-web-hosting"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":26016,"url":"https:\/\/mamchenkov.net\/wordpress\/2016\/04\/12\/pedantically-commented-ansible-playbook\/","url_meta":{"origin":28614,"position":0},"title":"Pedantically commented Ansible playbook","author":"Leonid Mamchenkov","date":"April 12, 2016","format":false,"excerpt":"Here is a nice example Ansible playbook with lots and lots of comments, showing how things work. \u00a0 https:\/\/gist.github.com\/marktheunissen\/2979474","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26931,"url":"https:\/\/mamchenkov.net\/wordpress\/2016\/11\/21\/using-ansible-to-bootstrap-an-amazon-ec2-instance\/","url_meta":{"origin":28614,"position":1},"title":"Using Ansible to bootstrap an Amazon EC2 instance","author":"Leonid Mamchenkov","date":"November 21, 2016","format":false,"excerpt":"This article - \"Using Ansible to Bootstrap My Work Environment Part 4\" is pure gold for anyone trying to figure out all the moving parts needed to automate the provisioning and configuration of the Amazon EC2 instance with Ansible. Sure, some bits are easier than the other, but it takes\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26227,"url":"https:\/\/mamchenkov.net\/wordpress\/2016\/07\/07\/forcing-amazon-linux-ami-compatibility-with-centos-in-ansible\/","url_meta":{"origin":28614,"position":2},"title":"Forcing Amazon Linux AMI compatibility with CentOS in Ansible","author":"Leonid Mamchenkov","date":"July 7, 2016","format":false,"excerpt":"One of the things that makes Ansible so awesome is a huge collection of shared roles over at Ansible Galaxy. \u00a0These bring you best practices, flexible configurations and in general save hours and hours of hardcore swearing and hair pulling. Each role usually supports multiple versions of multiple Linux distributions.\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26004,"url":"https:\/\/mamchenkov.net\/wordpress\/2016\/04\/07\/ansible-safety-net-for-dns-wildcard-hosts\/","url_meta":{"origin":28614,"position":3},"title":"Ansible safety net for DNS wildcard hosts","author":"Leonid Mamchenkov","date":"April 7, 2016","format":false,"excerpt":"After using Ansible for only a week, I am deeply in love. \u00a0I am doing more and more with less and less, and that's exactly how I want my automation. Today I had to solve an interesting problem. \u00a0Ansible operates, based on the host and group inventory. \u00a0As I mentioned\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":27794,"url":"https:\/\/mamchenkov.net\/wordpress\/2017\/07\/24\/fedora-26-update\/","url_meta":{"origin":28614,"position":4},"title":"Fedora 26 Update","author":"Leonid Mamchenkov","date":"July 24, 2017","format":false,"excerpt":"Fedora 26 has been release about a month and a half ago. \u00a0But I didn't have the time to update my laptop until today. \u00a0There was also nothing particularly exciting for me in this release, so there was no rush. Here's what I had to do today to update my\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":24935,"url":"https:\/\/mamchenkov.net\/wordpress\/2015\/11\/04\/fedora-23-and-upgrade-issues\/","url_meta":{"origin":28614,"position":5},"title":"Fedora 23 and upgrade issues","author":"Leonid Mamchenkov","date":"November 4, 2015","format":false,"excerpt":"\u00a0 Fedora 23 has been released yesterday, and as a big fan and a long time user I had to upgrade my laptop (from Fedora 22) immediately. \u00a0Or at least try. Usually, the process is quite simple and doesn't take much figuring out. \u00a0This time it was somewhat different though.\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"fedora","src":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2015\/11\/fedora-500x212.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/28614","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/comments?post=28614"}],"version-history":[{"count":0,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/28614\/revisions"}],"wp:attachment":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/media?parent=28614"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/categories?post=28614"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/tags?post=28614"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/keyring_services?post=28614"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}