Skip to content

Commit

Permalink
Refactor warning for the deprecated 'etcd_kubeadm_enabled' variable
Browse files Browse the repository at this point in the history
Signed-off-by: necatican <[email protected]>
  • Loading branch information
necatican committed Feb 8, 2022
1 parent bab8021 commit d9775a8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
20 changes: 20 additions & 0 deletions roles/kubernetes/preinstall/tasks/0020-verify-settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,26 @@
- inventory_hostname in groups.get('etcd',[])
- container_manager != 'docker'

# TODO: Clean this task up when we drop backward compatibility support for `etcd_kubeadm_enabled`
- name: Stop if etcd deployment type is not host or kubeadm when container_manager != docker and etcd_kubeadm_enabled is not defined
block:
- name: Warn the user if they are still using `etcd_kubeadm_enabled`
debug:
msg: >
"WARNING! => `etcd_kubeadm_enabled` is deprecated and will be removed in a future release.
You can set `etcd_deployment_type` to `kubeadm` instead of setting `etcd_kubeadm_enabled` to `true`."
changed_when: true

- name: Stop if `etcd_kubeadm_enabled` is defined and `etcd_deployment_type` is not `kubadm` or `host`
assert:
that: etcd_deployment_type == 'kubeadm'
msg: >
It is not possible to use `etcd_kubeadm_enabled` when `etcd_deployment_type` is set to {{ etcd_deployment_type }}.
Unset the `etcd_kubeadm_enabled` variable and set `etcd_deployment_type` to desired deployment type (`host`, `kubeadm`, `docker`) instead."
when: etcd_kubeadm_enabled
run_once: yes
when: etcd_kubeadm_enabled is defined

- name: Stop if download_localhost is enabled but download_run_once is not
assert:
that: download_run_once
Expand Down
15 changes: 4 additions & 11 deletions roles/kubespray-defaults/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,11 @@
tags:
- always

- name: Check if `etcd_kubeadm_enabled` is still in use
block:
- name: Warn the user if they are still using `etcd_kubeadm_enabled`
debug:
msg: "WARNING! => `etcd_kubeadm_enabled` is deprecated and will be removed in a future release. You can set `etcd_deployment_type` to `kubeadm`"
failed_when: true

- name: Set `etcd_deployment_type` to "kubeadm" if `etcd_kubeadm_enabled` is true
set_fact:
etcd_deployment_type: kubeadm
# TODO: Clean this task up when we drop backward compatibility support for `etcd_kubeadm_enabled`
- name: Set `etcd_deployment_type` to "kubeadm" if `etcd_kubeadm_enabled` is true
set_fact:
etcd_deployment_type: kubeadm
when:
- etcd_kubeadm_enabled is defined and etcd_kubeadm_enabled
ignore_errors: true
tags:
- always

0 comments on commit d9775a8

Please sign in to comment.