mirror of
https://github.com/kubernetes-sigs/kubespray.git
synced 2026-05-08 09:57:38 -02:30
Filter packages installation by OS and by group
Adds infrastructure to install OS packages depending not only on OS (family, versions, etc) but on groups. All the informations related to a particular package should reside in the `pkgs` dictionnary, which takes inspiration from the `downloads` dictionary structure.
This commit is contained in:
@@ -60,13 +60,27 @@
|
|||||||
- bootstrap-os
|
- bootstrap-os
|
||||||
|
|
||||||
- name: Install packages requirements
|
- 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:
|
package:
|
||||||
name: "{{ required_pkgs | union(common_required_pkgs) | flatten }}"
|
name: "{{ pkgs | dict2items | to_json|from_json | community.general.json_query(full_query) }}"
|
||||||
state: present
|
state: present
|
||||||
register: pkgs_task_result
|
register: pkgs_task_result
|
||||||
until: pkgs_task_result is succeeded
|
until: pkgs_task_result is succeeded
|
||||||
retries: "{{ pkg_install_retries }}"
|
retries: "{{ pkg_install_retries }}"
|
||||||
delay: "{{ retry_stagger | random + 3 }}"
|
delay: "{{ retry_stagger | random + 3 }}"
|
||||||
when: not (ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"] or is_fedora_coreos)
|
|
||||||
tags:
|
tags:
|
||||||
- bootstrap-os
|
- bootstrap-os
|
||||||
|
|||||||
Reference in New Issue
Block a user