mirror of
https://github.com/geerlingguy/ansible-role-kubernetes.git
synced 2024-12-21 19:06:56 +01:00
926a8c909e
Co-authored-by: ra-rau <mafe2.0@freenet.de>
60 lines
1.6 KiB
YAML
60 lines
1.6 KiB
YAML
---
|
|
- name: Include OS-specific variables.
|
|
include_vars: "{{ ansible_os_family }}.yml"
|
|
|
|
- include_tasks: setup-RedHat.yml
|
|
when: ansible_os_family == 'RedHat'
|
|
|
|
- include_tasks: setup-Debian.yml
|
|
when: ansible_os_family == 'Debian'
|
|
|
|
- name: Ensure dependencies are installed.
|
|
package: name=curl state=present
|
|
|
|
- name: Install Kubernetes packages.
|
|
package:
|
|
name: "{{ item.name | default(item) }}"
|
|
state: "{{ item.state | default('present') }}"
|
|
notify: restart kubelet
|
|
with_items: "{{ kubernetes_packages }}"
|
|
|
|
- include_tasks: sysctl-setup.yml
|
|
|
|
- include_tasks: kubelet-setup.yml # deprecated
|
|
when: kubernetes_kubelet_extra_args|length > 0
|
|
|
|
- name: Ensure kubelet is started and enabled at boot.
|
|
service:
|
|
name: kubelet
|
|
state: started
|
|
enabled: true
|
|
|
|
- name: Check if Kubernetes has already been initialized.
|
|
stat:
|
|
path: /etc/kubernetes/admin.conf
|
|
register: kubernetes_init_stat
|
|
|
|
# Set up control plane.
|
|
- include_tasks: control-plane-setup.yml
|
|
when: kubernetes_role == 'control_plane'
|
|
|
|
# Set up nodes.
|
|
- name: Get the kubeadm join command from the Kubernetes control plane.
|
|
command: kubeadm token create --print-join-command
|
|
changed_when: false
|
|
when: kubernetes_role == 'control_plane'
|
|
register: kubernetes_join_command_result
|
|
|
|
- name: Set the kubeadm join command globally.
|
|
set_fact:
|
|
kubernetes_join_command: >
|
|
{{ kubernetes_join_command_result.stdout }}
|
|
{{ kubernetes_join_command_extra_opts }}
|
|
when: kubernetes_join_command_result.stdout is defined
|
|
delegate_to: "{{ item }}"
|
|
delegate_facts: true
|
|
with_items: "{{ groups['all'] }}"
|
|
|
|
- include_tasks: node-setup.yml
|
|
when: kubernetes_role == 'node'
|