Skip to content

Commit

Permalink
add packaging config
Browse files Browse the repository at this point in the history
  • Loading branch information
dhollinger committed Oct 10, 2022
1 parent e3d407e commit dbf1497
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 32 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ config.yml
*.7z
*.exe
*.bin
webhook-go*
webhook.yml

bin/
dist/


22 changes: 22 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,28 @@ builds:
goarch: arm
- goos: windows
goarch: arm64
nfpms:
- vendor: Vox Pupuli
homepage: https://github.com/voxpupuli/webhook-go
maintainer: Vox Pupuli <[email protected]>
description: |-
Puppet Webhook API server written in Go.
Designed to provide a web api that can receive
webhooks from VCS services such as GitHub, GitLab, etc
and execute r10k deployments
license: Apache 2.0
formats:
- deb
- rpm
contents:
- src: build/webhook.yml
dst: /etc/voxpupuli/webhook.yml
type: "config|noreplace"
- src: build/webhook-go.service
dst: /etc/systemd/system/webhook-go.service
scripts:
postinstall: "build/post-install.sh"
postremove: "build/post-remove.sh"
release:
github:
owner: voxpupuli
Expand Down
41 changes: 41 additions & 0 deletions build/post-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/sh

cleanInstall() {
printf "\033[32m Post Install of an clean install\033[0m\n"
printf "\033[32m Reload the service unit from disk\033[0m\n"
systemctl daemon-reload ||:
printf "\033[32m Unmask the service\033[0m\n"
systemctl unmask webhook-go.service ||:
printf "\033[32m Set the preset flag for the service unit\033[0m\n"
systemctl preset webhook-go.service ||:
printf "\033[32m Start the service with systemctl start webhook-go.service\033[0m\n"
printf "\033[32m Enable the service with systemctl enable webhook-go.service\033[0m\n"
}

upgrade() {
printf "\033[32m Post Install of an upgrade\033[0m\n"
}

# Step 2, check if this is a clean install or an upgrade
action="$1"
if [ "$1" = "configure" ] && [ -z "$2" ]; then
action="install"
elif [ "$1" = "configure" ] && [ -n "$2" ]; then
action="upgrade"
fi

case "$action" in
"1" | "install")
cleanInstall
;;
"2" | "upgrade")
printf "\033[32m Post Install of an upgrade\033[0m\n"
upgrade
;;
*)
# $1 == version being installed
printf "\033[32m Alpine\033[0m"
cleanInstall
;;
esac

39 changes: 39 additions & 0 deletions build/post-remove.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/sh

remove() {
printf "\033[32m removing webhook-go\033[0m\n"
systemctl stop webhook-go.service
systemctl disable webhook-go.service
rm -rf /etc/systemd/system/webhook-go.service
systemctl daemon-reload
}

purge() {
printf "\033[32m Purgins config files\033[0m\n"
rm -rf /etc/voxpupuli/webhook.yml
}

upgrade() {
echo ""
}

echo "$@"

action="$1"

case "$action" in
"0" | "remove")
remove
;;
"1" | "upgrade")
upgrade
;;
"purge")
purge
;;
*)
printf "\033[32m Alpine\033[0m"
remove
;;
esac

14 changes: 14 additions & 0 deletions build/webhook-go.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=Puppet Deployment API Server
After=network.target
Documentation=https://github.com/voxpupuli/webhook-go

[Service]
Environment=GIN_MODE=release
ExecStart=/usr/bin/webhook-go server --config /etc/voxpupuli/webhook.yml
ExecReload=/bin/kill -HUP $PID
KillMode=process

[Install]
WantedBy=multi-user.target
Alias=webhook-go.service
30 changes: 30 additions & 0 deletions build/webhook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
server:
protected: true
user: puppet
password: puppet
port: 4000
tls:
enabled: false
certificate: ""
key: ""
# chatops:
# enabled: false
# service: slack
# channel: "#general"
# user: r10kbot
# auth_token: 12345
# server_uri: "https://rocketchat.local"
r10k:
config_path: /etc/puppetlabs/r10k/r10k.yaml
# default_branch: webhook_test
allow_uppercase: false
verbose: true
# orchestration:
# enabled: false
# type: bolt
# user: dhollinger
# bolt:
# transport: local
# targets:
# - localhost
# host_key_check: false
30 changes: 0 additions & 30 deletions webhook.yml.example

This file was deleted.

0 comments on commit dbf1497

Please sign in to comment.