Skip to content

Instantly share code, notes, and snippets.

@jgato
Created June 1, 2023 12:18
Show Gist options
  • Save jgato/08081d2bb8092cd0f8b6ecf1cd45b72f to your computer and use it in GitHub Desktop.
Save jgato/08081d2bb8092cd0f8b6ecf1cd45b72f to your computer and use it in GitHub Desktop.
for a given cluster-name (NAMESPACE) and a list of hosts, it will create the needed secrets to prepare the deployments. It will ask for the BMC user/password of each host
#! /bin/bash
if [ $# -lt 2 ]
then
echo "Usage: ./script.sh <NAMESPACE> <HOSTNAME_1> ... <HOSTNAME_N>"
exit 1
fi
export CLUSTERNS=$1
export HOSTNAME=$2
export PULLSECRETCONTENT=$(cat ~/pull-secret.jgato)
export PS64=$(echo -n ${PULLSECRETCONTENT} | base64 -w0)
envsubst <<"EOF" | oc apply -f -
apiVersion: v1
kind: Secret
metadata:
name: assisted-deployment-pull-secret
namespace: ${CLUSTERNS}
data:
.dockerconfigjson: ${PS64}
EOF
echo "Now introduce the credentials for the BMC"
USERNAME=`read -p 'Username: ' tmp; printf $tmp | base64`
PASSWORD=`read -s -p 'Password: ' tmp; printf $tmp | base64`
echo ""
shift
for host in "$@"
do
oc apply -f - <<EOF
apiVersion: v1
kind: Secret
metadata:
name: $host-bmc-secret
namespace: $CLUSTERNS
type: Opaque
data:
username: $USERNAME
password: $PASSWORD
EOF
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment