From bcba6b20864aa48ebf776734cfc8aa249faf3ad4 Mon Sep 17 00:00:00 2001 From: Andrew Woodlee Date: Mon, 3 Mar 2025 23:46:26 -0600 Subject: [PATCH] v0.10.0 --- .../unreleased/Added-20250301-132932.yaml | 3 + .../unreleased/Added-20250303-234248.yaml | 3 + .../unreleased/Added-20250303-234505.yaml | 3 + .../unreleased/Changed-20250301-194321.yaml | 3 + .../unreleased/Fixed-20250301-132600.yaml | 3 + .../unreleased/Fixed-20250301-132801.yaml | 3 + .../unreleased/Fixed-20250301-182434.yaml | 3 + docs/content/examples/backy.yaml | 108 ++++++++++++++++++ docs/content/examples/example.yml | 24 ++++ docs/layouts/shortcodes/code.html | 3 + examples/example.yml | 24 ++++ tests/.gitignore | 1 + tests/ErrorHook.yml | 17 +++ tests/HookNotInFile.yaml | 14 +++ tests/SuccessHook.yml | 16 +++ 15 files changed, 228 insertions(+) create mode 100644 .changes/unreleased/Added-20250301-132932.yaml create mode 100644 .changes/unreleased/Added-20250303-234248.yaml create mode 100644 .changes/unreleased/Added-20250303-234505.yaml create mode 100644 .changes/unreleased/Changed-20250301-194321.yaml create mode 100644 .changes/unreleased/Fixed-20250301-132600.yaml create mode 100644 .changes/unreleased/Fixed-20250301-132801.yaml create mode 100644 .changes/unreleased/Fixed-20250301-182434.yaml create mode 100644 docs/content/examples/backy.yaml create mode 100644 docs/content/examples/example.yml create mode 100644 docs/layouts/shortcodes/code.html create mode 100644 examples/example.yml create mode 100644 tests/.gitignore create mode 100644 tests/ErrorHook.yml create mode 100644 tests/HookNotInFile.yaml create mode 100644 tests/SuccessHook.yml diff --git a/.changes/unreleased/Added-20250301-132932.yaml b/.changes/unreleased/Added-20250301-132932.yaml new file mode 100644 index 0000000..38a0c1f --- /dev/null +++ b/.changes/unreleased/Added-20250301-132932.yaml @@ -0,0 +1,3 @@ +kind: Added +body: 'Hooks: improved logging when executing' +time: 2025-03-01T13:29:32.195438013-06:00 diff --git a/.changes/unreleased/Added-20250303-234248.yaml b/.changes/unreleased/Added-20250303-234248.yaml new file mode 100644 index 0000000..0f1e74f --- /dev/null +++ b/.changes/unreleased/Added-20250303-234248.yaml @@ -0,0 +1,3 @@ +kind: Added +body: 'User commands: adding SSH keys using config key `userSshPubKeys`' +time: 2025-03-03T23:42:48.009294808-06:00 diff --git a/.changes/unreleased/Added-20250303-234505.yaml b/.changes/unreleased/Added-20250303-234505.yaml new file mode 100644 index 0000000..292d7f9 --- /dev/null +++ b/.changes/unreleased/Added-20250303-234505.yaml @@ -0,0 +1,3 @@ +kind: Added +body: 'directives: added support for fetching values using directive `%{externalSource:key}%`' +time: 2025-03-03T23:45:05.666939653-06:00 diff --git a/.changes/unreleased/Changed-20250301-194321.yaml b/.changes/unreleased/Changed-20250301-194321.yaml new file mode 100644 index 0000000..6477681 --- /dev/null +++ b/.changes/unreleased/Changed-20250301-194321.yaml @@ -0,0 +1,3 @@ +kind: Changed +body: 'Commands: if dir is not specified, run in config dir' +time: 2025-03-01T19:43:21.323077376-06:00 diff --git a/.changes/unreleased/Fixed-20250301-132600.yaml b/.changes/unreleased/Fixed-20250301-132600.yaml new file mode 100644 index 0000000..07cf0d1 --- /dev/null +++ b/.changes/unreleased/Fixed-20250301-132600.yaml @@ -0,0 +1,3 @@ +kind: Fixed +body: 'LocalFetcher: return fetch error' +time: 2025-03-01T13:26:00.330176712-06:00 diff --git a/.changes/unreleased/Fixed-20250301-132801.yaml b/.changes/unreleased/Fixed-20250301-132801.yaml new file mode 100644 index 0000000..afdcc41 --- /dev/null +++ b/.changes/unreleased/Fixed-20250301-132801.yaml @@ -0,0 +1,3 @@ +kind: Fixed +body: 'Lists: load file key before attempting to load from current file' +time: 2025-03-01T13:28:01.739467944-06:00 diff --git a/.changes/unreleased/Fixed-20250301-182434.yaml b/.changes/unreleased/Fixed-20250301-182434.yaml new file mode 100644 index 0000000..70fcfad --- /dev/null +++ b/.changes/unreleased/Fixed-20250301-182434.yaml @@ -0,0 +1,3 @@ +kind: Fixed +body: 'fix: host not in config file, but in ssh config, properly added to hosts struct' +time: 2025-03-01T18:24:34.81395054-06:00 diff --git a/docs/content/examples/backy.yaml b/docs/content/examples/backy.yaml new file mode 100644 index 0000000..17046dd --- /dev/null +++ b/docs/content/examples/backy.yaml @@ -0,0 +1,108 @@ +commands: + stop-docker-container: + cmd: docker + Args: + - compose + - -f /some/path/to/docker-compose.yaml + - down + # if host is not defined, cmd will be run locally + host: some-host + hooks: + final: + - hostname + error: + - hostname + backup-docker-container-script: + cmd: /path/to/script + # The host has to be defined in the config file + host: some-host + environment: + - FOO=BAR + - APP=$VAR + shell-cmd: + cmd: rsync + shell: bash + Args: + - -av some-host:/path/to/data ~/Docker/Backups/docker-data + hostname: + cmd: hostname + update-docker: + type: package + shell: zsh # best to run package commands in a shell + packageName: docker-ce + Args: + - docker-ce-cli + packageManager: apt + packageOperation: install + update-dockerApt: + # type: package + shell: zsh + cmd: apt + Args: + - update + - "&&" + - apt install -y docker-ce + - docker-ce-cli + packageManager: apt + packageOperation: install + +cmd-lists: + cmds-to-run: # this can be any name you want + # all commands have to be defined + order: + - stop-docker-container + - backup-docker-container-script + - shell-cmd + - hostname + notifications: + - matrix.matrix + name: backup-some-server + cron: "0 0 1 * * *" + hostname: + name: hostname + order: + - hostname + notifications: + - mail.prod-email + +hosts: + # any ssh_config(5) keys/values not listed here will be looked up in the config file or the default config file + some-host: + hostname: some-hostname + config: ~/.ssh/config + user: user + privatekeypath: /path/to/private/key + port: 22 + # can also be env:VAR + password: file:/path/to/file + # only one is supported for now + proxyjump: some-proxy-host + +# optional +logging: + verbose: true + file: ./backy.log + console: false + cmd-std-out: false + + +notifications: + mail: + prod-email: + id: prod-email + type: mail + host: yourhost.tld + port: 587 + senderAddress: email@domain.tld + to: + - admin@domain.tld + username: smtp-username@domain.tld + password: your-password-here + matrix: + matrix: + id: matrix + type: matrix + home-server: your-home-server.tld + room-id: room-id + access-token: your-access-token + user-id: your-user-id \ No newline at end of file diff --git a/docs/content/examples/example.yml b/docs/content/examples/example.yml new file mode 100644 index 0000000..b11914f --- /dev/null +++ b/docs/content/examples/example.yml @@ -0,0 +1,24 @@ +commands: + stop-docker-container: + cmd: docker + Args: + - compose + - -f /some/path/to/docker-compose.yaml + - down + # if host is not defined, command will be run locally + # The host has to be defined in either the config file or the SSH Config files + host: some-host + hooks: + error: + - some-other-command-when-failing + success: + - success-command + final: + - final-command + backup-docker-container-script: + cmd: /path/to/local/script + # script file is input as stdin to SSH + type: scriptFile # also can be script + environment: + - FOO=BAR + - APP=$VAR \ No newline at end of file diff --git a/docs/layouts/shortcodes/code.html b/docs/layouts/shortcodes/code.html new file mode 100644 index 0000000..5f7b685 --- /dev/null +++ b/docs/layouts/shortcodes/code.html @@ -0,0 +1,3 @@ +{{ $file := .Get "file" | readFile }} +{{ $lang := .Get "language" }} +{{ (print "```" $lang "\n" $file "\n```") }} \ No newline at end of file diff --git a/examples/example.yml b/examples/example.yml new file mode 100644 index 0000000..b11914f --- /dev/null +++ b/examples/example.yml @@ -0,0 +1,24 @@ +commands: + stop-docker-container: + cmd: docker + Args: + - compose + - -f /some/path/to/docker-compose.yaml + - down + # if host is not defined, command will be run locally + # The host has to be defined in either the config file or the SSH Config files + host: some-host + hooks: + error: + - some-other-command-when-failing + success: + - success-command + final: + - final-command + backup-docker-container-script: + cmd: /path/to/local/script + # script file is input as stdin to SSH + type: scriptFile # also can be script + environment: + - FOO=BAR + - APP=$VAR \ No newline at end of file diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 0000000..c8c6761 --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1 @@ +private \ No newline at end of file diff --git a/tests/ErrorHook.yml b/tests/ErrorHook.yml new file mode 100644 index 0000000..701abee --- /dev/null +++ b/tests/ErrorHook.yml @@ -0,0 +1,17 @@ +commands: + echoTestFail: + cmd: ech + shell: bash + Args: hello world + hooks: + error: + - errorCmd + + errorCmd: + name: get docker version + cmd: docker + getOutput: true + outputToLog: true + Args: + - "-v" + host: email-svr \ No newline at end of file diff --git a/tests/HookNotInFile.yaml b/tests/HookNotInFile.yaml new file mode 100644 index 0000000..1aa384b --- /dev/null +++ b/tests/HookNotInFile.yaml @@ -0,0 +1,14 @@ +commands: + echoTestFail: + cmd: ech + shell: bash + Args: hello world + hooks: + error: + - errorCm # + + errorCmd: + name: get docker version + cmd: docker + Args: + - "-v" \ No newline at end of file diff --git a/tests/SuccessHook.yml b/tests/SuccessHook.yml new file mode 100644 index 0000000..058db73 --- /dev/null +++ b/tests/SuccessHook.yml @@ -0,0 +1,16 @@ +commands: + echoTestSuccess: + cmd: echo + shell: bash + Args: hello world + hooks: + success: + - successCmd + + errorCmd: + name: get docker version + cmd: docker + getOutput: true + outputToLog: true + Args: + - "-v" \ No newline at end of file