From a3714d8b79c4c2a706df5a6c04259cec860f4e69 Mon Sep 17 00:00:00 2001 From: Feng Ye Date: Wed, 18 Nov 2020 11:51:21 +0800 Subject: [PATCH] Make YUM baseurl and gpgkey configurable --- README.md | 6 +++++- defaults/main.yml | 4 ++++ tasks/setup-RedHat.yml | 10 +++------- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 7a10400..4d540c4 100644 --- a/README.md +++ b/README.md @@ -83,8 +83,12 @@ Options passed to `kubeadm init` when initializing the Kubernetes master. The `k Apt repository options for Kubernetes installation. kubernetes_yum_arch: x86_64 + kubernetes_yum_base_url: "https://packages.cloud.google.com/yum/repos/kubernetes-el7-{{ kubernetes_yum_arch }}" + kubernetes_yum_gpg_key: + - https://packages.cloud.google.com/yum/doc/yum-key.gpg + - https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg -Yum repository options for Kubernetes installation. +Yum repository options for Kubernetes installation. You can change `kubernete_yum_gpg_key` to a different url if you are behind a firewall or provide a trustworthy mirror. Usually in combination with changing `kubernetes_yum_base_url` as well. kubernetes_flannel_manifest_file_rbac: https://raw.githubusercontent.com/coreos/flannel/master/Documentation/k8s-manifests/kube-flannel-rbac.yml kubernetes_flannel_manifest_file: https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml diff --git a/defaults/main.yml b/defaults/main.yml index 99b7750..5bb912d 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -40,6 +40,10 @@ kubernetes_apt_repository: "deb http://apt.kubernetes.io/ kubernetes-xenial {{ k kubernetes_apt_ignore_key_error: false kubernetes_yum_arch: x86_64 +kubernetes_yum_base_url: "https://packages.cloud.google.com/yum/repos/kubernetes-el7-{{ kubernetes_yum_arch }}" +kubernetes_yum_gpg_key: + - https://packages.cloud.google.com/yum/doc/yum-key.gpg + - https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg # Flannel config files. kubernetes_flannel_manifest_file_rbac: https://raw.githubusercontent.com/coreos/flannel/master/Documentation/k8s-manifests/kube-flannel-rbac.yml diff --git a/tasks/setup-RedHat.yml b/tasks/setup-RedHat.yml index 83335d9..99a7098 100644 --- a/tasks/setup-RedHat.yml +++ b/tasks/setup-RedHat.yml @@ -6,19 +6,15 @@ enabled: true gpgcheck: true repo_gpgcheck: true - baseurl: https://packages.cloud.google.com/yum/repos/kubernetes-el7-{{ kubernetes_yum_arch }} - gpgkey: - - https://packages.cloud.google.com/yum/doc/yum-key.gpg - - https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg + baseurl: "{{ kubernetes_yum_base_url }}" + gpgkey: "{{ kubernetes_yum_gpg_key }}" - name: Add Kubernetes GPG keys. rpm_key: key: "{{ item }}" state: present register: kubernetes_rpm_key - with_items: - - https://packages.cloud.google.com/yum/doc/yum-key.gpg - - https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg + with_items: "{{ kubernetes_yum_gpg_key }}" - name: Make cache if Kubernetes GPG key changed. command: "yum -q makecache -y --disablerepo='*' --enablerepo='kubernetes'"