Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vaultkey #8

Merged
merged 2 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@ imagebuilder
|TAG | A tag that is added to the name|
|RAW_OUTPOUT | Set to yes to get the .img file as output|
|TOKEN | A token used by Ansible|
|VAULT_KEY | Key to use in the vaultkey.secret file|

### List of flavors

ubuntu24.04

ubuntu22.04

ubuntu20.04
Expand All @@ -69,8 +72,8 @@ Run mount command. Make sure to update the offset (526336) for the correct value
`mount ubuntu-22.04.4-preinstalled-server-arm64+raspi.img -o loop,offset=$(( 512 * 526336)) /mnt/`

## How to add my custom secrets file for ansible vaults?
Copy the file in `out/output`. and make sure that the name is NODENAME-vaultkey.secret

To use a custom secret the VAULT_KEY variable can be set. If a vaultkey file of the name NODENAME-vaultkey.secret already exists the variable will be ignored.

[![GitHub](https://img.shields.io/github/license/ERIGrid2/riasc-provisioning)](https://github.com/ERIGrid2/riasc-provisioning/blob/master/LICENSE)

Expand Down
9 changes: 7 additions & 2 deletions rpi/create_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ echo "Using token: ${TOKEN}"
echo "Using flavor: ${FLAVOR}"
echo "Using repo: ${GIT_URL}"
echo "Using branch: ${GIT_BRANCH}"
if [! -z "$VAULT_KEY" ]; then
echo "Using ansible secret ${VAULT_KEY}"
fi

# Check that required commands exist
echo "Check if required commands are installed..."
Expand Down Expand Up @@ -166,8 +169,10 @@ sed -i \

#Generate ansible secret
if [ ! -f ${OUTPUT_FOLDER}/"${NODENAME}"-vaultkey.secret ]; then
echo "Generate ansible secret"
VAULT_KEY=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 20; echo)
if [ -z "$VAULT_KEY" ]; then
echo "Generate ansible secret"
VAULT_KEY=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 20; echo)
fi
cat <<EOF > ${OUTPUT_FOLDER}/"${NODENAME}"-vaultkey.secret
#!/bin/bash
echo "${VAULT_KEY}"
Expand Down