mirror of
https://github.com/geerlingguy/ansible-role-kubernetes.git
synced 2024-11-23 19:06:33 +01:00
59 lines
1.5 KiB
YAML
59 lines
1.5 KiB
YAML
---
|
|
- 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 }}"
|
|
|
|
- name: Configure KUBELET_EXTRA_ARGS.
|
|
lineinfile:
|
|
path: /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
|
|
line: 'Environment="KUBELET_EXTRA_ARGS={{ kubernetes_kubelet_extra_args }}"'
|
|
regexp: 'Environment="KUBELET_EXTRA_ARGS='
|
|
insertafter: '^Environment='
|
|
state: present
|
|
register: kubelet_unit_file
|
|
|
|
- name: Reload systemd unit if args were changed.
|
|
systemd:
|
|
state: restarted
|
|
daemon_reload: yes
|
|
name: kubelet
|
|
when: kubelet_unit_file is changed
|
|
|
|
- name: Ensure kubelet is started and enabled at boot.
|
|
service:
|
|
name: kubelet
|
|
state: started
|
|
enabled: yes
|
|
|
|
- name: Check if Kubernetes has already been initialized.
|
|
stat:
|
|
path: /etc/kubernetes/admin.conf
|
|
register: kubernetes_init_stat
|
|
|
|
# Set up master.
|
|
- include_tasks: master-setup.yml
|
|
when: kubernetes_role == 'master'
|
|
|
|
# Set up nodes.
|
|
- name: Get the kubeadm join command from the Kubernetes master.
|
|
shell: kubeadm token create --print-join-command
|
|
changed_when: False
|
|
when: kubernetes_role == 'master'
|
|
run_once: True
|
|
register: kubernetes_join_command
|
|
|
|
- include_tasks: node-setup.yml
|
|
when: kubernetes_role == 'node'
|