diff --git a/roles/kubespray_defaults/defaults/main/download.yml b/roles/kubespray_defaults/defaults/main/download.yml index 8284db1ba..91c12c5fb 100644 --- a/roles/kubespray_defaults/defaults/main/download.yml +++ b/roles/kubespray_defaults/defaults/main/download.yml @@ -1,5 +1,4 @@ --- -local_release_dir: /tmp/releases download_cache_dir: /tmp/kubespray_cache # If this is true, debug information will be displayed but diff --git a/roles/kubespray_defaults/defaults/main/main.yml b/roles/kubespray_defaults/defaults/main/main.yml index eb9171119..7217d96ab 100644 --- a/roles/kubespray_defaults/defaults/main/main.yml +++ b/roles/kubespray_defaults/defaults/main/main.yml @@ -114,7 +114,7 @@ containerd_bin_dir: "{{ bin_dir }}" etcd_data_dir: /var/lib/etcd # Where the binaries will be downloaded. # Note: ensure that you've enough disk space (about 1G) -local_release_dir: "/tmp/releases" +local_release_dir: "{{ default_local_release_dir }}" # Random shifts for retrying failed ops like pushing/downloading retry_stagger: 5 diff --git a/roles/kubespray_defaults/vars/main/download.yml b/roles/kubespray_defaults/vars/main/download.yml new file mode 100644 index 000000000..1484d39a5 --- /dev/null +++ b/roles/kubespray_defaults/vars/main/download.yml @@ -0,0 +1,23 @@ +--- +## Variables used by roles/download and task installing artefacts on node + +# Where ansible should look for artefacts when installing binaries / pre-loading container image +# This is subtly different from local_release_dir, because it takes into +# account `download_delegate`, and in particular the scenario where: +# - hostvars['some_host']['download_delegate'] == 'other_host' or 'localhost' -> both scenario will result in the artefact transiting by localhost +# - hostvars['localhost']['local_release_dir'] != hostvars['some_host']['local_release_dir'] +# We explicitly check hostvars +install_source_dir: "{{ + hostvars[ + inventory_hostname if download_delegate == inventory_hostname + else 'localhost' + ]['local_release_dir'] | default(default_local_release_dir) +}}" + +# This always refers to the value of `local_release_dir` for localhost +# used by tasks which need to refer to paths on the controller, for instance, using lookup('file') +install_source_localhost: "{{ hostvars['localhost']['local_release_dir'] | default(default_local_release_dir) }}" + +# This variable is the default for local_release_dir and is used to refer to +# the default even when `local_release_dir` is overridden by inventory +default_local_release_dir: /tmp/releases