2018-05-09 16:19:11 +02:00
|
|
|
---
|
2018-09-08 05:46:11 +02:00
|
|
|
- name: Include OS-specific variables.
|
|
|
|
include_vars: "{{ ansible_os_family }}.yml"
|
|
|
|
|
2018-05-09 16:19:11 +02:00
|
|
|
- include_tasks: setup-RedHat.yml
|
|
|
|
when: ansible_os_family == 'RedHat'
|
|
|
|
|
|
|
|
- include_tasks: setup-Debian.yml
|
|
|
|
when: ansible_os_family == 'Debian'
|
|
|
|
|
2018-05-24 21:22:19 +02:00
|
|
|
- name: Ensure dependencies are installed.
|
2018-05-09 16:19:11 +02:00
|
|
|
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 }}"
|
|
|
|
|
2020-05-20 19:57:47 +02:00
|
|
|
# per the install doc,
|
|
|
|
# https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/
|
|
|
|
- name: Set sysctl for IPv4 bridges
|
|
|
|
sysctl:
|
|
|
|
name: net.bridge.bridge-nf-call-iptables
|
|
|
|
value: 1
|
|
|
|
state: present
|
|
|
|
|
|
|
|
- name: Set sysctl for IPv6 bridges
|
|
|
|
sysctl:
|
|
|
|
name: net.bridge.bridge-nf-call-ip6tables
|
|
|
|
value: 1
|
|
|
|
state: present
|
|
|
|
|
2018-09-08 05:46:11 +02:00
|
|
|
- include_tasks: kubelet-setup.yml
|
2018-05-09 18:15:30 +02:00
|
|
|
|
2018-05-09 16:19:11 +02:00
|
|
|
- name: Ensure kubelet is started and enabled at boot.
|
|
|
|
service:
|
|
|
|
name: kubelet
|
|
|
|
state: started
|
2018-09-28 05:17:50 +02:00
|
|
|
enabled: true
|
2018-05-09 16:19:11 +02:00
|
|
|
|
2018-05-09 18:15:30 +02:00
|
|
|
- name: Check if Kubernetes has already been initialized.
|
|
|
|
stat:
|
|
|
|
path: /etc/kubernetes/admin.conf
|
|
|
|
register: kubernetes_init_stat
|
|
|
|
|
2018-05-15 05:27:26 +02:00
|
|
|
# Set up master.
|
|
|
|
- include_tasks: master-setup.yml
|
|
|
|
when: kubernetes_role == 'master'
|
2018-05-09 16:19:11 +02:00
|
|
|
|
2018-05-15 05:27:26 +02:00
|
|
|
# Set up nodes.
|
|
|
|
- name: Get the kubeadm join command from the Kubernetes master.
|
2018-09-28 05:17:50 +02:00
|
|
|
command: kubeadm token create --print-join-command
|
|
|
|
changed_when: false
|
2018-05-15 05:27:26 +02:00
|
|
|
when: kubernetes_role == 'master'
|
2018-09-07 06:36:16 +02:00
|
|
|
register: kubernetes_join_command_result
|
|
|
|
|
|
|
|
- name: Set the kubeadm join command globally.
|
|
|
|
set_fact:
|
2019-12-15 02:50:57 +01:00
|
|
|
kubernetes_join_command: >
|
|
|
|
{{ kubernetes_join_command_result.stdout }}
|
|
|
|
{{ kubernetes_join_command_extra_opts }}
|
2018-09-07 06:36:16 +02:00
|
|
|
when: kubernetes_join_command_result.stdout is defined
|
|
|
|
delegate_to: "{{ item }}"
|
2018-09-28 05:17:50 +02:00
|
|
|
delegate_facts: true
|
2018-09-07 06:36:16 +02:00
|
|
|
with_items: "{{ groups['all'] }}"
|
2018-05-09 21:51:36 +02:00
|
|
|
|
2018-05-15 05:27:26 +02:00
|
|
|
- include_tasks: node-setup.yml
|
|
|
|
when: kubernetes_role == 'node'
|