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 }}"
|
|
|
|
|
2018-05-10 00:04:46 +02:00
|
|
|
- name: Configure KUBELET_EXTRA_ARGS.
|
2018-05-09 18:15:30 +02:00
|
|
|
lineinfile:
|
|
|
|
path: /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
|
2018-05-10 00:04:46 +02:00
|
|
|
line: 'Environment="KUBELET_EXTRA_ARGS={{ kubernetes_kubelet_extra_args }}"'
|
|
|
|
regexp: 'Environment="KUBELET_EXTRA_ARGS='
|
2018-05-09 18:15:30 +02:00
|
|
|
insertafter: '^Environment='
|
|
|
|
state: present
|
2018-05-10 00:04:46 +02:00
|
|
|
notify: restart kubelet
|
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
|
|
|
|
enabled: yes
|
|
|
|
|
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-06-08 06:42:45 +02:00
|
|
|
- name: configure docker cgroup driver
|
|
|
|
shell: sed -i "s/cgroup-driver=systemd/cgroup-driver=cgroupfs/g" /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
|
|
|
|
|
|
|
|
- name: restart docker services
|
|
|
|
shell: systemctl daemon-reload && service kubelet restart
|
|
|
|
|
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.
|
|
|
|
shell: kubeadm token create --print-join-command
|
2018-05-09 21:51:36 +02:00
|
|
|
changed_when: False
|
2018-06-08 06:42:45 +02:00
|
|
|
run_once: true
|
|
|
|
delegate_to: "{{ groups['master'][0] }}"
|
2018-05-15 05:27:26 +02:00
|
|
|
register: kubernetes_join_command
|
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'
|