From 4b1d77377977dd44c0eb01054a3071d9c03ce613 Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Wed, 9 May 2018 16:09:32 -0500 Subject: [PATCH] Fix install on CentOS 7. --- .travis.yml | 1 - README.md | 4 ++++ defaults/main.yml | 1 - meta/main.yml | 3 --- tasks/main.yml | 2 ++ tasks/setup-RedHat.yml | 35 ++++++++++++++++++++++++----------- 6 files changed, 30 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3b90107..23de055 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,6 @@ env: - distro: centos7 - distro: ubuntu1604 - distro: debian9 - - distro: fedora27 script: # Configure test script so we can run extra tests after playbook is run. diff --git a/README.md b/README.md index 479da12..ac13198 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,10 @@ TODO. kubernetes_apt_repository: "deb http://apt.kubernetes.io/ kubernetes-xenial {{ kubernetes_apt_release_channel }}" kubernetes_apt_ignore_key_error: False +TODO. + + kubernetes_yum_arch: x86_64 + TODO. ## Dependencies diff --git a/defaults/main.yml b/defaults/main.yml index c9fe805..1d95a7e 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -20,4 +20,3 @@ kubernetes_apt_repository: "deb http://apt.kubernetes.io/ kubernetes-xenial {{ k kubernetes_apt_ignore_key_error: False kubernetes_yum_arch: x86_64 -kubernetes_yum_repo_url: "https://packages.cloud.google.com/yum/repos/kubernetes-el7-{{ kubernetes_yum_arch }}" diff --git a/meta/main.yml b/meta/main.yml index 0bd3877..ea13032 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -11,9 +11,6 @@ galaxy_info: - name: EL versions: - 7 - - name: Fedora - versions: - - all - name: Debian versions: - stretch diff --git a/tasks/main.yml b/tasks/main.yml index b71a428..117db88 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -66,6 +66,8 @@ with_items: - kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml - kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/k8s-manifests/kube-flannel-rbac.yml + register: flannel_networking_result + changed_when: "'unchanged' not in flannel_networking_result.stdout" # TODO: Check if taint exists with something like `kubectl describe nodes` # instead of using kubernetes_init_stat.stat.exists check. diff --git a/tasks/setup-RedHat.yml b/tasks/setup-RedHat.yml index bffc54a..12e976b 100644 --- a/tasks/setup-RedHat.yml +++ b/tasks/setup-RedHat.yml @@ -1,13 +1,26 @@ --- -- name: Add Kubernetes GPG key. - rpm_key: - key: https://packages.cloud.google.com/yum/doc/yum-key.gpg - state: present +- name: Ensure Kubernetes repository exists. + yum_repository: + name: kubernetes + description: Kubernetes + enabled: yes + gpgcheck: yes + repo_gpgcheck: yes + 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 -- name: Add Kubernetes repository. - get_url: - url: "{{ kubernetes_yum_repo_url }}" - dest: '/etc/yum.repos.d/kubernetes.repo' - owner: root - group: root - mode: 0644 +- 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 + +- name: Make cache if Kubernetes GPG key changed. + command: "yum -q makecache -y --disablerepo='*' --enablerepo='kubernetes'" + when: kubernetes_rpm_key is changed + warn: no