From 63fa406c3c5e2657f2deda4fb9414d8c27013337 Mon Sep 17 00:00:00 2001 From: Xiaodu Date: Thu, 26 Mar 2020 03:58:25 +0800 Subject: [PATCH] Move host_architecture to kubespray-defaults (#5811) The variable is defined in `kubernetes/preinstall` role and used in several roles. Since `kubernetes/preinstall` is not always included when `ansible-playbook` is run with tag selectors (see #5734 for reason), they will fail, or individual roles must copy the same fact definitions (as in #3846). Moving the definition to the always-included `kubespray-defaults` role will resolve the dependency problem. --- roles/etcd/tasks/main.yml | 15 --------------- .../preinstall/tasks/0040-set_facts.yml | 16 ---------------- roles/kubespray-defaults/defaults/main.yaml | 11 +++++++++++ 3 files changed, 11 insertions(+), 31 deletions(-) diff --git a/roles/etcd/tasks/main.yml b/roles/etcd/tasks/main.yml index 07f27138e..a3236794f 100644 --- a/roles/etcd/tasks/main.yml +++ b/roles/etcd/tasks/main.yml @@ -1,19 +1,4 @@ --- -- name: set architecture_groups - set_fact: - architecture_groups: - x86_64: amd64 - aarch64: arm64 - -- name: ansible_architecture_rename - set_fact: - host_architecture: >- - {%- if ansible_architecture in architecture_groups -%} - {{ architecture_groups[ansible_architecture] }} - {%- else -%} - {{ ansible_architecture }} - {% endif %} - - include_tasks: check_certs.yml when: cert_management == "script" tags: diff --git a/roles/kubernetes/preinstall/tasks/0040-set_facts.yml b/roles/kubernetes/preinstall/tasks/0040-set_facts.yml index e0f1995d4..982916247 100644 --- a/roles/kubernetes/preinstall/tasks/0040-set_facts.yml +++ b/roles/kubernetes/preinstall/tasks/0040-set_facts.yml @@ -1,20 +1,4 @@ --- -- name: set architecture_groups - set_fact: - architecture_groups: - x86_64: amd64 - aarch64: arm64 - armv7l: arm - -- name: ansible_architecture_rename - set_fact: - host_architecture: >- - {%- if ansible_architecture in architecture_groups -%} - {{ architecture_groups[ansible_architecture] }} - {%- else -%} - {{ ansible_architecture }} - {% endif %} - - name: Force binaries directory for Container Linux by CoreOS and Flatcar set_fact: bin_dir: "/opt/bin" diff --git a/roles/kubespray-defaults/defaults/main.yaml b/roles/kubespray-defaults/defaults/main.yaml index 15738165d..bcaa97d7a 100644 --- a/roles/kubespray-defaults/defaults/main.yaml +++ b/roles/kubespray-defaults/defaults/main.yaml @@ -539,3 +539,14 @@ etcd_config_dir: /etc/ssl/etcd etcd_cert_dir: "{{ etcd_config_dir }}/ssl" typha_enabled: false + +_host_architecture_groups: + x86_64: amd64 + aarch64: arm64 + armv7l: arm +host_architecture: >- + {%- if ansible_architecture in _host_architecture_groups -%} + {{ _host_architecture_groups[ansible_architecture] }} + {%- else -%} + {{ ansible_architecture }} + {%- endif -%}