-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
templates/packer: support ldap service account for repo mtls conf
The secret needs 3 fields, the cert, key and baseurl for the repository. The CA is optional.
- Loading branch information
1 parent
53f7736
commit c8130d0
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
...packer/ansible/roles/common/files/worker-initialization-scripts/get_ldap_sa_mtls_creds.sh
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,44 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
source /tmp/cloud_init_vars | ||
|
||
echo "Deploy MTLS credentials for custom repositories." | ||
|
||
LDAP_SERVICE_ACCOUNT_MTLS_IMAGE_BUILDER_ARN=${LDAP_SERVICE_ACCOUNT_MTLS_IMAGE_BUILDER_ARN:-} | ||
if [[ -z "$LDAP_SERVICE_ACCOUNT_MTLS_IMAGE_BUILDER_ARN" ]]; then | ||
echo "LDAP_SERVICE_ACCOUNT_MTLS_IMAGE_BUILDER_ARN not defined, skipping." | ||
exit 0 | ||
fi | ||
|
||
/usr/local/bin/aws secretsmanager get-secret-value \ | ||
--endpoint-url "${SECRETS_MANAGER_ENDPOINT_URL}" \ | ||
--secret-id "${LDAP_SERVICE_ACCOUNT_MTLS_IMAGE_BUILDER_ARN}" | jq -r ".SecretString" > /tmp/ldap_service_account_mtls_credentials.json | ||
MTLS_CERT=$(jq -r ".cert" /tmp/ldap_service_account_mtls_credentials.json) | ||
MTLS_KEY=$(jq -r ".key" /tmp/ldap_service_account_mtls_credentials.json) | ||
BASEURL=$(jq -r ".baseurl" /tmp/ldap_service_account_mtls_credentials.json) | ||
CA=$(jq -r ".ca" /tmp/ldap_service_account_mtls_credentials.json) | ||
rm /tmp/ldap_service_account_mtls_credentials.json | ||
|
||
sudo tee /etc/osbuild-worker/image_builder_sa_mtls_cert.pem > /dev/null << EOF | ||
$MTLS_CERT | ||
EOF | ||
|
||
sudo tee /etc/osbuild-worker/image_builder_sa_mtls_key.pem > /dev/null << EOF | ||
$MTLS_KEY | ||
EOF | ||
|
||
sudo tee -a /etc/osbuild-worker/osbuild-worker.toml > /dev/null << EOF | ||
[repository_mtls] | ||
baseurl = "$BASEURL" | ||
mtls_client_key = "/etc/osbuild-worker/image_builder_sa_mtls_key.pem" | ||
mtls_client_cert = "/etc/osbuild-worker/image_builder_sa_mtls_cert.pem" | ||
EOF | ||
|
||
if [ "$CA" != null ]; then | ||
sudo tee /etc/osbuild-worker/image_builder_sa_ca.pem > /dev/null << EOF | ||
$CA | ||
EOF | ||
sudo tee -a /etc/osbuild-worker/osbuild-worker.toml > /dev/null << EOF | ||
ca = "/etc/osbuild-worker/image_builder_sa_ca.pem" | ||
EOF | ||
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