--- - name: Ensure packages are present hosts: all vars: iproute_package_name: redhat: iproute debian: iproute2 iputils_package_name: redhat: iputils debian: iputils-ping tasks: - name: Install required packages package: name: "{{ item }}" state: present update_cache: true with_items: - ca-certificates - "{{ iproute_package_name[ansible_facts['os_family'] | lower] }}" - "{{ iputils_package_name[ansible_facts['os_family'] | lower] }}" - name: Clear gathered facts meta: clear_facts