Update roles/kubernetes/tasks/main.yml

This commit is contained in:
2025-10-20 12:51:32 +00:00
parent 16a6fae38e
commit 5401347945

View File

@ -1,47 +1,64 @@
- name: Install containerd
apt:
name: containerd
- name: disable UFW firewall for labs
service:
name: ufw
state: stopped
enabled: false
- name: Disable SWAP
shell: |
swapoff -a
- name: Disable SWAP in fstab
lineinfile:
path: /etc/fstab
regexp: '^.*swap.*$'
line: '#\0'
backrefs: yes
- name: ensure net.bridge.bridge-nf-call-ip6tables is set to 1
sysctl:
name: net.bridge.bridge-nf-call-iptables
value: '1'
state: present
update_cache: no
become: true
reload: yes
- name: Hold Kubernetes packages
become: true
ansible.builtin.shell: |
apt-mark hold containerd
- name: Installation of apt-utils
apt:
name: apt-transport-https
state: present
update_cache: yes
- name: Adding Docker GPG key
ansible.builtin.apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
- name: Adding Docker Repository
apt_repository:
repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable
state: present
- name: Criar diretório .kube para o usuário ubuntu
become: true
ansible.builtin.file:
path: /run/flannel
state: directory
owner: root
group: root
mode: 0755
- name: Installation of Docker
apt:
name: "{{ item }}"
state: present
loop:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-compose
- name: Criar ou sobrescrever /run/flannel/subnet.env
become: true
copy:
dest: /run/flannel/subnet.env
content: |
FLANNEL_NETWORK=192.168.2.0/16
FLANNEL_SUBNET=192.168.2.1/24
FLANNEL_MTU=1450
FLANNEL_IPMASQ=true
owner: root
group: root
mode: '0644'
#- name: Add Kubernetes APT key
# apt_key:
# url: https://packages.cloud.google.com/apt/doc/apt-key.gpg
# state: present
- name: Setting value of SystemdCgroup
shell: |
containerd config default | sudo tee /etc/containerd/config.toml | grep SystemdCgroup
sed -i 's/SystemdCgroup = false/SystemdCgroup = true/g' /etc/containerd/config.toml
- name : Starting Service of Docker
service:
name: docker
state: started
enabled: yes
#- name: Add Kubernetes repo
# apt_repository:
# repo: deb http://apt.kubernetes.io/ kubernetes-jammy main
# state: present
- name: Adicionar chave GPG do Kubernetes
become: true