--- version: '3' silent: true vars: 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 tasks: default: - task: services run: ssh -qtt "$stashbox_domain" '{{.command}}' run-root: ssh -qtt "$stashbox_domain" 'su -l root -c "{{.command}}"' exec: - task: run vars: command: "{{.CLI_ARGS}}" exec-root: - task: run-root vars: command: "{{.CLI_ARGS}}" services-restart: cmds: - for: { var: SERVICES } task: run-root vars: command: echo service {{.ITEM}} restart services: cmds: - 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}}"