When I setup an ansible task with with_items
to install software with the apt
module like this:
- name: ensure base packagase are installed
apt:
name: "{{ item }}"
state: latest
update_cache: yes
with_items: "{{ system_base_packages }}"
Will the apt
module be called multiple times as well as the update_cache
? Or is this a single call to the module?
My main concern is that I do not want to update the cache multiple times for every software inside the array to be installed.
Best Answer
The following modules
apk, apt, dnf, package*, pacman, pkgng, yum, zypper
are smart to squash your items into single run.See this SO answer for links.
package
as of Ansible 2.3 (2017-04-12) no longer has it's items squashed. This can be overcome by specifyingsquash_actions=
in the[defaults]
section of your ansible.cfg file.