Hi Dmitry,
I would suggest you to use my approach bellow:
# Load a variable file based on the OS type, or a default if not found.
- include_vars: "{{ item }}"
with_first_found:
- "{{ ansible_distribution }}.yml"
- "{{ ansible_os_family }}.yml"
- "default.yml"
- action: '{{ pkg_mgr }} name={{ item }} state=latest'
with_items: packages
# Ubuntu.yml
pkg_mgr: apt
packages:
- bash
- screen
- curl
Here is a gist: https://gist.github.com/hostmaster/db37c8e6c2a43997a224
-- Best, Igor