1
0
IaC/ansible/roles/k8s_control/tasks/main.yaml

47 lines
1.1 KiB
YAML
Raw Normal View History

2022-10-30 07:56:06 -04:00
---
2022-10-30 09:25:47 -04:00
- name: create containerd config dir
ansible.builtin.file:
path: /etc/containerd
state: directory
owner: root
group: root
mode: 0664
- name: create containerd default config
ansible.builtin.shell:
cmd: |
containerd config default > /etc/containerd/config.toml
creates: /etc/containerd/config.toml
- name: enable systemd cgroups in containerd config
ansible.builtin.lineinfile:
path: /etc/containerd/config.toml
regexp: '^(.*)SystemdCgroup = false$'
line: ' SystemdCgroup = true'
backrefs: true
2022-10-30 10:01:23 -04:00
state: present
- name: enable and start containerd service
ansible.builtin.service:
name: containerd
state: restarted
enabled: true
- name: kubeadm init
when: ansible_host == {{ k8s_control_master_node }}
ansible.builtin.shell:
cmd: |
kubeadm init \
--apiserver-advertise-address="" \
--apiserver-cert-extra-sans="" \
--node-name k8s-master \
--pod-network-cidr=192.168.0.0/16
creates: /etc/kubernetes/admin.conf
- name: join remaining nodes
when: ansible_host != {{ k8s_control_master_node }}
ansible.builtin.shell:
cmd: |
creates: