There are two problems with kubernetes installation currently. The first
is that cri-o's package location has moved. The second is the debian
bookworms snap install has gone stale and we should update it with snap
before installing more snaps.
Per the cri-o packaging README [0] the packages for cri-o moved from the
k8s package cdn to downloads.opensuse.org. Update our cri-o installation
tasks to use the correct package repo. Not updating produces HTTP 403
errors. I guess they want people to notice that they shouldn't use the
old location any longer.
In the case of debian bookworm the microk8s snap needs a core snap
version available in a newer snapd release. We can use snap to install
snap in order to update snap. Do that so that microk8s can be installed
on Debian.
[0] 3b30cfee75/README.md
Change-Id: Ied971eb4ae4f53440fdb7204540b4360ab797e74
72 lines
1.8 KiB
YAML
72 lines
1.8 KiB
YAML
- name: Check distro
|
|
assert:
|
|
that: ansible_distribution_release in ['jammy', 'bookworm', 'noble']
|
|
msg: 'This role is only supported on Jammy or Bookworm or Noble'
|
|
|
|
- name: Install snapd
|
|
become: yes
|
|
package:
|
|
name: snapd
|
|
state: present
|
|
|
|
# Snapd isn't installed as a snap on Debian (it is on Ubuntu). After the
|
|
# base install we use snap to update itself so that we're running a modern
|
|
# snapd
|
|
# Otherwise some snaps complain about missing their dependencies.
|
|
- name: Update snap on Debian
|
|
become: yes
|
|
command: snap install core snapd
|
|
when: ansible_distribution == "Debian"
|
|
|
|
- name: Install microk8s snap
|
|
become: yes
|
|
command: 'snap install microk8s --classic --channel={{ ensure_kubernetes_microk8s_channel }}'
|
|
|
|
- name: Wait for kubernetes to be ready before adding add-ons
|
|
become: yes
|
|
command: '/snap/bin/microk8s status --wait-ready'
|
|
|
|
- name: Install add-ons
|
|
become: yes
|
|
command: '/snap/bin/microk8s enable {{ ensure_kubernetes_microk8s_addons | join(" ") }}'
|
|
|
|
- name: Install kubectl wrapper
|
|
become: yes
|
|
copy:
|
|
content: |
|
|
#!/bin/bash
|
|
/snap/bin/microk8s.kubectl "$@"
|
|
dest: /usr/local/bin/kubectl
|
|
owner: root
|
|
group: root
|
|
mode: 0755
|
|
|
|
- name: Allow zuul user kubectl access
|
|
become: yes
|
|
user:
|
|
name: 'zuul'
|
|
groups: 'microk8s'
|
|
append: yes
|
|
|
|
- name: Create .kube directory
|
|
file:
|
|
path: "{{ ansible_user_dir }}/.kube"
|
|
state: directory
|
|
mode: 0755
|
|
|
|
- name: Populate kube config
|
|
become: yes
|
|
shell: /snap/bin/microk8s config > {{ ansible_user_dir }}/.kube/config
|
|
|
|
- name: Ensure we can read config
|
|
become: yes
|
|
file:
|
|
path: "{{ ansible_user_dir }}/.kube/config"
|
|
owner: zuul
|
|
group: zuul
|
|
state: touch
|
|
mode: 0644
|
|
|
|
- name: Reset connection to pickup group
|
|
meta: reset_connection
|