c12s-kubespray/roles/network_plugin/calico/tasks/pre.yml
Hans Feldt 6141b98bf8
calico: default to using kdd datastore (#6693)
If already deployed, get current datastore from CNI config file
2020-09-23 08:38:09 -07:00

28 lines
962 B
YAML

---
- name: Slurp CNI config
slurp:
src: /etc/cni/net.d/10-calico.conflist
register: calico_cni_config_slurp
failed_when: false
- block:
- name: Set fact calico_cni_config from slurped CNI config
set_fact:
calico_cni_config: "{{ calico_cni_config_slurp['content'] | b64decode | from_json }}"
- name: Set fact calico_datastore to etcd if needed
set_fact:
calico_datastore: etcd
when: "'etcd_endpoints' in calico_cni_config.plugins.0"
when: calico_cni_config_slurp.content is defined
- name: Calico | Get kubelet hostname
shell: >-
set -o pipefail && {{ bin_dir }}/kubectl get node -o custom-columns='NAME:.metadata.name,INTERNAL-IP:.status.addresses[?(@.type=="InternalIP")].address'
| egrep "{{ ansible_all_ipv4_addresses | join('$|') }}$" | cut -d" " -f1
args:
executable: /bin/bash
register: calico_kubelet_name
delegate_to: "{{ groups['kube-master'][0] }}"
when:
- "cloud_provider is defined"