From a01e96e21a8e62e10c9108af471620d3742367e4 Mon Sep 17 00:00:00 2001 From: vdveldet Date: Thu, 28 Aug 2025 09:11:10 +0200 Subject: [PATCH] Introduced internal_facts.yml and adapt playbooks to use this (#12492) --- playbooks/cluster.yml | 2 +- playbooks/facts.yml | 39 +++-------------------------------- playbooks/internal_facts.yml | 39 +++++++++++++++++++++++++++++++++++ playbooks/remove_node.yml | 2 +- playbooks/reset.yml | 2 +- playbooks/scale.yml | 2 +- playbooks/upgrade_cluster.yml | 2 +- 7 files changed, 47 insertions(+), 41 deletions(-) create mode 100644 playbooks/internal_facts.yml diff --git a/playbooks/cluster.yml b/playbooks/cluster.yml index 1c69cfa2c..12aeeee02 100644 --- a/playbooks/cluster.yml +++ b/playbooks/cluster.yml @@ -3,7 +3,7 @@ import_playbook: boilerplate.yml - name: Gather facts - import_playbook: facts.yml + import_playbook: internal_facts.yml - name: Prepare for etcd install hosts: k8s_cluster:etcd diff --git a/playbooks/facts.yml b/playbooks/facts.yml index 9938c1900..4140e7fc9 100644 --- a/playbooks/facts.yml +++ b/playbooks/facts.yml @@ -1,39 +1,6 @@ --- -- name: Bootstrap hosts for Ansible - hosts: k8s_cluster:etcd:calico_rr - strategy: linear - any_errors_fatal: "{{ any_errors_fatal | default(true) }}" - gather_facts: false - environment: "{{ proxy_disable_env }}" - roles: - - { role: bootstrap_os, tags: bootstrap_os} +- name: Common tasks for every playbooks + import_playbook: boilerplate.yml - name: Gather facts - hosts: k8s_cluster:etcd:calico_rr - gather_facts: false - tags: always - tasks: - - name: Gather and compute network facts - import_role: - name: network_facts - - name: Gather minimal facts - setup: - gather_subset: '!all' - - # filter match the following variables: - # ansible_default_ipv4 - # ansible_default_ipv6 - # ansible_all_ipv4_addresses - # ansible_all_ipv6_addresses - - name: Gather necessary facts (network) - setup: - gather_subset: '!all,!min,network' - filter: "ansible_*_ipv[46]*" - - # filter match the following variables: - # ansible_memtotal_mb - # ansible_swaptotal_mb - - name: Gather necessary facts (hardware) - setup: - gather_subset: '!all,!min,hardware' - filter: "ansible_*total_mb" + import_playbook: internal_facts.yml diff --git a/playbooks/internal_facts.yml b/playbooks/internal_facts.yml new file mode 100644 index 000000000..9938c1900 --- /dev/null +++ b/playbooks/internal_facts.yml @@ -0,0 +1,39 @@ +--- +- name: Bootstrap hosts for Ansible + hosts: k8s_cluster:etcd:calico_rr + strategy: linear + any_errors_fatal: "{{ any_errors_fatal | default(true) }}" + gather_facts: false + environment: "{{ proxy_disable_env }}" + roles: + - { role: bootstrap_os, tags: bootstrap_os} + +- name: Gather facts + hosts: k8s_cluster:etcd:calico_rr + gather_facts: false + tags: always + tasks: + - name: Gather and compute network facts + import_role: + name: network_facts + - name: Gather minimal facts + setup: + gather_subset: '!all' + + # filter match the following variables: + # ansible_default_ipv4 + # ansible_default_ipv6 + # ansible_all_ipv4_addresses + # ansible_all_ipv6_addresses + - name: Gather necessary facts (network) + setup: + gather_subset: '!all,!min,network' + filter: "ansible_*_ipv[46]*" + + # filter match the following variables: + # ansible_memtotal_mb + # ansible_swaptotal_mb + - name: Gather necessary facts (hardware) + setup: + gather_subset: '!all,!min,hardware' + filter: "ansible_*total_mb" diff --git a/playbooks/remove_node.yml b/playbooks/remove_node.yml index f6362fd07..e8fceb790 100644 --- a/playbooks/remove_node.yml +++ b/playbooks/remove_node.yml @@ -32,7 +32,7 @@ when: pause_result.user_input | default('yes') != 'yes' - name: Gather facts - import_playbook: facts.yml + import_playbook: internal_facts.yml when: reset_nodes | default(True) | bool - name: Reset node diff --git a/playbooks/reset.yml b/playbooks/reset.yml index 3a1f7fd4f..4e0ecb362 100644 --- a/playbooks/reset.yml +++ b/playbooks/reset.yml @@ -3,7 +3,7 @@ import_playbook: boilerplate.yml - name: Gather facts - import_playbook: facts.yml + import_playbook: internal_facts.yml - name: Reset cluster hosts: etcd:k8s_cluster:calico_rr diff --git a/playbooks/scale.yml b/playbooks/scale.yml index 1d0e2424f..8e4989deb 100644 --- a/playbooks/scale.yml +++ b/playbooks/scale.yml @@ -3,7 +3,7 @@ import_playbook: boilerplate.yml - name: Gather facts - import_playbook: facts.yml + import_playbook: internal_facts.yml - name: Install etcd vars: diff --git a/playbooks/upgrade_cluster.yml b/playbooks/upgrade_cluster.yml index 3c6325794..3ce065b46 100644 --- a/playbooks/upgrade_cluster.yml +++ b/playbooks/upgrade_cluster.yml @@ -3,7 +3,7 @@ import_playbook: boilerplate.yml - name: Gather facts - import_playbook: facts.yml + import_playbook: internal_facts.yml - name: Download images to ansible host cache via first kube_control_plane node hosts: kube_control_plane[0]