This repository has been archived by the owner on Dec 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Caleb Hailey
committed
Apr 17, 2020
0 parents
commit 42061f0
Showing
13 changed files
with
1,028 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
description: "#{repo}" | ||
builds: | ||
- platform: "linux" | ||
arch: "amd64" | ||
asset_filename: "#{repo}_#{version}_linux_amd64.tar.gz" | ||
sha_filename: "#{repo}_#{version}_sha512-checksums.txt" | ||
filter: | ||
- "entity.system.os == 'linux'" | ||
- "entity.system.arch == 'amd64'" | ||
|
||
- platform: "linux" | ||
arch: "386" | ||
asset_filename: "#{repo}_#{version}_linux_386.tar.gz" | ||
sha_filename: "#{repo}_#{version}_sha512-checksums.txt" | ||
filter: | ||
- "entity.system.os == 'linux'" | ||
- "entity.system.arch == '386'" | ||
|
||
- platform: "linux" | ||
arch: "arm64" | ||
asset_filename: "#{repo}_#{version}_linux_arm64.tar.gz" | ||
sha_filename: "#{repo}_#{version}_sha512-checksums.txt" | ||
filter: | ||
- "entity.system.os == 'linux'" | ||
- "entity.system.arch == 'arm64'" | ||
|
||
- platform: "linux" | ||
arch: "armv7" | ||
asset_filename: "#{repo}_#{version}_linux_armv7.tar.gz" | ||
sha_filename: "#{repo}_#{version}_sha512-checksums.txt" | ||
filter: | ||
- "entity.system.os == 'linux'" | ||
- "entity.system.arch == 'armv7'" | ||
|
||
- platform: "OSX" | ||
arch: "amd64" | ||
asset_filename: "#{repo}_#{version}_darwin_amd64.tar.gz" | ||
sha_filename: "#{repo}_#{version}_sha512-checksums.txt" | ||
filter: | ||
- "entity.system.os == 'darwin'" | ||
- "entity.system.arch == 'amd64'" | ||
|
||
- platform: "Windows" | ||
arch: "amd64" | ||
asset_filename: "#{repo}_#{version}_windows_amd64.tar.gz" | ||
sha_filename: "#{repo}_#{version}_sha512-checksums.txt" | ||
filter: | ||
- "entity.system.os == 'windows'" | ||
- "entity.system.arch == 'amd64'" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: goreleaser | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
goreleaser: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Unshallow | ||
run: git fetch --prune --unshallow | ||
- name: Set up Go | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.13.x | ||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v1 | ||
with: | ||
version: latest | ||
args: release --rm-dist | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Go Test | ||
|
||
on: [push] | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [macos-latest, windows-latest, ubuntu-latest] | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Set up Go 1.13 | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.13 | ||
id: go | ||
- name: Test | ||
run: go test -v ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
sensu-runbook | ||
|
||
# Test binary, build with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# dep | ||
vendor/ | ||
|
||
# deploy | ||
bonsai/ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
builds: | ||
# List of builds | ||
- # First Build | ||
env: | ||
- CGO_ENABLED=0 | ||
main: main.go | ||
ldflags: '-s -w -X github.com/sensu-community/sensu-plugin-sdk/version.version={{.Version}} -X github.com/sensu-community/sensu-plugin-sdk/version.commit={{.Commit}} -X github.com/sensu-community/sensu-plugin-sdk/version.date={{.Date}}' | ||
# Set the binary output location to bin/ so archive will comply with Sensu Go Asset structure | ||
binary: bin/entrypoint | ||
goos: | ||
- darwin | ||
- linux | ||
- windows | ||
goarch: | ||
- amd64 | ||
- 386 | ||
- arm | ||
- arm64 | ||
goarm: | ||
- 5 | ||
- 6 | ||
- 7 | ||
targets: | ||
- darwin_amd64 | ||
- linux_386 | ||
- linux_amd64 | ||
- linux_arm_5 | ||
- linux_arm_6 | ||
- linux_arm_7 | ||
- linux_arm64 | ||
- windows_386 | ||
- windows_amd64 | ||
|
||
checksum: | ||
name_template: "{{ .ProjectName }}_{{ .Version }}_sha512-checksums.txt" | ||
algorithm: sha512 | ||
|
||
archives: | ||
- id: tar | ||
format: tar.gz | ||
files: | ||
- LICENSE | ||
- README.md | ||
- CHANGELOG.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) | ||
and this project adheres to [Semantic | ||
Versioning](http://semver.org/spec/v2.0.0.html). | ||
|
||
## Unreleased | ||
|
||
## [0.0.1] - 2000-01-01 | ||
|
||
### Added | ||
- Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright 2020 Sensu, Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
[![Sensu Bonsai Asset](https://img.shields.io/badge/Bonsai-Download%20Me-brightgreen.svg?colorB=89C967&logo=sensu)](https://bonsai.sensu.io/assets/calebhailey/sensu-runbook) | ||
![Go Test](https://github.com/calebhailey/sensu-runbook/workflows/Go%20Test/badge.svg) | ||
![goreleaser](https://github.com/calebhailey/sensu-runbook/workflows/goreleaser/badge.svg) | ||
|
||
# Sensu Runbook | ||
|
||
## Table of Contents | ||
|
||
- [Overview](#overview) | ||
- [Usage examples](#usage-examples) | ||
- [Configuration](#configuration) | ||
- [Sensuctl command installation](#sensuctl-command-installation) | ||
- [Installation from source](#installation-from-source) | ||
- [Additional notes](#additional-notes) | ||
- [Contributing](#contributing) | ||
|
||
## Overview | ||
|
||
Execute commands and custom scripts on Sensu Agent nodes. Sensu Go offers several unique attributes that make it a compelling runbook automation platform, including: | ||
|
||
- **Namespaces & RBAC**. Sensu Go is a multi-tenant platform, with SSO and API | ||
Keys, enabling _self-service_ runbook automation | ||
- **Secure transport**. Sensu offers TLS certificate-based auth & TLS encrypted | ||
transport | ||
- **Publish/subscribe model of communication**. No centralized system with "keys to | ||
the kingdom" to remotely access target nodes and execute arbitrary commands | ||
- [Sensu Assets][assets]. Use Sensu to securely automate distribution of custom | ||
runbook code (e.g. shell scripts or python scripts) | ||
- [Sensu Tokens][tokens]. Use Sensu's powerful templating system to create dynamic | ||
runbook automations that can scale to thousands of nodes | ||
- **Event processing**. Integrate with Slack, Pagerduty, ServiceNow, VictorOps, | ||
JIRA, and more | ||
- **Code reuse**. Reuse ad hoc runbook scripts as monitoring checks or automated | ||
remediations using Sensu Go | ||
- **Audit logging**. The runbook configuration, request, execution, and event | ||
processing are all logged by Sensu | ||
- Much, much, more... | ||
|
||
[assets]: https://docs.sensu.io/sensu-go/latest/reference/assets/ | ||
[tokens]: https://docs.sensu.io/sensu-go/latest/reference/tokens/ | ||
|
||
## Usage examples | ||
|
||
* Run as a standalone program: | ||
|
||
``` | ||
$ ./sensu-runbook --help | ||
Sensu Runbook Automation. Execute commands on Sensu Agent nodes. | ||
Usage: | ||
sensu-runbook [flags] | ||
sensu-runbook [command] | ||
Available Commands: | ||
help Help about any command | ||
version Print the version number of this plugin | ||
Flags: | ||
-a, --assets string Comma-separated list of assets to distribute with the command(s) | ||
-c, --command string The command that should be executed by the Sensu Go agent(s) | ||
-h, --help help for sensu-runbook | ||
-n, --namespace string Sensu Namespace to perform the runbook automation (defaults to $SENSU_NAMESPACE) (default "sensu-system") | ||
--sensu-access-token string Sensu API Access Token (defaults to $SENSU_ACCESS_TOKEN) | ||
--sensu-api-url string Sensu API URL (defaults to $SENSU_API_URL) (default "https://demo.sensu.io:8080") | ||
--sensu-trusted-ca-file string Sensu API Trusted Certificate Authority File (defaults to $SENSU_TRUSTED_CA_FILE) | ||
-s, --subscriptions string Comma-separated list of subscriptions to execute the command(s) on | ||
-t, --timeout string Command execution timeout, in seconds (default "10") | ||
Use "sensu-runbook [command] --help" for more information about a command. | ||
``` | ||
|
||
* Use as a [`sensuctl` command plugin][plugin]: | ||
|
||
``` | ||
$ sensuctl command install runbook calebhailey/sensu-runbook | ||
command was installed successfully | ||
$ sensuctl command exec runbook -- --help | ||
INFO[0000] asset includes builds, using builds instead of asset asset=runbook component=asset-manager entity=sensuctl | ||
Sensu Runbook Automation. Execute commands on Sensu Agent nodes. | ||
Usage: | ||
sensu-runbook [flags] | ||
sensu-runbook [command] | ||
Available Commands: | ||
help Help about any command | ||
version Print the version number of this plugin | ||
Flags: | ||
-a, --assets string Comma-separated list of assets to distribute with the command(s) | ||
-c, --command string The command that should be executed by the Sensu Go agent(s) | ||
-h, --help help for sensu-runbook | ||
-n, --namespace string Sensu Namespace to perform the runbook automation (defaults to $SENSU_NAMESPACE) (default "sensu-system") | ||
--sensu-access-token string Sensu API Access Token (defaults to $SENSU_ACCESS_TOKEN) | ||
--sensu-api-url string Sensu API URL (defaults to $SENSU_API_URL) (default "https://demo.sensu.io:8080") | ||
--sensu-trusted-ca-file string Sensu API Trusted Certificate Authority File (defaults to $SENSU_TRUSTED_CA_FILE) | ||
-s, --subscriptions string Comma-separated list of subscriptions to execute the command(s) on | ||
-t, --timeout string Command execution timeout, in seconds (default "10") | ||
Use "sensu-runbook [command] --help" for more information about a command. | ||
``` | ||
|
||
[plugin]: https://docs.sensu.io/sensu-go/latest/sensuctl/reference/#extend-sensuctl-with-commands | ||
|
||
## Configuration | ||
|
||
### Sensuctl command installation | ||
|
||
This plugin is intended for use as a [`sensuctl` command plugin][command]. If | ||
you're using sensuctl 5.13 or later, run the following command: | ||
|
||
``` | ||
sensuctl command install calebhailey/sensu-runbook | ||
``` | ||
|
||
## Installation from source | ||
|
||
The preferred way of installing and deploying this plugin is to use it as an Asset. If you would | ||
like to compile and install the plugin from source or contribute to it, download the latest version | ||
or create an executable script from this source. | ||
|
||
From the local path of the sensu-runbook repository: | ||
|
||
``` | ||
go build | ||
``` | ||
|
||
## Additional notes | ||
|
||
This plugin is in technical preview and should be considered "unstable", but | ||
feedback is welcome and appreciated! | ||
|
||
### Roadmap | ||
|
||
- Publish asset to Bonsai | ||
- Add support for `--runtime_assets` | ||
- Add support for `--handlers` | ||
- Add support for Assets (`--url` and `--sha512`) | ||
- Write a blog post! | ||
|
||
## Contributing | ||
|
||
For more information about contributing to this plugin, see [Contributing][1]. | ||
|
||
[1]: https://github.com/sensu/sensu-go/blob/master/CONTRIBUTING.md | ||
[2]: https://github.com/sensu-community/sensu-plugin-sdk | ||
[3]: https://github.com/sensu-plugins/community/blob/master/PLUGIN_STYLEGUIDE.md | ||
[4]: https://github.com/sensu-community/check-plugin-template/blob/master/.github/workflows/release.yml | ||
[5]: https://github.com/sensu-community/check-plugin-template/actions | ||
[6]: https://docs.sensu.io/sensu-go/latest/reference/checks/ | ||
[7]: https://github.com/sensu-community/check-plugin-template/blob/master/main.go | ||
[8]: https://bonsai.sensu.io/ | ||
[9]: https://github.com/sensu-community/sensu-plugin-tool | ||
[10]: https://docs.sensu.io/sensu-go/latest/reference/assets/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/sh | ||
|
||
REQUIRED_ARGS=1 | ||
PROVIDED_ARGS=$# | ||
VERSION=$1 | ||
|
||
check_args() { | ||
if [ "$REQUIRED_ARGS" != "$PROVIDED_ARGS" ]; | ||
then | ||
echo "\nERROR: too few arguments. Please provide a version number.\n" | ||
echo "" | ||
echo "Example usage:" | ||
echo "" | ||
echo "$ build.sh 0.1.0" | ||
echo "" | ||
exit 1 | ||
fi | ||
return 0 | ||
} | ||
|
||
generate_asset() { | ||
if [[ -d bin ]]; then | ||
rm -rf bin | ||
fi | ||
mkdir bin | ||
cp sensu-runbook bin/entrypoint | ||
tar -czf sensu-runbook-${VERSION}.tar.gz bin | ||
rm -rf bin | ||
} | ||
|
||
check_args | ||
generate_asset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module github.com/calebhailey/sensu-runbook | ||
|
||
go 1.13 | ||
|
||
require ( | ||
github.com/google/uuid v1.1.1 | ||
github.com/sensu-community/sensu-plugin-sdk v0.6.0 | ||
github.com/sensu/sensu-go v0.0.0-20200131164840-40b1d5938251 | ||
) |
Oops, something went wrong.