update apt sources, add apt keyring gpg

This commit is contained in:
Marc Bihlmaier 2023-11-07 04:00:59 +01:00
parent 25e782117c
commit 1eb8be8309
2 changed files with 23 additions and 11 deletions

View File

@ -51,10 +51,12 @@ kubernetes_apiserver_advertise_address: ''
kubernetes_version_kubeadm: 'stable-{{ kubernetes_version }}' kubernetes_version_kubeadm: 'stable-{{ kubernetes_version }}'
kubernetes_ignore_preflight_errors: 'all' kubernetes_ignore_preflight_errors: 'all'
kubernetes_apt_release_channel: main kubernetes_apt_release_channel: "stable"
# Note that xenial repo is used for all Debian derivatives at this time. kubernetes_apt_keyring_file: "/etc/apt/keyrings/kubernetes-apt-keyring.gpg"
kubernetes_apt_repository: "deb http://apt.kubernetes.io/ kubernetes-xenial {{ kubernetes_apt_release_channel }}" kubernetes_apt_repository_pkgs_k8s_io: "deb [signed-by={{ kubernetes_apt_keyring_file }}] https://pkgs.k8s.io/core:/{{ kubernetes_apt_release_channel }}:/v{{ kubernetes_version }}/deb/ /"
kubernetes_apt_ignore_key_error: false kubernetes_apt_ignore_key_error: false
# this one is deprecated and will be deleted with this role
kubernetes_apt_repository: "deb http://apt.kubernetes.io/ kubernetes-xenial {{ kubernetes_apt_release_channel }}"
kubernetes_yum_arch: '$basearch' kubernetes_yum_arch: '$basearch'
kubernetes_yum_base_url: "https://packages.cloud.google.com/yum/repos/kubernetes-el7-{{ kubernetes_yum_arch }}" kubernetes_yum_base_url: "https://packages.cloud.google.com/yum/repos/kubernetes-el7-{{ kubernetes_yum_arch }}"

View File

@ -6,16 +6,26 @@
- ca-certificates - ca-certificates
state: present state: present
- name: Add Kubernetes apt key. - name: Prepare apt keyring directory.
apt_key: ansible.builtin.file:
url: https://packages.cloud.google.com/apt/doc/apt-key.gpg path: "{{ kubernetes_apt_keyring_file | dirname }}"
state: present state: directory
register: add_repository_key mode: 0755
ignore_errors: "{{ kubernetes_apt_ignore_key_error }}"
- name: Get Kubernetes apt key.
shell: "curl -fsSL https://pkgs.k8s.io/core:/{{ kubernetes_apt_release_channel }}:/v{{ kubernetes_version }}/deb/Release.key | gpg --dearmor -o {{ kubernetes_apt_keyring_file }}"
args:
creates: "{{ kubernetes_apt_keyring_file }}"
- name: Be sure deprecated Kubernetes repository is absent.
file:
path: "/etc/apt/sources.list.d/apt_kubernetes_io.list"
state: absent
- name: Add Kubernetes repository. - name: Add Kubernetes repository.
apt_repository: ansible.builtin.apt_repository:
repo: "{{ kubernetes_apt_repository }}" repo: "{{ kubernetes_apt_repository_pkgs_k8s_io }}"
filename: pkgs_k8s_io
state: present state: present
update_cache: true update_cache: true