feat(ansible): add playbook for installing A13Labs systools with tasks for downloading, unpacking, and setting permissions

This commit is contained in:
2025-05-19 00:34:21 +02:00
parent fef5c73726
commit c9def750f6
13 changed files with 42 additions and 400 deletions
@@ -1,3 +1,3 @@
Match User git
AuthorizedKeysCommandUser git
AuthorizedKeysCommand /usr/local/bin/gitea-auth -u %u -t %t -k %k
AuthorizedKeysCommand /usr/local/bin/k8s_gitea_auth -u %u -t %t -k %k
-11
View File
@@ -1,11 +0,0 @@
#!/bin/bash
NAMESPACE=gitea
PREFIX=gitea-app
# Get the list of running pod names in the given namespace and filter by prefix
POD_NAME=$(/usr/local/bin/kubectl get pods -n "$NAMESPACE" -o json | jq -r --arg PREFIX "$PREFIX" '.items[] | select(.metadata.name | startswith($PREFIX)) | select(.status.phase == "Running") | .metadata.name' | head -n 1)
# Check if a running pod matching the prefix is found
if [ -z "$POD_NAME" ]; then
exit 1
else
/usr/local/bin/kubectl exec -n "$NAMESPACE" "$POD_NAME" -i -- su -s /bin/bash git -- /usr/local/bin/gitea keys -c /data/gitea/conf/app.ini -e git "$@"
fi
+1 -8
View File
@@ -1,11 +1,4 @@
#!/bin/bash
NAMESPACE=gitea
PREFIX=gitea-app
# Get the list of running pod names in the given namespace and filter by prefix
POD_NAME=$(/usr/local/bin/kubectl get pods -n "$NAMESPACE" -o json | jq -r --arg PREFIX "$PREFIX" '.items[] | select(.metadata.name | startswith($PREFIX)) | select(.status.phase == "Running") | .metadata.name' | head -n 1)
# Remove the -c flag from the command
COMMAND=$(echo "$@" | sed "s/-c //g")
# Check if a running pod matching the prefix is found
if [ ! -z "$POD_NAME" ]; then
/usr/local/bin/kubectl exec -n "$NAMESPACE" "$POD_NAME" -i -- env SSH_ORIGINAL_COMMAND="$SSH_ORIGINAL_COMMAND" su -s /bin/bash git -- $COMMAND
fi
/usr/local/bin/k8s_gitea_shell "$NAMESPACE" "$PREFIX" "$@"
+40
View File
@@ -0,0 +1,40 @@
---
- name: Install A13Labs systools
hosts: ubuntu
gather_facts: true
# Specific tasks for this playbook
tasks:
- name: Set required facts
ansible.builtin.set_fact:
systools_verion: " {{ systools_version | default('0.0.1') }}"
tags: always
- name: Download systools zip file
ansible.builtin.get_url:
url: https://github.com/a13labs/systools/releases/download/v{{ systools_version }}/systools-v{{ systools_version }}-linux-amd64.zip
dest: /tmp/systools-v{{ systools_version }}-linux-amd64.zip
mode: '0644'
- name: Unpack systools zip file
ansible.builtin.unarchive:
src: /tmp/systools-v{{ systools_version }}-linux-amd64.zip
dest: /usr/local/bin
remote_src: true
mode: '0755'
extra_opts:
- -j
- name: Remove systools zip file
ansible.builtin.file:
path: /tmp/systools-v{{ systools_version }}-linux-amd64.zip
state: absent
- name: Set root-only executable permissions for specific tools
ansible.builtin.file:
path: /usr/local/bin/{{ item }}
mode: '0750'
loop:
- open_volume
- read_system_id
- k8s_encryption_provider