Skip to content

Commit

Permalink
kubectl: add kubectl_version parameter (#742)
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Berendt <[email protected]>
  • Loading branch information
berendt authored Dec 16, 2024
1 parent 8ee817c commit db9f385
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
12 changes: 8 additions & 4 deletions molecule/delegated/tests/kubectl/redhat.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import pytest

from ..util.util import (
get_ansible,
get_variable,
get_from_url,
extract_url_from_variable,
get_ansible,
get_centos_repo_key,
get_from_url,
get_variable,
jinja_replacement,
)

testinfra_runner, testinfra_hosts = get_ansible()
Expand All @@ -32,7 +33,10 @@ def test_kubectl_gpg_key_present(host):
)

k8s_repository_key_url = get_variable(host, "kubectl_redhat_repository_key")
key_content = get_from_url(k8s_repository_key_url)
k8s_version = get_variable(host, "kubectl_version")
key_content = get_from_url(
jinja_replacement(k8s_repository_key_url, {"kubectl_version": k8s_version})
)
assert installed_key in key_content


Expand Down
12 changes: 5 additions & 7 deletions roles/kubectl/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
---
##########################
# repository (arch is selected automatically by the system, no manual placement required!)
kubectl_version: "1.32"

kubectl_configure_repository: true

# Review the following url for the current installation instructions
# https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/#install-using-native-package-management
# (Update key and release if changed)
kubectl_debian_repository_key: https://pkgs.k8s.io/core:/stable:/v1.32/deb/Release.key
kubectl_debian_repository: "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.32/deb/ /"
kubectl_debian_repository_key: "https://pkgs.k8s.io/core:/stable:/v{{ kubectl_version }}/deb/Release.key"
kubectl_debian_repository: "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v{{ kubectl_version }}/deb/ /"

kubectl_redhat_repository_key: https://pkgs.k8s.io/core:/stable:/v1.32/rpm/repodata/repomd.xml.key
kubectl_redhat_repository: "https://pkgs.k8s.io/core:/stable:/v1.32/rpm/"
kubectl_redhat_repository_key: "https://pkgs.k8s.io/core:/stable:/v{{ kubectl_version }}/rpm/repodata/repomd.xml.key"
kubectl_redhat_repository: "https://pkgs.k8s.io/core:/stable:/v{{ kubectl_version }}/rpm/"

0 comments on commit db9f385

Please sign in to comment.