geerlingguy.ansible-role-ku.../tasks/main.yml

65 lines
1.7 KiB
YAML
Raw Normal View History

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 }}"
- name: Configure KUBELET_EXTRA_ARGS.
lineinfile:
path: '{{ kubernetes_kubelet_extra_args_config_file }}'
line: 'KUBELET_EXTRA_ARGS={{ kubernetes_kubelet_extra_args }}'
regexp: 'KUBELET_EXTRA_ARGS='
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
2018-05-09 16:19:11 +02:00
- 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'
2018-05-09 16:19:11 +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
when: kubernetes_role == 'master'
register: kubernetes_join_command_result
- name: Set the kubeadm join command globally.
set_fact:
kubernetes_join_command: "{{ kubernetes_join_command_result.stdout }}"
when: kubernetes_join_command_result.stdout is defined
delegate_to: "{{ item }}"
delegate_facts: True
with_items: "{{ groups['all'] }}"
2018-05-09 21:51:36 +02:00
- include_tasks: node-setup.yml
when: kubernetes_role == 'node'