File tree 4 files changed +20
-7
lines changed
4 files changed +20
-7
lines changed Original file line number Diff line number Diff line change 1
1
name : Run Ansible Playbook
2
2
3
3
on :
4
+ schedule :
5
+ # Runs weekly at 3:00 AM every Monday (UTC)
6
+ - cron : " 0 3 * * 1"
4
7
workflow_dispatch :
5
8
inputs :
6
9
playbook :
7
10
description : " Choose the Ansible playbook to run"
8
11
required : true
9
12
type : choice
10
13
options :
11
- - apt.yml
12
14
- docker-count.yml
13
15
- docker-login.yml
14
- - docker-prune.yml
15
16
- git-pull-reset.yml
16
- - main -reboot-required.yml
17
+ - maint -reboot-required.yml
17
18
- ntp.yml
18
19
- zsh.yml
20
+ - weekly/docker-prune.yml
21
+ - weekly/apt.yml
19
22
20
23
jobs :
21
24
run-playbook :
@@ -85,10 +88,20 @@ jobs:
85
88
eval $(ssh-agent -s)
86
89
ssh-add /root/.ssh/id_rsa
87
90
88
- - name : Run the selected playbook
91
+ - name : Run Playbooks
89
92
env :
90
93
BWS_ACCESS_TOKEN : ${{ secrets.BWS_ACCESS_TOKEN }}
91
94
ANSIBLE_CONFIG : ansible/ansible.cfg
92
95
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
Original file line number Diff line number Diff line change 1
1
---
2
2
- name : check if system reboot is required
3
3
hosts : " *"
4
- become : yes
4
+ become : true
5
5
tasks :
6
6
- name : check if system reboot is required
7
7
become : true
File renamed without changes.
File renamed without changes.
You can’t perform that action at this time.
0 commit comments