hashipi

Raspberry Pi Test Cluster for HashiCorp Vault, Nomad and Consul
git clone https://git.in0rdr.ch/hashipi.git
Log | Files | Refs | README

commit 81c6c9c9476a7c015b09ef2198e29895586fb2f2
parent c62fe4a76298087edef2df5f970e4d3c31a440c2
Author: Andreas Gruhler <andreas.gruhler@adfinis.com>
Date:   Sun,  4 Jun 2023 12:47:49 +0200

feat: use HC distribution pkgs

Diffstat:
Mbootstrap.sh | 9++++++++-
Mconsul.sh | 42+-----------------------------------------
Mhashi-pi.json | 25++++++++-----------------
Dhashicorp.asc | 122-------------------------------------------------------------------------------
Mnomad.sh | 52+---------------------------------------------------
Mvault.sh | 66++++--------------------------------------------------------------
6 files changed, 22 insertions(+), 294 deletions(-)

diff --git a/bootstrap.sh b/bootstrap.sh @@ -25,9 +25,16 @@ chmod +x /tmp/resizerootfs mv /tmp/resizerootfs /usr/sbin/ systemctl enable resizerootfs.service +# Add HashiCorp repository +wget -O- https://apt.releases.hashicorp.com/gpg \ + | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg +echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" \ + | tee /etc/apt/sources.list.d/hashicorp.list + # Install packages apt-get update -DEBIAN_FRONTEND=noninteractive apt-get install -y jq podman cloud-init +DEBIAN_FRONTEND=noninteractive apt-get install -y jq podman cloud-init \ + "consul=${CONSUL_VERSION}-1" "vault=${VAULT_VERSION}-1" "nomad=${NOMAD_VERSION}-1" # Configure insecure local registry cat << EOF > /etc/containers/registries.conf diff --git a/consul.sh b/consul.sh @@ -7,26 +7,8 @@ # set -o nounset set -o xtrace -CONSUL_URL="https://releases.hashicorp.com/consul" - cd "/home/${USERNAME}" -# Download Consul binary and checksums -curl -sS -O "${CONSUL_URL}/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_${CONSUL_ARCH}.zip" -curl -sS -O "${CONSUL_URL}/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_SHA256SUMS" -curl -sS -O "${CONSUL_URL}/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_SHA256SUMS.sig" - -# Verify signature and zip archive -gpg --import "hashicorp.asc" -gpg --verify "consul_${CONSUL_VERSION}_SHA256SUMS.sig" "consul_${CONSUL_VERSION}_SHA256SUMS" -sha256sum -c "consul_${CONSUL_VERSION}_SHA256SUMS" --ignore-missing - -# Install binary -unzip "consul_${CONSUL_VERSION}_linux_${CONSUL_ARCH}.zip" -chown root: consul -mv consul /usr/local/bin/ -consul --version - # Move uploaded tls files mkdir -p /opt/consul/tls mv /tmp/tls/* /opt/consul/tls/ @@ -43,6 +25,7 @@ chmod 644 /opt/consul/tls/consul-agent-ca.pem # Create Consul config files mkdir -p /etc/consul.d +rm -rf /etc/consul.d/* cat << EOF > /etc/consul.d/consul.hcl datacenter = "dc1" @@ -103,29 +86,6 @@ tls { } EOF -# Configure systemd service unit -cat << EOF > /etc/systemd/system/consul.service -[Unit] -Description="HashiCorp Consul - A service mesh solution" -Documentation=https://www.consul.io/ -Requires=network-online.target -After=network-online.target -ConditionFileNotEmpty=/etc/consul.d/consul.hcl - -[Service] -Type=notify -User=consul -Group=consul -ExecStart=/usr/local/bin/consul agent -config-dir=/etc/consul.d/ -ExecReload=/usr/local/bin/consul reload -KillMode=process -Restart=on-failure -LimitNOFILE=65536 - -[Install] -WantedBy=multi-user.target -EOF - systemctl enable consul # Configure .bashrc diff --git a/hashi-pi.json b/hashi-pi.json @@ -8,23 +8,21 @@ "flash_device_path": null, "img_size": "3G", "consul_version": "1.15.2", - "consul_arch": "arm64", "consul_encrypt": null, "consul_tls_ca": null, "consul_tls_certs": null, "consul_retry_join": "\"HashiPi0\", \"HashiPi1\", \"HashiPi2\"", "nomad_version": "1.5.5", - "nomad_arch": "arm64", "nomad_nfs_server": "", "nomad_nfs_mount": "", "nomad_nfs_target": "", "vault_version": "1.13.2", - "vault_arch": "arm64", "vault_tls_ca_cert": "./tls/vault/ca/vault_ca.pem", "vault_tls_ca_key": "./tls/vault/ca/vault_ca.key", "vault_tls_subj_alt_name": "IP:127.0.0.1", "vault_transit_server": null, - "vault_transit_token": null + "vault_transit_token": null, + "cilium_version": "1.13.2" }, "sensitive-variables": [ "consul_encrypt", @@ -83,15 +81,13 @@ "environment_vars": [ "HOSTNAME={{ user `hostname` }}", "USERNAME={{ user `username` }}", - "AUTHORIZED_KEYS={{ user `authorized_keys` }}" + "AUTHORIZED_KEYS={{ user `authorized_keys` }}", + "NOMAD_VERSION={{ user `nomad_version` }}", + "CONSUL_VERSION={{ user `consul_version` }}", + "VAULT_VERSION={{ user `vault_version` }}" ] }, { - "type": "file", - "source": "hashicorp.asc", - "destination": "/home/{{ user `username` }}/hashicorp.asc" - }, - { "type": "shell", "inline": ["mkdir /tmp/tls"] }, @@ -111,8 +107,6 @@ "remote_folder": "/home/{{ user `username` }}", "environment_vars": [ "USERNAME={{ user `username` }}", - "CONSUL_VERSION={{ user `consul_version` }}", - "CONSUL_ARCH={{ user `consul_arch` }}", "CONSUL_ENCRYPT={{ user `consul_encrypt` }}", "CONSUL_RETRY_JOIN={{ user `consul_retry_join` }}" ] @@ -123,11 +117,10 @@ "remote_folder": "/home/{{ user `username` }}", "environment_vars": [ "USERNAME={{ user `username` }}", - "NOMAD_VERSION={{ user `nomad_version` }}", - "NOMAD_ARCH={{ user `nomad_arch` }}", "NFS_SERVER={{ user `nomad_nfs_server` }}", "NFS_MOUNT={{ user `nomad_nfs_mount` }}", - "NFS_MOUNT_TARGET={{ user `nomad_nfs_target` }}" + "NFS_MOUNT_TARGET={{ user `nomad_nfs_target` }}", + "CILIUM_VERSION={{ user `cilium_version` }}" ] }, { @@ -147,8 +140,6 @@ "environment_vars": [ "USERNAME={{ user `username` }}", "HOSTNAME={{ user `hostname` }}", - "VAULT_VERSION={{ user `vault_version` }}", - "VAULT_ARCH={{ user `vault_arch` }}", "VAULT_TLS_CA_CERT=/tmp/vault_ca.pem", "VAULT_TLS_CA_KEY=/tmp/vault_ca.key", "VAULT_TLS_SUBJ_ALT_NAME={{ user `vault_tls_subj_alt_name` }}", diff --git a/hashicorp.asc b/hashicorp.asc @@ -1,122 +0,0 @@ ------BEGIN PGP PUBLIC KEY BLOCK----- - -mQINBGB9+xkBEACabYZOWKmgZsHTdRDiyPJxhbuUiKX65GUWkyRMJKi/1dviVxOX -PG6hBPtF48IFnVgxKpIb7G6NjBousAV+CuLlv5yqFKpOZEGC6sBV+Gx8Vu1CICpl -Zm+HpQPcIzwBpN+Ar4l/exCG/f/MZq/oxGgH+TyRF3XcYDjG8dbJCpHO5nQ5Cy9h -QIp3/Bh09kET6lk+4QlofNgHKVT2epV8iK1cXlbQe2tZtfCUtxk+pxvU0UHXp+AB -0xc3/gIhjZp/dePmCOyQyGPJbp5bpO4UeAJ6frqhexmNlaw9Z897ltZmRLGq1p4a -RnWL8FPkBz9SCSKXS8uNyV5oMNVn4G1obCkc106iWuKBTibffYQzq5TG8FYVJKrh -RwWB6piacEB8hl20IIWSxIM3J9tT7CPSnk5RYYCTRHgA5OOrqZhC7JefudrP8n+M -pxkDgNORDu7GCfAuisrf7dXYjLsxG4tu22DBJJC0c/IpRpXDnOuJN1Q5e/3VUKKW -mypNumuQpP5lc1ZFG64TRzb1HR6oIdHfbrVQfdiQXpvdcFx+Fl57WuUraXRV6qfb -4ZmKHX1JEwM/7tu21QE4F1dz0jroLSricZxfaCTHHWNfvGJoZ30/MZUrpSC0IfB3 -iQutxbZrwIlTBt+fGLtm3vDtwMFNWM+Rb1lrOxEQd2eijdxhvBOHtlIcswARAQAB -tERIYXNoaUNvcnAgU2VjdXJpdHkgKGhhc2hpY29ycC5jb20vc2VjdXJpdHkpIDxz -ZWN1cml0eUBoYXNoaWNvcnAuY29tPokCVAQTAQoAPhYhBMh0AR8KtAURDQIQVTQ2 -XZRy10aPBQJgffsZAhsDBQkJZgGABQsJCAcCBhUKCQgLAgQWAgMBAh4BAheAAAoJ -EDQ2XZRy10aPtpcP/0PhJKiHtC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Ca0YrShtxfdSb13oKX+pFr -aZXvxyZlCa5qoQQBV1sowmPL1N2j3dR9TVpdTyCFQSv4KeiExmowtLIjeCppRBEK -eeYHJnlfkyKXPhxTVVO6H+dU4nVu0ASQZ07KiQjbI+zTpPKFLPp3/0sPRJM57r1+ -aTS71iR7nZNZ1f8LZV2OvGE6fJVtgJ1J4Nu02K54uuIhU3tg1+7Xt+IqwRc9rbVr -pHH/hFCYBPW2D2dxB+k2pQlg5NI+TpsXj5Zun8kRw5RtVb+dLuiH/xmxArIee8Jq -ZF5q4h4I33PSGDdSvGXn9UMY5Isjpg== -=7pIB ------END PGP PUBLIC KEY BLOCK----- diff --git a/nomad.sh b/nomad.sh @@ -7,8 +7,6 @@ # set -o nounset set -o xtrace -NOMAD_URL="https://releases.hashicorp.com/nomad" - cd "/home/${USERNAME}" # Install podman driver for Nomad @@ -19,33 +17,12 @@ unzip "nomad-driver-podman_${NOMAD_PODMAN_DRIVER_VERSION}_linux_arm64.zip" mkdir -p /opt/nomad/plugins/ mv nomad-driver-podman /opt/nomad/plugins/ -# Download Nomad binary and checksums -curl -sS -O "${NOMAD_URL}/${NOMAD_VERSION}/nomad_${NOMAD_VERSION}_linux_${NOMAD_ARCH}.zip" -curl -sS -O "${NOMAD_URL}/${NOMAD_VERSION}/nomad_${NOMAD_VERSION}_SHA256SUMS" -curl -sS -O "${NOMAD_URL}/${NOMAD_VERSION}/nomad_${NOMAD_VERSION}_SHA256SUMS.sig" - -# Verify signature and zip archive -gpg --import "hashicorp.asc" -gpg --verify "nomad_${NOMAD_VERSION}_SHA256SUMS.sig" "nomad_${NOMAD_VERSION}_SHA256SUMS" -sha256sum -c "nomad_${NOMAD_VERSION}_SHA256SUMS" --ignore-missing - -# Extract binary -unzip "nomad_${NOMAD_VERSION}_linux_${NOMAD_ARCH}.zip" - -# Fix ownership and install binary -chown root: nomad -chmod 0755 nomad -mv nomad /usr/local/bin/ - -# Check version -nomad --version - # Create Nomad data directory mkdir -p /opt/nomad # Create Nomads config files mkdir -p /etc/nomad.d -chmod 700 /etc/nomad.d +rm -rf /etc/nomad.d/* cat << EOF > /etc/nomad.d/nomad.hcl datacenter = "dc1" @@ -145,32 +122,6 @@ autopilot { } EOF -# Configure systemd service unit -cat << EOF > /etc/systemd/system/nomad.service -[Unit] -Description=Nomad -Documentation=https://nomadproject.io/docs/ -Wants=network-online.target -After=network-online.target - -[Service] -EnvironmentFile=/etc/nomad.d/nomad.env -ExecReload=/bin/kill -HUP -ExecStart=/usr/local/bin/nomad agent -config /etc/nomad.d -KillMode=process -KillSignal=SIGINT -LimitNOFILE=infinity -LimitNPROC=infinity -Restart=on-failure -RestartSec=2 -StartLimitBurst=3 -StartLimitIntervalSec=10 -TasksMax=infinity - -[Install] -WantedBy=multi-user.target -EOF - # Add VAULT_TOKEN placeholder, replace w/ real token # https://www.nomadproject.io/docs/integrations/vault-integration echo "VAULT_TOKEN=changeme" > /etc/nomad.d/nomad.env @@ -222,7 +173,6 @@ keyfile: /var/lib/cilium/consul-tls/dc1-server-consul-key.pem EOF # Run Cilium as privileged container on the node -CILIUM_VERSION=1.13.2 cat << EOF > /etc/systemd/system/cilium.service [Unit] Description=Cilium Agent diff --git a/vault.sh b/vault.sh @@ -7,33 +7,16 @@ # set -o nounset set -o xtrace -VAULT_URL="https://releases.hashicorp.com/vault" - cd "/home/${USERNAME}" -# Download Vault binary and checksums -curl -sS -O "${VAULT_URL}/${VAULT_VERSION}/vault_${VAULT_VERSION}_linux_${VAULT_ARCH}.zip" -curl -sS -O "${VAULT_URL}/${VAULT_VERSION}/vault_${VAULT_VERSION}_SHA256SUMS" -curl -sS -O "${VAULT_URL}/${VAULT_VERSION}/vault_${VAULT_VERSION}_SHA256SUMS.sig" - -# Verify signature and zip archive -gpg --import "hashicorp.asc" -gpg --verify "vault_${VAULT_VERSION}_SHA256SUMS.sig" "vault_${VAULT_VERSION}_SHA256SUMS" -sha256sum -c "vault_${VAULT_VERSION}_SHA256SUMS" --ignore-missing - -# Install binary -unzip "vault_${VAULT_VERSION}_linux_${VAULT_ARCH}.zip" -chown root: vault -mv vault /usr/local/bin/ -vault --version - # Create Vault config directories +mkdir -p /etc/vault.d +rm -rf /etc/vault.d/* mkdir -p /etc/vault.d/tls +# The vault systemd service requires this env file, can be empty +touch /etc/vault.d/vault.env cd /etc/vault.d/tls -# Vault system user -useradd --system --home /etc/vault.d --shell /bin/false vault - # Specify CSR parameters for server key VAULT_TLS_SUBJ_ALT_NAME=${VAULT_TLS_SUBJ_ALT_NAME:+", $VAULT_TLS_SUBJ_ALT_NAME"} SERVER_CONFIG=" @@ -68,9 +51,6 @@ cat "$VAULT_TLS_CA_CERT" >> "${HOSTNAME}.pem" mv "$VAULT_TLS_CA_CERT" /usr/local/share/ca-certificates/ update-ca-certificates -# Allow usage of mlock syscall without root -setcap cap_ipc_lock=+ep /usr/local/bin/vault - cat << EOF > /etc/vault.d/vault.hcl ui = true @@ -117,44 +97,6 @@ EOF chmod 640 /etc/vault.d/vault.hcl -# Configure systemd service unit -cat << EOF > /etc/systemd/system/vault.service -[Unit] -Description="HashiCorp Vault - A tool for managing secrets" -Documentation=https://www.vaultproject.io/docs/ -Requires=network-online.target -After=network-online.target -ConditionFileNotEmpty=/etc/vault.d/vault.hcl -StartLimitIntervalSec=60 -StartLimitBurst=3 - -[Service] -Type=notify -EnvironmentFile=-/etc/vault.d/vault.env -User=vault -Group=vault -ProtectSystem=full -ProtectHome=read-only -PrivateTmp=yes -PrivateDevices=yes -SecureBits=keep-caps -AmbientCapabilities=CAP_IPC_LOCK -CapabilityBoundingSet=CAP_SYSLOG CAP_IPC_LOCK -NoNewPrivileges=yes -ExecStart=/usr/local/bin/vault server -config=/etc/vault.d/vault.hcl -ExecReload=/bin/kill --signal HUP \$MAINPID -KillMode=process -KillSignal=SIGINT -Restart=on-failure -RestartSec=5 -TimeoutStopSec=30 -LimitNOFILE=65536 -LimitMEMLOCK=infinity - -[Install] -WantedBy=multi-user.target -EOF - systemctl enable vault # Configure .bashrc