2024-02-23 08:25:03 +00:00
|
|
|
---
|
2023-01-01 07:50:03 +00:00
|
|
|
version: '3'
|
|
|
|
|
2024-02-23 08:25:03 +00:00
|
|
|
silent: true
|
|
|
|
|
2023-01-01 07:50:03 +00:00
|
|
|
vars:
|
2024-02-23 08:25:03 +00:00
|
|
|
CONFIG_PATHS: |
|
|
|
|
/usr/local/etc/haproxy.conf
|
|
|
|
/usr/local/etc/nginx/nginx.conf
|
|
|
|
/usr/local/etc/apache24/httpd.conf
|
|
|
|
SERVICES: "haproxy apache24 nginx plexmediaserver"
|
|
|
|
SERVICE_PORTS: 80 443 22 32400
|
|
|
|
command: 'echo $(whoami)@$(hostname -f)'
|
|
|
|
|
|
|
|
dotenv:
|
|
|
|
- .env
|
|
|
|
env:
|
|
|
|
GITLAB_PROJECT_ID: '{{ .stashbox_project_id }}'
|
|
|
|
GITLAB_PROJECT_SLUG: stashbox
|
2023-01-01 07:50:03 +00:00
|
|
|
|
|
|
|
tasks:
|
2024-02-23 08:25:03 +00:00
|
|
|
default:
|
|
|
|
- task: services
|
|
|
|
|
2024-02-24 04:23:52 +00:00
|
|
|
run: ssh -qtt "$stashbox_domain" '{{.command}}'
|
|
|
|
run-root: ssh -qtt "$stashbox_domain" 'su -l root -c "{{.command}}"'
|
2024-02-23 08:25:03 +00:00
|
|
|
|
|
|
|
exec:
|
|
|
|
- task: run
|
|
|
|
vars:
|
|
|
|
command: "{{.CLI_ARGS}}"
|
|
|
|
exec-root:
|
|
|
|
- task: run-root
|
|
|
|
vars:
|
|
|
|
command: "{{.CLI_ARGS}}"
|
|
|
|
|
|
|
|
services-restart:
|
2023-01-01 07:50:03 +00:00
|
|
|
cmds:
|
2024-02-23 08:25:03 +00:00
|
|
|
- for: { var: SERVICES }
|
|
|
|
task: run-root
|
|
|
|
vars:
|
|
|
|
command: echo service {{.ITEM}} restart
|
|
|
|
services:
|
2023-01-01 07:50:03 +00:00
|
|
|
cmds:
|
2024-02-23 08:25:03 +00:00
|
|
|
- for: { var: SERVICE_PORTS }
|
|
|
|
task: run
|
|
|
|
vars:
|
|
|
|
command: echo "=== PORT {{.ITEM}}"; sockstat -l|grep ":{{.ITEM}}"
|
|
|
|
|
|
|
|
nano:
|
|
|
|
- task: run
|
|
|
|
vars:
|
|
|
|
command: nano {{ .CLI_ARGS }}
|
|
|
|
nano-root:
|
|
|
|
- task: run-root
|
|
|
|
vars:
|
|
|
|
command: nano {{ .CLI_ARGS }}
|
|
|
|
|
|
|
|
diff:
|
|
|
|
- task: path-diff
|
|
|
|
vars:
|
|
|
|
remote_path: "{{.CLI_ARGS}}"
|
|
|
|
update:
|
|
|
|
- task: safe-update
|
|
|
|
vars:
|
|
|
|
remote_path: "{{.CLI_ARGS}}"
|
|
|
|
theme-update:
|
|
|
|
- task: path-update
|
|
|
|
vars:
|
|
|
|
remote_path: "{{.stashbox_webtheme_root}}/"
|
|
|
|
local_path: "theme/*"
|
|
|
|
conf-update:
|
|
|
|
cmds:
|
|
|
|
- for: { var: CONFIG_PATHS }
|
|
|
|
task: safe-update
|
|
|
|
vars:
|
|
|
|
remote_path: "{{.ITEM}}"
|
|
|
|
conf-diff:
|
|
|
|
cmds:
|
|
|
|
- for: { var: CONFIG_PATHS }
|
|
|
|
task: path-diff
|
|
|
|
vars:
|
|
|
|
remote_path: "{{.ITEM}}"
|
|
|
|
|
|
|
|
plan: source .env; terraform init; terraform plan
|
|
|
|
migrate-state: terraform init -migrate-state
|
|
|
|
|
|
|
|
# Utilities
|
|
|
|
path-update: echo scp "{{.local_path}}" "$stashbox_domain:{{.remote_path}}"
|
|
|
|
path-backup: scp "$stashbox_domain:{{.remote_path}}" "./.$(basename {{.remote_path}})-$(date +%s)" || echo "No file found."
|
|
|
|
path-diff:
|
|
|
|
- task: path-backup
|
|
|
|
vars:
|
|
|
|
remote_path: "{{.remote_path}}"
|
|
|
|
- diff "$(ls -c .$(basename {{.remote_path}})-*|head -n1)" "$(basename {{.remote_path}})" || [ "$?" == "1" ]
|
|
|
|
safe-update:
|
|
|
|
- task: path-backup
|
|
|
|
vars:
|
|
|
|
remote_path: "{{.remote_path}}"
|
|
|
|
- echo scp "$(basename {{.remote_path}})" "$stashbox_domain:{{.remote_path}}"
|
|
|
|
- task: path-diff
|
|
|
|
vars:
|
|
|
|
remote_path: "{{.remote_path}}"
|