{"id":3564,"date":"2018-10-27T10:46:05","date_gmt":"2018-10-27T15:46:05","guid":{"rendered":"https:\/\/dev.iachieved.it\/iachievedit\/?p=3564"},"modified":"2018-10-27T10:46:05","modified_gmt":"2018-10-27T15:46:05","slug":"ansible-2-7-deprecation-warning-apt-and-squash_actions","status":"publish","type":"post","link":"https:\/\/dev.iachieved.it\/iachievedit\/ansible-2-7-deprecation-warning-apt-and-squash_actions\/","title":{"rendered":"Ansible 2.7 Deprecation Warning &#8211; apt and squash_actions"},"content":{"rendered":"<p>Ansible 2.7 was released recently and along with it brought a new deprecation warning for the <code>apt<\/code> module:<\/p>\n<p>[code lang=text]<br \/>\nTASK [Install base packages] ******************************************<br \/>\nThursday 18 October 2018  15:35:52 +0000 (0:00:01.648)       0:06:25.667 ******<br \/>\n[DEPRECATION WARNING]: Invoking &quot;apt&quot; only once while using a loop via<br \/>\nsquash_actions is deprecated. Instead of using a loop to supply multiple items<br \/>\nand specifying `name: {{ item }}`, please use `name: [u&#039;htop&#039;, u&#039;zsh&#039;, u&#039;s3cmd&#039;]` and remove<br \/>\nthe loop. This feature will be removed in version 2.11. Deprecation warnings<br \/>\ncan be disabled by setting deprecation_warnings=False in ansible.cfg.<br \/>\n[\/code]<\/p>\n<p>Our <code>apt<\/code> task was:<\/p>\n<p>[code lang=text]<br \/>\n&#8211; name:  Install base packages<br \/>\n  apt:<br \/>\n    name:  &quot;{{ item }}&quot;<br \/>\n    state: present<br \/>\n    update_cache: yes<br \/>\n  with_items:<br \/>\n    &#8211; htop<br \/>\n    &#8211; zsh<br \/>\n    &#8211; s3cmd<br \/>\n[\/code]<\/p>\n<p>Very standard.<\/p>\n<p>The new style with Ansible 2.7 should look like:<\/p>\n<p>[code lang=text]<br \/>\n&#8211; name:  Install base packages<br \/>\n  apt:<br \/>\n    name:  &quot;{{ packages }}&quot;<br \/>\n    state: present<br \/>\n    update_cache:  yes<br \/>\n  vars:<br \/>\n    packages:<br \/>\n      &#8211; htop<br \/>\n      &#8211; zsh<br \/>\n      &#8211; s3cmd<br \/>\n[\/code]<\/p>\n<p>The change is self-explanatory (and is alluded to in the deprecation warning):  rather than loop over a list and applying the <code>apt<\/code> module, provide the module with a list of items to process.<\/p>\n<p>You can read up on the documentation for <code>apt<\/code> in Ansible 2.7 <a href=\"https:\/\/docs.ansible.com\/ansible\/2.7\/modules\/apt_module.html\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ansible 2.7 was released recently and along with it brought a new deprecation warning for the apt module: [code lang=text] TASK [Install base packages] ****************************************** Thursday 18 October 2018 15:35:52 +0000 (0:00:01.648) 0:06:25.667 ****** [DEPRECATION WARNING]: Invoking &quot;apt&quot; only once while using a loop via squash_actions is deprecated. Instead of using a loop to supply [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3318,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[68,21],"tags":[],"class_list":["post-3564","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ansible","category-devops"],"_links":{"self":[{"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/posts\/3564"}],"collection":[{"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/comments?post=3564"}],"version-history":[{"count":2,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/posts\/3564\/revisions"}],"predecessor-version":[{"id":3567,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/posts\/3564\/revisions\/3567"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/media\/3318"}],"wp:attachment":[{"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/media?parent=3564"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/categories?post=3564"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.iachieved.it\/iachievedit\/wp-json\/wp\/v2\/tags?post=3564"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}