Skip to content

Commit

Permalink
Install K9s on the seed (#569)
Browse files Browse the repository at this point in the history
  • Loading branch information
MoteHue committed Jul 9, 2024
1 parent f823ea5 commit b1b8e0b
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
3 changes: 3 additions & 0 deletions playbooks/provision_cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
- include_role:
name: stackhpc.azimuth_ops.k3s

- include_role:
name: stackhpc.azimuth_ops.k9s

- name: Get installed Kubernetes version
command: k3s kubectl version --output json
changed_when: false
Expand Down
19 changes: 19 additions & 0 deletions roles/k9s/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---

# The K9s repo
k9s_repo: https://github.com/derailed/k9s
# The K9s version to download
k9s_version: v0.32.5
# The OS variant and architecture to use
# See https://github.com/derailed/k9s/releases for the available options
k9s_os: "{{ ansible_system }}"
k9s_architecture: "{{ 'amd64' if ansible_architecture == 'x86_64' else ansible_architecture }}"
# The name of the K9s archive
k9s_archive_name: "k9s_{{ k9s_os }}_{{ k9s_architecture }}.tar.gz"
# The URL of the K9s archive to download
k9s_archive_url: "{{ k9s_repo }}/releases/download/{{ k9s_version }}/{{ k9s_archive_name }}"

# The directory into which the K9s archive should be unpacked
k9s_unpack_directory: "/opt/k9s/{{ k9s_version }}"
# The directory into which the K9s binary should be placed
k9s_bin_directory: /usr/local/bin
29 changes: 29 additions & 0 deletions roles/k9s/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---

- name: Ensure unpack directory exists
file:
path: "{{ k9s_unpack_directory }}"
state: directory

- name: Download and extract K9s archive
unarchive:
remote_src: yes
src: "{{ k9s_archive_url }}"
dest: "{{ k9s_unpack_directory }}"

- name: Ensure binary directory exists
file:
path: "{{ k9s_bin_directory }}"
state: directory

- name: Copy executable to binary directory
copy:
remote_src: yes
src: "{{ (k9s_unpack_directory, 'k9s') | path_join }}"
dest: "{{ k9s_bin_directory }}"
mode: u=rwx,g=rw,o=rx

- name: Ensure K9s shell completions are in .bashrc
lineinfile:
path: "{{ ansible_env.HOME }}/.bashrc"
line: source <(k9s completion bash)

0 comments on commit b1b8e0b

Please sign in to comment.