Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitLab Instruction doc #39

Merged
merged 5 commits into from
Jul 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

# Step 2: use the versioned sensu/sensuflow action
# Step 2: use the versioned sensu/sensu-flow action
- name: Sensuflow with required settings
uses: sensu/[email protected]
with:
Expand Down Expand Up @@ -260,9 +260,14 @@ _OR_
description: Optional boolean argument to to disable sanity checks default: false


## Adapting to Other CI/CD Workflows
If you would like to adapt this for other CI/CD workflows, take a look at the sensuflow.sh script from this repositorory. The script should be self-documenting with regard to needed executable dependancies and information concerning environment variables used.
## Using the Docker container image with other CI/CD tools
While this is originally developed and tested for use with GitHub Actions, there is a vendor neutral `sensu/sensu-flow` [Docker](https://hub.docker.com/repository/docker/sensu/sensu-flow) container image available as of version `0.6.0` that should be suitable for use with any CI/CD tool chain that is capable of using container images for CI/CD jobs. Here's a list of contributed instructions for alternative CI/CD vendors:


* [GitLab](docs/GITLAB.md)

Contributed instructions for additional CI/CD services are welcome.

## Goals

SensuFlow is under active development, so please don't hesitate to submit issues for any enhancements you'd like to see.
Expand Down
50 changes: 50 additions & 0 deletions docs/GITLAB.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
## GitLab
You can use the `sensu/sensu-flow` [Docker container image](https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#define-image-in-the-gitlab-ciyml-file) with GitLab. This container image includes everything needed to run the `sensuflow.sh` script originally developed for GitHub actions. Please note, it's a good idea to use GitLab's support for [Vault Secrets](https://docs.gitlab.com/ee/ci/yaml/index.html#secrets) for sensitive authentication variables such as the Sensu api key or password.

### Important environment variables
When using the docker image with GitLab, you'll need to be aware of several environment variables used by the `sensuflow.sh` script run within the Docker container. These variables are documented in the `sensuflow.sh` header comments, but here's a quick summary for reference.

```
## Required Environment Variables
# SENSU_API_URL: sensu backend api url used by sensuctl
# SENSU_API_KEY: sensu api key for sensuctl, used instead of user and password above
## Optional Environment Variables
# SENSU_CA: CA certificate as a string
# SENSU_CA_FILE: CA certificate file, if set overrides SENSU_CA
# CONFIGURE_OPTIONS: Additional sensuctl configure options
# NAMESPACES_DIR: directory holding sensuflow namepace subdirectories
# NAMESPACES_FILE: file holding namespace resource definitions sensuflow action should create
# MANAGED_RESOURCES: comma seperated list of resources
# MATCHING_LABEL: resource label to match
# MATCHING_CONDITION: condition to match
# DISABLE_SANITY_CHECKS: if set disable sanity checks
# DISABLE_TLS_VERIFY: if set disable TLS verification
## Deprecated Authentication Environment Variables
# SENSU_USER: sensu user for sensuctl configue (deprecated, use SENSU_API_KEY)
# SENSU_PASSWORD: sensu password for sensuctl configure (deprecated, use SENSU_API_KEY)
```

### Reference GitLab CI/CD job definition
Here's a reference example for a GitLab CI/CD job definition making use of the `sensu/sensu-flow` docker image together with an api-key seeded into a vault.
```
stages:
- deploy

.sensu_flow:
image: sensu/sensu-flow:latest
variables:
MATCHING_CONDITION: "== '$CI_PROJECT_NAME'"
SENSU_BACKEND_URL: https://sensu-api.example.com
secrets:
SENSU_API_KEY:
vault: sensu/sensu-flow/api-key
file: false
script:
- /sensuflow.sh

sensu_flow:
extends: .sensu_flow
stage: deploy
variables:
VERBOSE: "1"
```
7 changes: 4 additions & 3 deletions sensuflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
# jq: https://stedolan.github.io/jq/
#
## Required Environment Variables
# SENSU_USER: sensu user for sensuctl configure
# SENSU_PASSWORD: sensu password for sensuctl configure
# SENSU_API_KEY: sensu api key for sensuctl, used instead of user and password above
# SENSU_API_URL: sensu backend api url used by sensuctl
# SENSU_API_KEY: sensu api key for sensuctl, used instead of user and password above
## Optional Environment Variables
# SENSU_CA: CA certificate as a string
# SENSU_CA_FILE: CA certificate file, if set overrides SENSU_CA
Expand All @@ -23,6 +21,9 @@
# MATCHING_CONDITION: condition to match
# DISABLE_SANITY_CHECKS: if set disable sanity checks
# DISABLE_TLS_VERIFY: if set disable TLS verification
## Deprecated Authentication Environment Variables
# SENSU_USER: sensu user for sensuctl configue (deprecated, use SENSU_API_KEY)
# SENSU_PASSWORD: sensu password for sensuctl configure (deprecated, use SENSU_API_KEY)

## GitHub Action Notes
# GitHub Actions prefaces variables with INPUT_
Expand Down