Skip to content

Instantly share code, notes, and snippets.

@sandromello
Last active July 18, 2023 14:09
Show Gist options
  • Save sandromello/ff10a067304638efc0e460ebe91b48df to your computer and use it in GitHub Desktop.
Save sandromello/ff10a067304638efc0e460ebe91b48df to your computer and use it in GitHub Desktop.
hoopagent-secretsmanager.md

On a Linux VM

  1. Install the cli
curl -s -L https://releases.hoop.dev/release/install-cli.sh | sh
  1. Create the systemd unit

Make sure to create the token in your local machine (hoop admin create agent linux-vm) and change the mysql configuration

cat - >/etc/systemd/system/hoopagent.service <<EOF
[Unit]
Description=Hoop Agent
After=network.target

[Service]
ExecStart=hoop start agent
Environment="HOME=/root"
Environment="HOOP_TOKEN=<AGENT_TOKEN>"
Environment="HOOP_GRPCURL=app.hoop.dev:8443"
Environment='MYSQL_CONFIG={"HOST": "<HOST>", "PORT": "3306", "USER": "<USER>", "PASS": "<PASS>"}'
StandardOutput=true
Restart=on-failure
RestartSec=10s

[Install]
WantedBy=multi-user.target
EOF
  1. start the agent
systemctl daemon-reload
systemctl enable hoopagent.service
systemctl start hoopagent

Make sure to install a mysql client, on ubuntu: apt-get update -y && apt-get install -y default-mysql-client

On Your Local Machine

  1. Login
hoop login
  1. Enable the secretsmanager plugin
hoop admin create plugin secretsmanager \
    --connection mysql-utm \
    --source hoop/secretsmanager \
    --overwrite
  1. Associate a new connection with the secrets manager plugin
hoop admin create connection mysql-utm --agent linux-vm \
    -e HOST=envjson:MYSQL_CONFIG:HOST \
    -e PORT=envjson:MYSQL_CONFIG:PORT \
    -e USER=envjson:MYSQL_CONFIG:USER \
    -e MYSQL_PWD=envjson:MYSQL_CONFIG:PASS \
    --plugin secretsmanager \
    --overwrite -- mysql -h '$HOST' --port '$PORT' -u '$USER'
  1. Connect it
hoop connect mysql-utm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment