Install specific K8s version

This commit is contained in:
Emil Dabrowski 2023-01-11 21:04:00 +01:00
parent ddc2730fc3
commit 5db5bbbb4d
2 changed files with 16 additions and 4 deletions

View File

@ -9,8 +9,9 @@
- curl - curl
ansible.builtin.apt: ansible.builtin.apt:
name: "{{ packages }}" name: "{{ packages }}"
state: present state: latest
update_cache: yes update_cache: yes
cache_valid_time: 3600
- name: Setup Kubernetes repository - name: Setup Kubernetes repository
become: true become: true
@ -25,19 +26,29 @@
repo: deb [signed-by=/etc/apt/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main repo: deb [signed-by=/etc/apt/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main
state: present state: present
- name: Update apt cache
ansible.builtin.apt:
update_cache: yes
- name: Get Kubernetes package version
ansible.builtin.shell: "apt-cache show kubeadm | grep -F 'Version: {{ k8s_version }}.' | cut -d' ' -f2 | sort -n | tail -n 1"
register: k8s_pkg_ver
- name: Setup Kubernetes packages - name: Setup Kubernetes packages
become: true become: true
vars: vars:
packages: packages:
- kubelet - kubelet={{ k8s_pkg_ver.stdout }}
- kubeadm - kubeadm={{ k8s_pkg_ver.stdout }}
- kubectl - kubectl={{ k8s_pkg_ver.stdout }}
block: block:
- name: Install kubelet, kubeadm and kubectl - name: Install kubelet, kubeadm and kubectl
ansible.builtin.apt: ansible.builtin.apt:
name: "{{ packages }}" name: "{{ packages }}"
state: present state: present
update_cache: yes update_cache: yes
allow_downgrade: no
cache_valid_time: 3600
- name: Hold Kubernetes packages - name: Hold Kubernetes packages
loop: "{{ packages }}" loop: "{{ packages }}"

View File

@ -53,6 +53,7 @@
name: "{{ packages }}" name: "{{ packages }}"
state: present state: present
update_cache: yes update_cache: yes
cache_valid_time: 3600
- name: Install Kubernetes module dependencies - name: Install Kubernetes module dependencies
ansible.builtin.pip: ansible.builtin.pip: