try a new workflow

This commit is contained in:
2025-12-19 19:20:19 +05:30
parent eaedd4aca1
commit 53a4179108

View File

@@ -1,64 +1,65 @@
name: Run ansible playbooks name: Ansible Operations
on: on:
schedule: schedule:
- cron: "@daily" - cron: "@daily"
workflow_dispatch: workflow_dispatch:
env:
REPO_PATH: /tmp/repo
jobs: jobs:
update-packages: clone-repo:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: outputs:
image: alpine/ansible:2.18.6 repo-path: ${{ env.REPO_PATH }}
steps: steps:
- name: Setup environment - name: Checkout repository
run: | uses: actions/checkout@v6
apk add git with:
git clone https://gitea.akshun-lab.cc/aggarwalakshun/ansible.git /mnt path: ${{ env.REPO_PATH }}
echo -e "${{ secrets.ANSIBLE_PRIVATE_KEY }}" > /mnt/default-key && \
echo "${{ secrets.ANSIBLE_BECOME_PASS }}" > /mnt/become-pass.txt && \
chmod 600 /mnt/default-key
- name: Update packages
env:
ANSIBLE_HOST_KEY_CHECKING: 'False'
ANSIBLE_PYTHON_INTERPRETER: 'auto_silent'
run: |
ansible-playbook -i /mnt/inventory.yml --vault-pass-file /mnt/become-pass.txt --key-file /mnt/default-key /mnt/playbooks/update-packages.yml
prune-images: setup-environment:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: needs: clone-repo
image: alpine/ansible:2.18.6 outputs:
key-file: ${{ env.REPO_PATH }}/default-key
vault-file: ${{ env.REPO_PATH }}/become-pass.txt
steps: steps:
- name: Setup environment - name: Set up environment
run: |
apk add git
git clone https://gitea.akshun-lab.cc/aggarwalakshun/ansible.git /mnt
echo -e "${{ secrets.ANSIBLE_PRIVATE_KEY }}" > /mnt/default-key && \
echo "${{ secrets.ANSIBLE_BECOME_PASS }}" > /mnt/become-pass.txt && \
chmod 600 /mnt/default-key
- name: Prune ctr images
env: env:
ANSIBLE_HOST_KEY_CHECKING: 'False' ANSIBLE_PRIVATE_KEY: ${{ secrets.ANSIBLE_PRIVATE_KEY }}
ANSIBLE_PYTHON_INTERPRETER: 'auto_silent' ANSIBLE_BECOME_PASS: ${{ secrets.ANSIBLE_BECOME_PASS }}
run: | run: |
ansible-playbook -i /mnt/inventory.yml --vault-pass-file /mnt/become-pass.txt --key-file /mnt/default-key /mnt/playbooks/prune-k3s.yml mkdir -p ${{ env.REPO_PATH }}
echo -e "$ANSIBLE_PRIVATE_KEY" > ${{ env.REPO_PATH }}/default-key
echo "$ANSIBLE_BECOME_PASS" > ${{ env.REPO_PATH }}/become-pass.txt
chmod 600 ${{ env.REPO_PATH }}/default-key
update-proxmox: ansible-jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: needs: setup-environment
image: alpine/ansible:2.18.6 strategy:
matrix:
playbook:
- name: update-packages
file: update-packages.yml
- name: prune-images
file: prune-k3s.yml
- name: update-proxmox
file: update-proxmox.yml
steps: steps:
- name: Setup environment - name: Run ${{ matrix.playbook.name }}
run: | uses: addnab/docker-run-action@v3
apk add git with:
git clone https://gitea.akshun-lab.cc/aggarwalakshun/ansible.git /mnt image: gitea.akshun-lab.cc/aggarwalakshun/ansible:1.0.0
echo -e "${{ secrets.ANSIBLE_PRIVATE_KEY }}" > /mnt/default-key && \ options: -v ${{ env.REPO_PATH }}:/repo
echo "${{ secrets.ANSIBLE_BECOME_PASS }}" > /mnt/become-pass.txt && \ run: |
chmod 600 /mnt/default-key ansible-playbook \
- name: Update proxmox nodes -i /repo/inventory.yml \
--vault-pass-file /repo/become-pass.txt \
--key-file /repo/default-key \
/repo/playbooks/${{ matrix.playbook.file }}
env: env:
ANSIBLE_HOST_KEY_CHECKING: 'False' ANSIBLE_HOST_KEY_CHECKING: 'False'
ANSIBLE_PYTHON_INTERPRETER: 'auto_silent' ANSIBLE_PYTHON_INTERPRETER: 'auto_silent'
run: |
ansible-playbook -i /mnt/inventory.yml --vault-pass-file /mnt/become-pass.txt --key-file /mnt/default-key /mnt/playbooks/update-proxmox.yml