Skip to content

stuttgart-things/machineshop

Repository files navigation

stuttgart-things/machineshop

git based CLI interface for managing configuration as code

FEATURES

  • RENDER TEMPLATES w/ DEFAULTS AND PARAMETERS (RENDER)
  • INSTALL MULTIPLE BINARIES FROM WEB SOURCES AT ONCE/IN PARALLEL (INSTALL)
  • RENDER + EXECUTE MULTIPLE SCRIPTS (INSTALL)
  • RETRIEVE SECRETS FROM VAULT (GET)

DEPLOYMENT

BINARY BY RELEASE
# LINUX x86_64
VERSION=v1.9.0
wget https://github.com/stuttgart-things/machineshop/releases/download/${VERSION}/machineshop_Linux_x86_64.tar.gz
tar xvfz machineshop_Linux_x86_64.tar.gz
sudo mv machineshop /usr/bin/machineshop
rm -rf LICENSE README.md
sudo chmod +x /usr/bin/machineshop
machineshop version
CONTAINER IMAGE
# RUN COMMAND
sudo nerdctl run ghcr.io/stuttgart-things/machineshop/machineshop-9c3178088556daa12a17db5edcc6b5b7:1.9.10 version
# JUMP INTO SHELL
nerdctl run -it --entrypoint bash \
ghcr.io/stuttgart-things/machineshop/machineshop-9c3178088556daa12a17db5edcc6b5b7:1.9.10

DEV

CREATE BRANCH
task branch
CREATE PULL-REQUEST/MERGE
task pr
BUILD RELEASE
task release TAG=v1.8.0 # EXAMPLE VERSION
BUILD CONTAINER-IMAGE w/ KO
task ko TAG=v1.9.0 # EXAMPLE VERSION

USAGE EXAMPLES

CREATE

creates things on github

REPOSITORY
export GITHUB_TOKEN=<GITHUB_TOKEN>

machineshop create \
--kind repo \
--group stuttgart-things \
--repository machineshop2 \
--message "test repository - machineshop" \
--private true
BRANCH
export GITHUB_TOKEN=<GITHUB_TOKEN>

machineshop create \
--kind branch \
--branch hello \
--repository machineshop \
--group stuttgart-things \
--files "Dockerfile:Dockerfile" \
PULL-REQUEST
export GITHUB_TOKEN=<GITHUB_TOKEN>

machineshop create \
--kind pr \
--title test2 \
--branch hello \
--repository machineshop \
--group stuttgart-things
MERGE
export GITHUB_TOKEN=<GITHUB_TOKEN>

machineshop create \
--kind merge \
--group stuttgart-things \
--repository stuttgart-things \
--message "test" \
--merge rebase \
--id 243

PUSH

push things to targets

MINIO (BUCKET)
export MINIO_ACCESS_KEY=sthings
export MINIO_SECRET_KEY=<PASSWORD>
export MINIO_ADDR=artifacts.automation.sthings-vsphere.labul.sva.de
export MINIO_SECURE=true

machineshop push \
--target minio \
--source pod.yaml \
--destination manifests:pod-example.yaml # <BUCKET>:<OBECTNAME>
MS TEAMS
WEBHOOK_URL=https://365sva.webhook...

machineshop push \
--target teams \
--source "hello from machineshop cli" \
--destination ${WEBHOOK_URL} \
--color blue

RENDER

render things from templates from various input sources

EXAMPLE TEMPLATE
---
runs:
  packagePublishHelmChart:
    # FLAT VALUE
    name: package-publish-{{ .chartName }}

# LOOP OVER LIST
{{ range .food }}
- {{ . }}{{ end }}

# RANDOM ELEMENT FROM EXISTING LIST
favoriteFood: {{ .RANDOMfood }}
EXAMPLE DEFAULTS FILE
---
chartName: helloHelm
food:
  - schnitzel
  - apple
  - hamburger
LOCAL
machineshop render \
--source local \
--template ../golang/machineshop/tests/template-square.yaml \
--brackets square \
--output stdout \
--defaults /home/sthings/projects/stuttgart-things/packer/environments/labul-pve.yaml
GIT
machineshop render --source git \
--git https://github.com/stuttgart-things/stuttgart-things.git \
--defaults packer/environments/labul-vsphere.yaml \
--template packer/os/ubuntu23-vsphere.pkr.tpl.hcl \
--output stdout

DELETE

delete things on git(hub)

BRANCH
export GITHUB_TOKEN=<GITHUB_TOKEN>

machineshop delete \
--kind branch \
--branch hello \
--repository stuttgart-things \
--group stuttgart-things
FILES
export GITHUB_TOKEN=<GITHUB_TOKEN>

machineshop delete \
--kind files \
--branch main \
--repository stuttgart-things \
--group stuttgart-things \
--files ".github/workflows/lint-k8s-manifests.yaml" \
--user patrick-hermann-sva

GET

get things from systems

REQUIREMENT: VAULT APPROLE EXPORTS
export VAULT_NAMESPACE=root
export VAULT_ROLE_ID=1d42d7e7-8c14-e5f9-801d-b3ecef416616
export VAULT_SECRET_ID=623c991f-dd76-c437-2723-bb2ef5b02d87
export VAULT_ADDR=https://≤VAULT_ADDR>[:8200]
GET SECRET VALUE BY PATH
machineshop get --path apps/data/scr:password | tail -n +8

machineshop get --path apps/data/scr:password --output file --destination /tmp/password.txt

machineshop get --path kubeconfigs/data/dev21:kubeconfig --output file --destination /tmp/dev211 --b64 true

LICENSE

APACHE 2.0

Copyright 2023 patrick hermann.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Author Information

Patrick Hermann, stuttgart-things 05/2023