c12s-kubespray/roles/kubernetes/master/tasks/kubeadm-kubeconfig.yml

34 lines
1.1 KiB
YAML

---
- name: Backup old configuration files
copy:
src: "{{ kube_config_dir }}/{{ item.src }}"
dest: "{{ kube_config_dir }}/{{ item.dest }}"
remote_src: yes
with_items:
- {src: admin.conf, dest: admin.conf.old}
- {src: kubelet.conf, dest: kubelet.conf.old}
- {src: controller-manager.conf, dest: controller-manager.conf.old}
- {src: scheduler.conf, dest: scheduler.conf.old}
ignore_errors: yes
- name: Remove old configuration files
file:
path: "{{ kube_config_dir }}/{{ item }}"
state: absent
with_items:
- admin.conf
- kubelet.conf
- controller-manager.conf
- scheduler.conf
- name: Generate new configuration files
command: "{{ bin_dir }}/kubeadm init phase kubeconfig all --config={{ kube_config_dir }}/kubeadm-config.yaml"
environment: "{{ proxy_env }}"
when: kubeadm_version is version('v1.13.0', '>=')
ignore_errors: yes
- name: Generate new configuration files
command: "{{ bin_dir }}/kubeadm alpha phase kubeconfig all --config={{ kube_config_dir }}/kubeadm-config.yaml"
environment: "{{ proxy_env }}"
when: kubeadm_version is version('v1.13.0', '<')
ignore_errors: yes