Skip to content

Commit 8295535

Browse files
author
Mafyuh
committedJan 13, 2025
add weekly playbook runs
1 parent fd2ea44 commit 8295535

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed
 

‎.forgejo/workflows/ansible-playbooks.yml

+19-6
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
name: Run Ansible Playbook
22

33
on:
4+
schedule:
5+
# Runs weekly at 3:00 AM every Monday (UTC)
6+
- cron: "0 3 * * 1"
47
workflow_dispatch:
58
inputs:
69
playbook:
710
description: "Choose the Ansible playbook to run"
811
required: true
912
type: choice
1013
options:
11-
- apt.yml
1214
- docker-count.yml
1315
- docker-login.yml
14-
- docker-prune.yml
1516
- git-pull-reset.yml
16-
- main-reboot-required.yml
17+
- maint-reboot-required.yml
1718
- ntp.yml
1819
- zsh.yml
20+
- weekly/docker-prune.yml
21+
- weekly/apt.yml
1922

2023
jobs:
2124
run-playbook:
@@ -85,10 +88,20 @@ jobs:
8588
eval $(ssh-agent -s)
8689
ssh-add /root/.ssh/id_rsa
8790
88-
- name: Run the selected playbook
91+
- name: Run Playbooks
8992
env:
9093
BWS_ACCESS_TOKEN: ${{ secrets.BWS_ACCESS_TOKEN }}
9194
ANSIBLE_CONFIG: ansible/ansible.cfg
9295
run: |
93-
ansible-playbook -i ansible/hosts.ini ./ansible/playbooks/${{ github.event.inputs.playbook }} \
94-
--extra-vars "bw_access_token=${{ secrets.BW_ACCESS_TOKEN }}"
96+
if [ -z "${{ github.event.inputs.playbook }}" ]; then
97+
echo "Running all playbooks in ansible/playbooks/weekly..."
98+
for playbook in ansible/playbooks/weekly/*.yml; do
99+
echo "Running $playbook..."
100+
ansible-playbook -i ansible/hosts.ini $playbook \
101+
--extra-vars "bw_access_token=${{ secrets.BW_ACCESS_TOKEN }}"
102+
done
103+
else
104+
echo "Running selected playbook: ${{ github.event.inputs.playbook }}"
105+
ansible-playbook -i ansible/hosts.ini ansible/playbooks/${{ github.event.inputs.playbook }} \
106+
--extra-vars "bw_access_token=${{ secrets.BW_ACCESS_TOKEN }}"
107+
fi

‎ansible/playbooks/main-reboot-required.yml renamed to ‎ansible/playbooks/maint-reboot-required.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
- name: check if system reboot is required
33
hosts: "*"
4-
become: yes
4+
become: true
55
tasks:
66
- name: check if system reboot is required
77
become: true
File renamed without changes.

0 commit comments

Comments
 (0)
Please sign in to comment.