generated from jiuka/checkmk_template
-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit 26443f7
Showing
19 changed files
with
396 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,18 @@ | ||
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.155.1/containers/ubuntu/.devcontainer/base.Dockerfile | ||
|
||
# [Choice] CheckMK version: 2.2.0-latest | ||
ARG VARIANT="2.2.0-latest" | ||
FROM checkmk/check-mk-raw:${VARIANT} | ||
|
||
RUN /docker-entrypoint.sh /bin/true | ||
|
||
# [Optional] Uncomment this section to install additional OS packages. | ||
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ | ||
&& apt-get -y install --no-install-recommends nodejs gcc | ||
|
||
ADD requirements.txt /tmp/requirements.txt | ||
RUN PATH="/omd/sites/cmk/bin:${PATH}" \ | ||
OMD_ROOT="/omd/sites/cmk" \ | ||
/omd/sites/cmk/bin/pip3 install -r /tmp/requirements.txt | ||
|
||
ENTRYPOINT ["/bin/bash"] |
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 @@ | ||
#!/bin/bash | ||
|
||
NAME=$(python3 -c 'print(eval(open("package").read())["name"])') | ||
VERSION=$(python3 -c 'print(eval(open("package").read())["version"])') | ||
rm -f $NAME-$VERSION.mkp \ | ||
/omd/sites/cmk/var/check_mk/packages/${NAME}-*.mkp \ | ||
/omd/sites/cmk/var/check_mk/packages_local/${NAME}-*.mkp ||: | ||
|
||
mkp -v package package 2>&1 | sed '/Installing$/Q' ||: | ||
|
||
cp /omd/sites/cmk/var/check_mk/packages_local/$NAME-$VERSION.mkp . | ||
|
||
mkp inspect $NAME-$VERSION.mkp | ||
|
||
# Set Outputs for GitHub Workflow steps | ||
if [ -n "$GITHUB_WORKSPACE" ]; then | ||
echo "pkgfile=${NAME}-${VERSION}.mkp" >> $GITHUB_OUTPUT | ||
echo "pkgname=${NAME}" >> $GITHUB_OUTPUT | ||
echo "pkgversion=$VERSION" >> $GITHUB_OUTPUT | ||
fi |
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,48 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: | ||
// https://github.com/microsoft/vscode-dev-containers/tree/v0.155.1/containers/ubuntu | ||
{ | ||
"name": "Checkmk", | ||
"build": { | ||
"dockerfile": "Dockerfile", | ||
// Update 'VARIANT' to pick an Ubuntu version: focal, bionic | ||
"args": { "VARIANT": "2.2.0-latest" } | ||
}, | ||
|
||
"customizations": { | ||
"vscode": { | ||
// Add the IDs of extensions you want installed when the container is created. | ||
"extensions": [ | ||
"ms-python.python", | ||
"ms-python.flake8", | ||
"littlefoxteam.vscode-python-test-adapter" | ||
], | ||
|
||
// Set *default* container specific settings.json values on container create. | ||
"settings": { | ||
"terminal.integrated.defaultProfile.linux": "bash", | ||
"python.defaultInterpreterPath": "/omd/sites/cmk/bin/python3" | ||
} | ||
} | ||
}, | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
"postCreateCommand": ".devcontainer/symlink.sh", | ||
|
||
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. | ||
"remoteUser": "cmk", | ||
|
||
// Uncomment to use with podman | ||
//"containerUser": "cmk", | ||
//"runArgs": ["--userns=keep-id"], | ||
|
||
"remoteEnv": { | ||
"PATH": "/omd/sites/cmk/bin:/omd/sites/cmk/local/lib/python3/bin/:${containerEnv:PATH}", | ||
"OMD_ROOT": "/omd/sites/cmk", | ||
"OMD_SITE": "cmk", | ||
"CMK_SITE_ID": "cmk", | ||
"WORKSPACE": "${containerWorkspaceFolder}" | ||
} | ||
} |
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,4 @@ | ||
flake8 | ||
pytest | ||
pytest-cov | ||
requests-mock |
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,15 @@ | ||
#!/bin/bash | ||
|
||
for DIR in 'agents' 'checkman' 'checks' 'doc' 'inventory' 'notifications' 'pnp-templates' 'web'; do | ||
rm -rfv $OMD_ROOT/local/share/check_mk/$DIR | ||
ln -sv $WORKSPACE/$DIR $OMD_ROOT/local/share/check_mk/$DIR | ||
done; | ||
|
||
rm -rfv $OMD_ROOT/local/lib/python3/cmk/base/plugins/agent_based | ||
ln -sv $WORKSPACE/agent_based $OMD_ROOT/local/lib/python3/cmk/base/plugins/agent_based | ||
|
||
mkdir -p $OMD_ROOT/local/lib/python3/cmk/base/cee/plugins | ||
ln -sv $WORKSPACE/bakery $OMD_ROOT/local/lib/python3/cmk/base/cee/plugins/bakery | ||
|
||
rm -rfv $OMD_ROOT/local/lib/nagios/plugins | ||
ln -sv $WORKSPACE/nagios_plugins $OMD_ROOT/local/lib/nagios/plugins |
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,11 @@ | ||
# DO NOT EDIT - Change template-sync.conf | ||
include .devcontainer/ | ||
include .devcontainer/** | ||
exclude .github/template-sync.conf | ||
include .github/ | ||
include .github/** | ||
include .vscode/ | ||
include .vscode/** | ||
include .flake8 | ||
include .gitignore | ||
include .gitattributes |
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,4 @@ | ||
# Add additional sync excludes for this repo | ||
#exclude .github/do-not-sync | ||
#exclude .flake8 | ||
#exclude .gitignore |
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,23 @@ | ||
#!/usr/bin/bash | ||
|
||
TEMPDIR=$(mktemp -d) | ||
|
||
cleanup() { | ||
echo "Removing $TEMPDIR" | ||
rm -rf $TEMPDIR | ||
} | ||
trap cleanup EXIT | ||
|
||
git -C $TEMPDIR clone https://github.com/jiuka/checkmk_template.git | ||
|
||
CMD="rsync --archive --cvs-exclude --no-owner --no-group --no-times --verbose" | ||
if [ -e ".devcontainer/template-sync.conf" ]; then | ||
CMD="${CMD} --filter='merge .devcontainer/template-sync.conf'" | ||
fi | ||
if [ -e "${TEMPDIR}/checkmk_template/.devcontainer/template-sync-includes.conf" ]; then | ||
CMD="${CMD} --filter='merge ${TEMPDIR}/checkmk_template/.devcontainer/template-sync-includes.conf'" | ||
fi | ||
CMD="${CMD} --filter='exclude *' ${TEMPDIR}/checkmk_template/ $(pwd)/" | ||
bash -c "$CMD" | ||
|
||
echo $CMD |
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,12 @@ | ||
[flake8] | ||
# In .style.yapf and .pylintrc we use 100, but in some cases this isn't enforced. | ||
max-line-length=550 | ||
ignore= | ||
################################################################################################ | ||
# Miscellaneous stuff | ||
################################################################################################ | ||
################################################################################################ | ||
# Incompatible with YAPF | ||
################################################################################################ | ||
# unexpected spaces around keyword / parameter equals | ||
E251, |
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,2 @@ | ||
# Set the default behavior | ||
* text=auto eol=lf |
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,42 @@ | ||
name: build-release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
- '!v*[a-z]' | ||
|
||
jobs: | ||
build-release: | ||
name: Build Release Package | ||
runs-on: ubuntu-latest | ||
container: | ||
image: checkmk/check-mk-raw:2.2.0-latest | ||
permissions: | ||
contents: write | ||
|
||
env: | ||
OMD_ROOT: /omd/sites/cmk | ||
OMD_SITE: cmk | ||
CMK_SITE_ID: cmk | ||
WORKSPACE: ${{ github.workspace }} | ||
|
||
steps: | ||
- name: Initialize Checkmk Site | ||
run: /docker-entrypoint.sh /bin/true | ||
- uses: actions/checkout@v3 | ||
- name: Setup links | ||
run: .devcontainer/symlink.sh | ||
- name: Update GITHUB_PATH | ||
run: echo "/omd/sites/cmk/bin" >> $GITHUB_PATH | ||
- name: Build Extension | ||
run: .devcontainer/build.sh | ||
id: cmkpkg | ||
|
||
- name: Create Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
release_name: Release ${{ github.ref }} | ||
draft: false | ||
prerelease: false | ||
files: ${{ steps.cmkpkg.outputs.pkgfile }} |
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,39 @@ | ||
name: build | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
tags-ignore: | ||
- 'v*' | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
name: Build Checkmk package | ||
runs-on: ubuntu-latest | ||
container: | ||
image: checkmk/check-mk-raw:2.2.0-latest | ||
|
||
env: | ||
OMD_ROOT: /omd/sites/cmk | ||
OMD_SITE: cmk | ||
CMK_SITE_ID: cmk | ||
WORKSPACE: ${{ github.workspace }} | ||
|
||
steps: | ||
- name: Initialize Checkmk Site | ||
run: /docker-entrypoint.sh /bin/true | ||
- uses: actions/checkout@v3 | ||
- name: Setup links | ||
run: .devcontainer/symlink.sh | ||
- name: Update GITHUB_PATH | ||
run: echo "/omd/sites/cmk/bin" >> $GITHUB_PATH | ||
- name: Build Extension | ||
run: .devcontainer/build.sh | ||
id: cmkpkg | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ steps.cmkpkg.outputs.pkgfile }} | ||
path: ${{ steps.cmkpkg.outputs.pkgfile }} |
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,22 @@ | ||
name: Lint | ||
|
||
on: | ||
push: | ||
paths: | ||
- '**.py' | ||
|
||
jobs: | ||
flake8_py3: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.9 | ||
- name: Install flake8 | ||
run: pip install flake8 | ||
- name: Run flake8 | ||
uses: py-actions/flake8@v2 |
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,30 @@ | ||
name: pytest | ||
|
||
on: | ||
push: [] | ||
|
||
jobs: | ||
pytest: | ||
|
||
runs-on: ubuntu-latest | ||
container: | ||
image: checkmk/check-mk-raw:2.2.0-latest | ||
|
||
env: | ||
OMD_ROOT: /omd/sites/cmk | ||
OMD_SITE: cmk | ||
CMK_SITE_ID: cmk | ||
WORKSPACE: ${{ github.workspace }} | ||
|
||
steps: | ||
- name: Initialize Checkmk Site | ||
run: /docker-entrypoint.sh /bin/true | ||
- uses: actions/checkout@v3 | ||
- name: Setup links | ||
run: ./.devcontainer/symlink.sh | ||
- name: Install pytest | ||
run: su -l -c "REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt pip3 install -r $GITHUB_WORKSPACE/.devcontainer/requirements.txt" cmk | ||
- name: Update GITHUB_PATH | ||
run: echo "/omd/sites/cmk/bin" >> $GITHUB_PATH | ||
- name: Run pytest | ||
run: python3 -m pytest |
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,4 @@ | ||
*.mkp | ||
.coverage | ||
__pycache__ | ||
debug.log |
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 @@ | ||
{ | ||
"python.linting.flake8Enabled": true, | ||
"python.linting.enabled": true, | ||
"python.testing.pytestArgs": [ | ||
"." | ||
], | ||
"python.testing.unittestEnabled": false, | ||
"python.testing.pytestEnabled": true, | ||
"files.associations": { | ||
"package": "python" | ||
}, | ||
"python.defaultInterpreterPath": "/omd/sites/cmk/bin/python3" | ||
} |
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,35 @@ | ||
{ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "Install", | ||
"type": "shell", | ||
"command": ".devcontainer/build.sh", | ||
"problemMatcher": [], | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
} | ||
}, | ||
{ | ||
"label": "Start Site", | ||
"type": "shell", | ||
"command": "omd start", | ||
"problemMatcher": [] | ||
}, | ||
{ | ||
"label": "Re-Start Site", | ||
"type": "shell", | ||
"command": "omd restart", | ||
"problemMatcher": [] | ||
}, | ||
{ | ||
"label": "Stop Site", | ||
"type": "shell", | ||
"command": "omd stop", | ||
"problemMatcher": [] | ||
} | ||
] | ||
} |
Oops, something went wrong.