After upgrading Ansible to version 2.8.3, the “apt” module started spitting out deprecation warnings:
TASK [common : basic packages] ****************************************************************
[DEPRECATION WARNING]: Invoking "apt" only once while using a loop via squash_actions is deprecated. Instead of using a loop to supply multiple items and specifying `name: "{{ item }}"`, please use `name: ['vim', 'screen', 'rsync']` and remove the loop. This feature will be removed in version 2.11. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
ok: [hostname] => (item=['vim', 'screen', 'rsync'])
The cause of the warning is the following task (or other similar apt
tasks):
|
|
Apparently the apt
module is invoked for every item in the loop, and that is slow, and expensive.
There is a better way to do this:
|
|
But I yet have to figure out how to do this if the package names are in a variable. That is for another day …