Skip to content

Commit

Permalink
Merge pull request #178 from grycap/fix_new
Browse files Browse the repository at this point in the history
Fix new
  • Loading branch information
micafer authored Mar 20, 2024
2 parents 9b03957 + 66f4444 commit b67dbc6
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 83 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Role Variables

The variables that can be passed to this role and a brief description about them are as follows.

# Version to install or latest
kube_version: 1.11.4
# Version to install or latest (1.24 or higher)
kube_version: 1.24.17
# Type of node front or wn
kube_type_of_node: front
# IP address or name of the Kube front node
Expand Down
50 changes: 13 additions & 37 deletions tasks/Debian.yaml
Original file line number Diff line number Diff line change
@@ -1,43 +1,19 @@
- block:

- name: Set kube_minor_version
set_fact:
kube_minor_version: "{{ kube_version.split('.')[0] }}.{{ kube_version.split('.')[1] }}"

- name: Add repo key
get_url:
url: "https://pkgs.k8s.io/core:/stable:/v{{ kube_minor_version }}/deb/Release.key"
dest: /etc/apt/trusted.gpg.d/kubernetes.asc
mode: '0644'

- name: Add kubernetes repo
apt_repository: repo='deb https://pkgs.k8s.io/core:/stable:/v{{ kube_minor_version }}/deb/ /' state=present update_cache=yes

when: "kube_version is version('1.24', '>=')"

- block:

- name: Add repo key
get_url:
url: "https://packages.cloud.google.com/apt/doc/apt-key.gpg"
dest: /etc/apt/trusted.gpg.d/google.gpg
mode: '0644'
force: true
register: add_key
ignore_errors: yes
- fail:
msg: "Kubernetes version {{ kube_version }} is not supported"
when: "kube_version is version('1.24', '<')"

- name: Add repo key copy with asc extension to workarond issues
copy:
src: /etc/apt/trusted.gpg.d/google.gpg
dest: /etc/apt/trusted.gpg.d/google.asc
mode: '0644'
remote_src: yes
when: add_key is changed
- name: Set kube_minor_version
set_fact:
kube_minor_version: "{{ kube_version.split('.')[0] }}.{{ kube_version.split('.')[1] }}"

- name: Add kubernetes repo
apt_repository: repo='deb http://apt.kubernetes.io/ kubernetes-xenial main' state=present update_cache=yes
- name: Add repo key
get_url:
url: "https://pkgs.k8s.io/core:/stable:/v{{ kube_minor_version }}/deb/Release.key"
dest: /etc/apt/trusted.gpg.d/kubernetes.asc
mode: '0644'

when: "kube_version is version('1.24', '<')"
- name: Add kubernetes repo
apt_repository: repo='deb https://pkgs.k8s.io/core:/stable:/v{{ kube_minor_version }}/deb/ /' state=present update_cache=yes

- name: Install kubernetes packages
apt: name=kubelet={{ kube_version }}*,kubeadm={{ kube_version }}*,kubectl={{ kube_version }}*
Expand Down
68 changes: 24 additions & 44 deletions tasks/RedHat.yaml
Original file line number Diff line number Diff line change
@@ -1,50 +1,30 @@
---
- block:

- name: Set kube_minor_version
set_fact:
kube_minor_version: "{{ kube_version.split('.')[0] }}.{{ kube_version.split('.')[1] }}"

- name: Set repo file
copy:
dest: /etc/yum.repos.d/kubernetes.repo
content: |
[kubernetes]
name=Kubernetes
baseurl=https://pkgs.k8s.io/core:/stable:/v{{ kube_minor_version }}/rpm/
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=https://pkgs.k8s.io/core:/stable:/v{{ kube_minor_version }}/rpm/repodata/repomd.xml.key
exclude=kubelet kubeadm kubectl cri-tools kubernetes-cni
- name: import gpg key
rpm_key:
key: https://pkgs.k8s.io/core:/stable:/v{{ kube_minor_version }}/rpm/repodata/repomd.xml.key
state: present

when: "kube_version is version('1.24', '>=')"

- block:

- name: Set repo file
copy:
dest: /etc/yum.repos.d/kubernetes.repo
content: |
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
- fail:
msg: "Kubernetes version {{ kube_version }} is not supported"
when: "kube_version is version('1.24', '<')"

- name: import gpg key
rpm_key:
key: https://packages.cloud.google.com/yum/doc/yum-key.gpg
state: present
- name: Set kube_minor_version
set_fact:
kube_minor_version: "{{ kube_version.split('.')[0] }}.{{ kube_version.split('.')[1] }}"

- name: Set repo file
copy:
dest: /etc/yum.repos.d/kubernetes.repo
content: |
[kubernetes]
name=Kubernetes
baseurl=https://pkgs.k8s.io/core:/stable:/v{{ kube_minor_version }}/rpm/
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=https://pkgs.k8s.io/core:/stable:/v{{ kube_minor_version }}/rpm/repodata/repomd.xml.key
exclude=kubelet kubeadm kubectl cri-tools kubernetes-cni
- name: import gpg key
rpm_key:
key: https://pkgs.k8s.io/core:/stable:/v{{ kube_minor_version }}/rpm/repodata/repomd.xml.key
state: present

when: "kube_version is version('1.24', '<')"

- name: Install kubernetes packages
package: name=psmisc,kubelet-{{kube_version}},kubeadm-{{kube_version}},kubectl-{{kube_version}},yum-plugin-versionlock state=present update_cache=yes
Expand Down

0 comments on commit b67dbc6

Please sign in to comment.