Added deleting kerings and repositories list before installing, changed became rules for some tasks

pull/1/head
yuobrezkov 2025-01-27 12:44:38 +03:00
parent 53620f6e95
commit dd7ff6713a
3 changed files with 22 additions and 4 deletions

View File

@ -7,7 +7,6 @@
- name: Initialize master node
hosts: master
become: yes
roles:
- role: kubernetes-master
tags: master

View File

@ -7,6 +7,25 @@
update_cache: yes
upgrade: dist
autoremove: yes
- name: Remove existing Kubernetes repository if it exists
file:
path: /etc/apt/sources.list.d/kubernetes.list
state: absent
- name: Remove existing Kubernetes GPG key if it exists
file:
path: /etc/apt/keyrings/kubernetes-apt-keyring.gpg
state: absent
- name: Remove existing CRI-O repository if it exists
file:
path: /etc/apt/sources.list.d/cri-o.list
state: absent
- name: Remove existing CRI-O GPG key if it exists
file:
path: /etc/apt/keyrings/cri-o-apt-keyring.gpg
state: absent
- name: Disable swap
shell: |
swapoff -a
@ -73,7 +92,7 @@
curl -fsSL https://pkgs.k8s.io/addons:/cri-o:/stable:/{{crio_version}}/deb/Release.key | gpg --dearmor -o /etc/apt/keyrings/cri-o-apt-keyring.gpg
- name: Add cri-o repository
shell: |
echo "deb [signed-by=/etc/apt/keyrings/cri-o-apt-keyring.gpg] https://pkgs.k8s.io/addons:/cri-o:/stable:/$CRIO_VERSION/deb/ /" | tee /etc/apt/sources.list.d/cri-o.list
echo "deb [signed-by=/etc/apt/keyrings/cri-o-apt-keyring.gpg] https://pkgs.k8s.io/addons:/cri-o:/stable:/{{crio_version}}/deb/ /" | tee /etc/apt/sources.list.d/cri-o.list
- name: Installing cri-o
apt:
update_cache: yes

View File

@ -12,10 +12,10 @@
- name: Ensure .kube directory exists on the target machine
command: mkdir -p {{ ansible_user_dir }}/.kube
- name: Copy kubeconfig from master node to target machine
- name: Copy kubeconfig to home directory
become: yes
command: >
cp /etc/kubernetes/admin.conf {{ ansible_user_dir }}/.kube/config
cp -f /etc/kubernetes/admin.conf {{ ansible_user_dir }}/.kube/config
- name: Set correct ownership for kubeconfig
become: yes