{"id":181,"date":"2016-10-29T13:10:19","date_gmt":"2016-10-29T12:10:19","guid":{"rendered":"http:\/\/www.carmichaelclan.net\/?p=181"},"modified":"2016-10-29T13:13:33","modified_gmt":"2016-10-29T12:13:33","slug":"ansible-code-to-update-all-raspberry-pi","status":"publish","type":"post","link":"https:\/\/www.carmichaelclan.net\/?p=181","title":{"rendered":"Ansible code to update all Raspberry Pi"},"content":{"rendered":"<p>The following code will one by one update your raspberry Pis and then reboot them.<\/p>\n<hr \/>\n<p><code><br \/>\n---<br \/>\n- hosts: all<br \/>\nremote_user: pi<br \/>\nserial: 1<\/code><\/p>\n<p>tasks:<br \/>\n&#8211; name: Update all packages<br \/>\napt:<br \/>\nupgrade: dist<br \/>\nupdate_cache: yes<br \/>\nbecome: yes<br \/>\nregister: updated<\/p>\n<p>&#8211; name: Reboot Machine if updated<br \/>\ncommand: shutdown -r +1<br \/>\nasync: 1<br \/>\npoll: 0<br \/>\nignore_errors: true<br \/>\nbecome: yes<br \/>\nwhen: updated.changed<\/p>\n<p>&#8211; name: Wait for Machine to come back online<br \/>\nlocal_action: wait_for<br \/>\nhost={{ inventory_hostname }}<br \/>\nport=22<br \/>\nstate=started<br \/>\ndelay=65<br \/>\nwhen: updated.changed<br \/>\n~<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The following code will one by one update your raspberry Pis and then reboot them. &#8212; &#8211; hosts: all remote_user: pi serial: 1 tasks: &#8211; name: Update all packages apt: upgrade: dist update_cache: yes become: yes register: updated &#8211; name: Reboot Machine if updated command: shutdown -r +1 async: 1 poll: 0 ignore_errors: true become: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-181","post","type-post","status-publish","format-standard","hentry","category-ansible"],"_links":{"self":[{"href":"https:\/\/www.carmichaelclan.net\/index.php?rest_route=\/wp\/v2\/posts\/181","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.carmichaelclan.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.carmichaelclan.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.carmichaelclan.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.carmichaelclan.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=181"}],"version-history":[{"count":4,"href":"https:\/\/www.carmichaelclan.net\/index.php?rest_route=\/wp\/v2\/posts\/181\/revisions"}],"predecessor-version":[{"id":185,"href":"https:\/\/www.carmichaelclan.net\/index.php?rest_route=\/wp\/v2\/posts\/181\/revisions\/185"}],"wp:attachment":[{"href":"https:\/\/www.carmichaelclan.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=181"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.carmichaelclan.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=181"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.carmichaelclan.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=181"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}