From a8ed657fb3412ed5074e5b4fc472bc5363a09527 Mon Sep 17 00:00:00 2001 From: Nathan Douglas Date: Fri, 1 Mar 2024 10:57:05 -0500 Subject: [PATCH 1/9] deb822_repository format --- defaults/main.yml | 6 +++--- tasks/setup-Debian.yml | 29 ++++++----------------------- 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index e850ed0..53c2fd3 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -51,9 +51,9 @@ kubernetes_apiserver_advertise_address: '' kubernetes_version_kubeadm: 'stable-{{ kubernetes_version }}' kubernetes_ignore_preflight_errors: 'all' -kubernetes_apt_release_channel: "stable" -kubernetes_apt_keyring_file: "/etc/apt/keyrings/kubernetes-apt-keyring.asc" -kubernetes_apt_repository: "deb [signed-by={{ kubernetes_apt_keyring_file }}] https://pkgs.k8s.io/core:/{{ kubernetes_apt_release_channel }}:/v{{ kubernetes_version }}/deb/ /" +kubernetes_apt_release_channel: main +kubernetes_apt_repository: "https://pkgs.k8s.io/core:/stable:/v{{ kubernetes_version }}/deb/" +kubernetes_apt_ignore_key_error: false kubernetes_yum_base_url: "https://pkgs.k8s.io/core:/stable:/v{{ kubernetes_version }}/rpm/" kubernetes_yum_gpg_key: "https://pkgs.k8s.io/core:/stable:/v{{ kubernetes_version }}/rpm/repodata/repomd.xml.key" diff --git a/tasks/setup-Debian.yml b/tasks/setup-Debian.yml index 7c77ae5..3b55e7c 100644 --- a/tasks/setup-Debian.yml +++ b/tasks/setup-Debian.yml @@ -6,30 +6,13 @@ - ca-certificates state: present -- name: Prepare apt keyring directory. - ansible.builtin.file: - path: "{{ kubernetes_apt_keyring_file | dirname }}" - state: directory - mode: 0755 - -- name: Get Kubernetes apt key. - ansible.builtin.get_url: - url: "https://pkgs.k8s.io/core:/{{ kubernetes_apt_release_channel }}:/v{{ kubernetes_version }}/deb/Release.key" - dest: "{{ kubernetes_apt_keyring_file }}" - mode: '0644' - force: true - -- 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. - ansible.builtin.apt_repository: - repo: "{{ kubernetes_apt_repository }}" - filename: pkgs_k8s_io - state: present - update_cache: true + deb822_repository: + name: kubernetes + types: deb + uris: "{{ kubernetes_apt_repository }}" + suites: / + signed_by: "{{ kubernetes_apt_repository }}/Release.key" - name: Add Kubernetes apt preferences file to pin a version. template: From 054af0d9777ae73ad236395e5edbb3463bcab12d Mon Sep 17 00:00:00 2001 From: Nathan Douglas Date: Wed, 6 Mar 2024 06:10:51 -0500 Subject: [PATCH 2/9] Add `debian` package to be able to use deb822_repository. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e25bd67..99ff948 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,7 +63,7 @@ jobs: python-version: '3.x' - name: Install test dependencies. - run: pip3 install ansible molecule molecule-plugins[docker] docker + run: pip3 install ansible molecule molecule-plugins[docker] docker debian - name: Run Molecule tests. run: molecule test From 038cda429a4a75445b083068444e8d212c2321b4 Mon Sep 17 00:00:00 2001 From: Nathan Douglas Date: Wed, 6 Mar 2024 06:13:56 -0500 Subject: [PATCH 3/9] Revert "Add `debian` package to be able to use deb822_repository." This reverts commit 054af0d9777ae73ad236395e5edbb3463bcab12d. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 99ff948..e25bd67 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,7 +63,7 @@ jobs: python-version: '3.x' - name: Install test dependencies. - run: pip3 install ansible molecule molecule-plugins[docker] docker debian + run: pip3 install ansible molecule molecule-plugins[docker] docker - name: Run Molecule tests. run: molecule test From baadacdb3c4f8fa499fcedff720c1de960faf7ee Mon Sep 17 00:00:00 2001 From: Nathan Douglas Date: Wed, 6 Mar 2024 06:15:42 -0500 Subject: [PATCH 4/9] Add `python3-debian` to list of dependencies. --- tasks/setup-Debian.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/tasks/setup-Debian.yml b/tasks/setup-Debian.yml index 3b55e7c..c74bc2e 100644 --- a/tasks/setup-Debian.yml +++ b/tasks/setup-Debian.yml @@ -4,6 +4,7 @@ name: - apt-transport-https - ca-certificates + - python3-debian state: present - name: Add Kubernetes repository. From 904f5be944ca22619a616a5132879e3a3ca79d89 Mon Sep 17 00:00:00 2001 From: Nathan Douglas Date: Wed, 6 Mar 2024 06:25:22 -0500 Subject: [PATCH 5/9] Update apt cache when Kubernetes repo is added. --- tasks/setup-Debian.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tasks/setup-Debian.yml b/tasks/setup-Debian.yml index c74bc2e..c2aa395 100644 --- a/tasks/setup-Debian.yml +++ b/tasks/setup-Debian.yml @@ -14,6 +14,12 @@ uris: "{{ kubernetes_apt_repository }}" suites: / signed_by: "{{ kubernetes_apt_repository }}/Release.key" + register: kubernetes_repository + +- name: 'Update Apt cache.' + ansible.builtin.apt: + update_cache: true + when: kubernetes_repository.changed - name: Add Kubernetes apt preferences file to pin a version. template: From e35045cc6c2f126698b053d2b38d49b6bb6e2e2a Mon Sep 17 00:00:00 2001 From: Nathan Douglas Date: Wed, 6 Mar 2024 06:40:49 -0500 Subject: [PATCH 6/9] FML --- tasks/setup-Debian.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/setup-Debian.yml b/tasks/setup-Debian.yml index c2aa395..d8ca5d9 100644 --- a/tasks/setup-Debian.yml +++ b/tasks/setup-Debian.yml @@ -19,7 +19,7 @@ - name: 'Update Apt cache.' ansible.builtin.apt: update_cache: true - when: kubernetes_repository.changed + when: kubernetes_repository.changed - name: Add Kubernetes apt preferences file to pin a version. template: From d4517950a4e64338443745f28bc3195915af8c5b Mon Sep 17 00:00:00 2001 From: Nathan Douglas Date: Wed, 6 Mar 2024 06:41:19 -0500 Subject: [PATCH 7/9] Code style. --- tasks/setup-Debian.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/setup-Debian.yml b/tasks/setup-Debian.yml index d8ca5d9..5812ee9 100644 --- a/tasks/setup-Debian.yml +++ b/tasks/setup-Debian.yml @@ -16,8 +16,8 @@ signed_by: "{{ kubernetes_apt_repository }}/Release.key" register: kubernetes_repository -- name: 'Update Apt cache.' - ansible.builtin.apt: +- name: Update Apt cache. + apt: update_cache: true when: kubernetes_repository.changed From 8bfb1d772f306a17cf23a723deb572f033cf9ef2 Mon Sep 17 00:00:00 2001 From: Nathan Douglas Date: Wed, 6 Mar 2024 13:57:07 -0500 Subject: [PATCH 8/9] Removed some unnecessary stuff. --- README.md | 6 ++---- defaults/main.yml | 2 -- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 578a237..274b471 100644 --- a/README.md +++ b/README.md @@ -140,12 +140,10 @@ kubernetes_ignore_preflight_errors: 'all' Options passed to `kubeadm init` when initializing the Kubernetes control plane. The `kubernetes_apiserver_advertise_address` defaults to `ansible_default_ipv4.address` if it's left empty. ```yaml -kubernetes_apt_release_channel: "stable" -kubernetes_apt_keyring_file: "/etc/apt/keyrings/kubernetes-apt-keyring.asc" -kubernetes_apt_repository: "deb [signed-by={{ kubernetes_apt_keyring_file }}] https://pkgs.k8s.io/core:/{{ kubernetes_apt_release_channel }}:/v{{ kubernetes_version }}/deb/ /" +kubernetes_apt_repository: "https://pkgs.k8s.io/core:/stable:/v{{ kubernetes_version }}/deb/" ``` -Apt repository options for Kubernetes installation. +Apt repository option for Kubernetes installation. ```yaml kubernetes_yum_base_url: "https://pkgs.k8s.io/core:/stable:/v{{ kubernetes_version }}/rpm/" diff --git a/defaults/main.yml b/defaults/main.yml index 53c2fd3..6089771 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -51,9 +51,7 @@ kubernetes_apiserver_advertise_address: '' kubernetes_version_kubeadm: 'stable-{{ kubernetes_version }}' kubernetes_ignore_preflight_errors: 'all' -kubernetes_apt_release_channel: main kubernetes_apt_repository: "https://pkgs.k8s.io/core:/stable:/v{{ kubernetes_version }}/deb/" -kubernetes_apt_ignore_key_error: false kubernetes_yum_base_url: "https://pkgs.k8s.io/core:/stable:/v{{ kubernetes_version }}/rpm/" kubernetes_yum_gpg_key: "https://pkgs.k8s.io/core:/stable:/v{{ kubernetes_version }}/rpm/repodata/repomd.xml.key" From 32292cfd890ce75fbe773bf2d8414905bb86b2ca Mon Sep 17 00:00:00 2001 From: Nathan Douglas Date: Wed, 6 Mar 2024 15:24:35 -0500 Subject: [PATCH 9/9] Just kidding, adding back in the release channel option. --- README.md | 5 +++-- defaults/main.yml | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 274b471..2077324 100644 --- a/README.md +++ b/README.md @@ -140,10 +140,11 @@ kubernetes_ignore_preflight_errors: 'all' Options passed to `kubeadm init` when initializing the Kubernetes control plane. The `kubernetes_apiserver_advertise_address` defaults to `ansible_default_ipv4.address` if it's left empty. ```yaml -kubernetes_apt_repository: "https://pkgs.k8s.io/core:/stable:/v{{ kubernetes_version }}/deb/" +kubernetes_apt_release_channel: "stable" +kubernetes_apt_repository: "https://pkgs.k8s.io/core:/{{ kubernetes_apt_release_channel }}:/v{{ kubernetes_version }}/deb/" ``` -Apt repository option for Kubernetes installation. +Apt repository options for Kubernetes installation. ```yaml kubernetes_yum_base_url: "https://pkgs.k8s.io/core:/stable:/v{{ kubernetes_version }}/rpm/" diff --git a/defaults/main.yml b/defaults/main.yml index 6089771..f74583f 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -51,7 +51,8 @@ kubernetes_apiserver_advertise_address: '' kubernetes_version_kubeadm: 'stable-{{ kubernetes_version }}' kubernetes_ignore_preflight_errors: 'all' -kubernetes_apt_repository: "https://pkgs.k8s.io/core:/stable:/v{{ kubernetes_version }}/deb/" +kubernetes_apt_release_channel: "stable" +kubernetes_apt_repository: "https://pkgs.k8s.io/core:/{{ kubernetes_apt_release_channel }}:/v{{ kubernetes_version }}/deb/" kubernetes_yum_base_url: "https://pkgs.k8s.io/core:/stable:/v{{ kubernetes_version }}/rpm/" kubernetes_yum_gpg_key: "https://pkgs.k8s.io/core:/stable:/v{{ kubernetes_version }}/rpm/repodata/repomd.xml.key"