{"id":1022,"date":"2021-03-06T19:47:24","date_gmt":"2021-03-06T17:47:24","guid":{"rendered":"http:\/\/www.netexpertise.eu\/en\/?p=1022"},"modified":"2021-08-10T08:13:46","modified_gmt":"2021-08-10T06:13:46","slug":"why-ansible-upgrades-on-hold-packages-and-how-to-fix-it","status":"publish","type":"post","link":"http:\/\/www.netexpertise.eu\/en\/devops\/ansible\/why-ansible-upgrades-on-hold-packages-and-how-to-fix-it.html","title":{"rendered":"Why Ansible Upgrades Packages on Hold and How to Fix it"},"content":{"rendered":"\n<p>I was writing a new <a href=\"\/en\/category\/devops\/ansible\">Ansible<\/a> role to upgrade all of my VMs with <em>apt update<\/em> and <em>apt upgrade<\/em>. I was still using an old Rancher that only works with docker-ce package up to version 18.06.<\/p>\n\n\n\n<p>A first task holds back the package with <a href=\"https:\/\/docs.ansible.com\/ansible\/latest\/collections\/ansible\/builtin\/dpkg_selections_module.html\">Ansible Dpkg module<\/a>, basically an <em>apt hold<\/em>, as recommended on many websites.<br>A second and third steps run an <em>apt update<\/em> and <em>apt full upgrade<\/em> on my system with <a href=\"https:\/\/docs.ansible.com\/ansible\/latest\/collections\/ansible\/builtin\/apt_module.html\">Ansible apt module<\/a>. <br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"yaml\" class=\"language-yaml\"><code>- name: keep docker from being updated on Rancher nodes\n\u00a0 dpkg_selections:\n\u00a0 \u00a0 name: docker-ce\n\u00a0 \u00a0 selection: hold<\/code>\n- name: apt update cache\n  apt:\n    update_cache: yes\n  changed_when: False\n<code>\n- name: apt full-upgrade\n\u00a0 apt:\n\u00a0 \u00a0 upgrade: full<\/code><\/code><\/pre>\n\n\n\n<p><br>I then launch my playbook full of confidence and, see docker-ce being upgraded! Oddly, this seems to impact Ubuntu distributions, while it runs smoothly on Debian family.<br><br><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><a href=\"http:\/\/www.netexpertise.eu\/en\/wp-content\/uploads\/moto-cross-sport-race-vehicle-4697302.jpg\"><img decoding=\"async\" src=\"\/uploads\/moto-cross-sport-race-vehicle-4697302.jpg\" alt=\"Moto Cross Sport Race Vehicle\"\/><\/a><figcaption><a href=\"https:\/\/pixabay.com\/users\/Vitrioline\">Vitrioline<\/a> \/ Pixabay<\/figcaption><\/figure><\/div>\n\n\n\n<p><br>The <a href=\"https:\/\/docs.ansible.com\/ansible\/latest\/collections\/ansible\/builtin\/apt_module.html\">Ansible apt module<\/a> page states &#8220;If full, performs an aptitude full-upgrade&#8221;.<br>Let&#8217;s check the package on hold after the first step:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\"><strong>$<\/strong> dpkg -l | grep docker\nhi&nbsp; docker-ce   18.06.3~ce~3-0~ubuntu.  amd64.  Docker: the open-source application container engine<\/code><\/pre>\n\n\n\n<p><br>Same with aptitude:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\"><strong>$<\/strong> aptitude search ~i | grep docker\ni&nbsp; docker-ce - Docker: the open-source application container engine<\/code><\/pre>\n\n\n\n<p>h for hold is MISSING!<\/p>\n\n\n\n<p><br>apt-get and aptitude seem to rely on different hold functions, thus &#8220;dpkg &#8211;selections&#8221; doesn&#8217;t assure that aptitude (which is the command that performs the upgrade) will not touch the held packages.<\/p>\n\n\n\n<p><br>What now?<br>We&#8217;re lucky, Ansible apt module provides a way to force updating with apt-get instead of aptitude<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"yaml\" class=\"language-yaml\">- name: apt full-upgrade\n&nbsp; apt:\n&nbsp; &nbsp; upgrade: full\n&nbsp; &nbsp; force_apt_get: yes<\/code><\/pre>\n\n\n\n<p>And it did solve my problem<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was writing a new Ansible role to upgrade all of my VMs with apt update and apt upgrade. I was still using an old Rancher that only works with docker-ce package up to version 18.06. A first task holds back the package with Ansible Dpkg module, basically an apt hold, as recommended on many [&hellip;]<\/p>\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},"categories":[427],"tags":[429,169,386,170],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.8.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Netexpertise - Why Ansible Upgrades Packages on Hold and How to Fix it<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/www.netexpertise.eu\/en\/devops\/ansible\/why-ansible-upgrades-on-hold-packages-and-how-to-fix-it.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Netexpertise - Why Ansible Upgrades Packages on Hold and How to Fix it\" \/>\n<meta property=\"og:description\" content=\"I was writing a new Ansible role to upgrade all of my VMs with apt update and apt upgrade. I was still using an old Rancher that only works with docker-ce package up to version 18.06. A first task holds back the package with Ansible Dpkg module, basically an apt hold, as recommended on many [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.netexpertise.eu\/en\/devops\/ansible\/why-ansible-upgrades-on-hold-packages-and-how-to-fix-it.html\" \/>\n<meta property=\"og:site_name\" content=\"Netexpertise\" \/>\n<meta property=\"article:published_time\" content=\"2021-03-06T17:47:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-08-10T06:13:46+00:00\" \/>\n<meta name=\"author\" content=\"dave\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@netexpertise\" \/>\n<meta name=\"twitter:site\" content=\"@netexpertise\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"http:\/\/www.netexpertise.eu\/en\/devops\/ansible\/why-ansible-upgrades-on-hold-packages-and-how-to-fix-it.html\",\"url\":\"http:\/\/www.netexpertise.eu\/en\/devops\/ansible\/why-ansible-upgrades-on-hold-packages-and-how-to-fix-it.html\",\"name\":\"Netexpertise - Why Ansible Upgrades Packages on Hold and How to Fix it\",\"isPartOf\":{\"@id\":\"http:\/\/www.netexpertise.eu\/en\/#website\"},\"datePublished\":\"2021-03-06T17:47:24+00:00\",\"dateModified\":\"2021-08-10T06:13:46+00:00\",\"author\":{\"@id\":\"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa\"},\"breadcrumb\":{\"@id\":\"http:\/\/www.netexpertise.eu\/en\/devops\/ansible\/why-ansible-upgrades-on-hold-packages-and-how-to-fix-it.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/www.netexpertise.eu\/en\/devops\/ansible\/why-ansible-upgrades-on-hold-packages-and-how-to-fix-it.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/www.netexpertise.eu\/en\/devops\/ansible\/why-ansible-upgrades-on-hold-packages-and-how-to-fix-it.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/www.netexpertise.eu\/en\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Why Ansible Upgrades Packages on Hold and How to Fix it\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/www.netexpertise.eu\/en\/#website\",\"url\":\"http:\/\/www.netexpertise.eu\/en\/\",\"name\":\"Netexpertise\",\"description\":\"Systems \/ Networks \/ DevOps\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/www.netexpertise.eu\/en\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa\",\"name\":\"dave\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g\",\"contentUrl\":\"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g\",\"caption\":\"dave\"},\"sameAs\":[\"http:\/\/www.netexpertise.eu\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Netexpertise - Why Ansible Upgrades Packages on Hold and How to Fix it","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/www.netexpertise.eu\/en\/devops\/ansible\/why-ansible-upgrades-on-hold-packages-and-how-to-fix-it.html","og_locale":"en_US","og_type":"article","og_title":"Netexpertise - Why Ansible Upgrades Packages on Hold and How to Fix it","og_description":"I was writing a new Ansible role to upgrade all of my VMs with apt update and apt upgrade. I was still using an old Rancher that only works with docker-ce package up to version 18.06. A first task holds back the package with Ansible Dpkg module, basically an apt hold, as recommended on many [&hellip;]","og_url":"http:\/\/www.netexpertise.eu\/en\/devops\/ansible\/why-ansible-upgrades-on-hold-packages-and-how-to-fix-it.html","og_site_name":"Netexpertise","article_published_time":"2021-03-06T17:47:24+00:00","article_modified_time":"2021-08-10T06:13:46+00:00","author":"dave","twitter_card":"summary_large_image","twitter_creator":"@netexpertise","twitter_site":"@netexpertise","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"http:\/\/www.netexpertise.eu\/en\/devops\/ansible\/why-ansible-upgrades-on-hold-packages-and-how-to-fix-it.html","url":"http:\/\/www.netexpertise.eu\/en\/devops\/ansible\/why-ansible-upgrades-on-hold-packages-and-how-to-fix-it.html","name":"Netexpertise - Why Ansible Upgrades Packages on Hold and How to Fix it","isPartOf":{"@id":"http:\/\/www.netexpertise.eu\/en\/#website"},"datePublished":"2021-03-06T17:47:24+00:00","dateModified":"2021-08-10T06:13:46+00:00","author":{"@id":"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa"},"breadcrumb":{"@id":"http:\/\/www.netexpertise.eu\/en\/devops\/ansible\/why-ansible-upgrades-on-hold-packages-and-how-to-fix-it.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.netexpertise.eu\/en\/devops\/ansible\/why-ansible-upgrades-on-hold-packages-and-how-to-fix-it.html"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/www.netexpertise.eu\/en\/devops\/ansible\/why-ansible-upgrades-on-hold-packages-and-how-to-fix-it.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/www.netexpertise.eu\/en"},{"@type":"ListItem","position":2,"name":"Why Ansible Upgrades Packages on Hold and How to Fix it"}]},{"@type":"WebSite","@id":"http:\/\/www.netexpertise.eu\/en\/#website","url":"http:\/\/www.netexpertise.eu\/en\/","name":"Netexpertise","description":"Systems \/ Networks \/ DevOps","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/www.netexpertise.eu\/en\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa","name":"dave","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/image\/","url":"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g","contentUrl":"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g","caption":"dave"},"sameAs":["http:\/\/www.netexpertise.eu"]}]}},"_links":{"self":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/posts\/1022"}],"collection":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/comments?post=1022"}],"version-history":[{"count":0,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/posts\/1022\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/media?parent=1022"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/categories?post=1022"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/tags?post=1022"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}