Ansible with_items single or multiple module call

ansible

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.