diff --git a/roles/kubernetes/preinstall/tasks/0070-system-packages.yml b/roles/kubernetes/preinstall/tasks/0070-system-packages.yml index 7f0c054748d..1e27c6b7af2 100644 --- a/roles/kubernetes/preinstall/tasks/0070-system-packages.yml +++ b/roles/kubernetes/preinstall/tasks/0070-system-packages.yml @@ -60,13 +60,27 @@ - bootstrap-os - name: Install packages requirements + vars: + # The json_query for selecting packages name is split for readability + # see files/pkgs-schema.json for the structure of `pkgs` + # and the matching semantics + full_query: "[? value | ( {{ filters_os }} ) && ( {{ filters_groups }} ) ].key" + filters_groups: "groups | @ == null || [? contains(`{{ group_names }}`, @)]" + filters_os: "os == null || (os | ( {{ filters_family }} ) || ( {{ filters_distro }} ))" + dquote: !unsafe '"' + # necessary to workaround Ansible escaping + filters_distro: "distributions.{{ dquote }}{{ ansible_distribution }}{{ dquote }} | + @ == `{}` || + contains(not_null(major_versions, `[]`), '{{ ansible_distribution_major_version }}') || + contains(not_null(versions, `[]`), '{{ ansible_distribution_version }}') || + contains(not_null(releases, `[]`), '{{ ansible_distribution_release }}')" + filters_family: "families && contains(families, '{{ ansible_os_family }}')" package: - name: "{{ required_pkgs | union(common_required_pkgs) | flatten }}" + name: "{{ pkgs | dict2items | to_json|from_json | community.general.json_query(full_query) }}" state: present register: pkgs_task_result until: pkgs_task_result is succeeded retries: "{{ pkg_install_retries }}" delay: "{{ retry_stagger | random + 3 }}" - when: not (ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"] or is_fedora_coreos) tags: - bootstrap-os