]> Frank Brehm's Git Trees - pixelpark/create-terraform.git/commitdiff
Adding generating password file for postinstall-scripts/register-rhel
authorFrank Brehm <frank.brehm@pixelpark.com>
Mon, 16 Oct 2023 13:05:53 +0000 (15:05 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Mon, 16 Oct 2023 13:05:53 +0000 (15:05 +0200)
example/prd-repo03.yaml
postinstall-scripts/register-rhel

index cdafa377ef3cad0a49188f30bd00ccde8e529b39..947fbebef90781b9abc24aa90ef878207a113ebd 100644 (file)
@@ -2,7 +2,7 @@
 defaults:
   vsphere: live
   cluster: vmcc-l105-01
-  vm_folder: Pixelpark/Tools
+  vm_folder: Pixelpark/Tools/live
   num_cpus: 2
   memory: 4GB
   boot_delay: 5
@@ -34,7 +34,7 @@ defaults:
   dns_options: 'timeout:1 attempts:2 use-vc'
 
 vms:
-  - name: repo03.pixelpark.com
+  - name: prd-repo03.pixelpark.com
     interfaces:
       - address_v4: 217.66.55.69
 
index 3d527091bccbda1f3fb6bab3a491c73837c07e0d..2204e14b8d8ee1269ec9e5265896c6d16fe18bbc 100755 (executable)
@@ -19,6 +19,7 @@ export PATH='/sbin:/bin:/usr/sbin:/usr/bin'
 
 RHSM_USER='dpx-subscriber'
 RHSM_PWD=
+RHSM_PWD_FILE="${BIN_DIR}/rhsm-user-passwd"
 SM_BIN='subscription-manager'
 
 detect_color
@@ -33,7 +34,7 @@ DESCRIPTION=$( cat <<-EOF
 #------------------------------------------------------------------------------
 usage() {
     cat <<-EOF
-       Usage: ${BASE_NAME} [-U USER ] [-P PASSWORD ] ${STD_USAGE}
+       Usage: ${BASE_NAME} [-U USER ] [-P PASSWORD ] [-y PASSWORD_FILE] ${STD_USAGE}
               ${BASE_NAME} [-h|--help]
               ${BASE_NAME} [-V|--version]
 
@@ -41,6 +42,8 @@ usage() {
                -U|--user USER  Gives the username for the account which is registering the system.
                -P|--password PASSWORD
                                Gives the user account password.
+               -y|--password-file PASSWORD_FILE
+                               A file containing the user account password.
        EOF
 
        echo "${STD_USAGE_MSG}"
@@ -50,8 +53,8 @@ usage() {
 get_options() {
 
     local tmp=
-    local short_options="U:P:${STD_SHORT_OPTIONS}"
-    local long_options="user:,password:,${STD_LONG_OPTIONS}"
+    local short_options="U:P:y:${STD_SHORT_OPTIONS}"
+    local long_options="user:,password:,password-file:,${STD_LONG_OPTIONS}"
 
     set +e
     tmp=$( getopt -o "${short_options}" --long "${long_options}" -n "${BASE_NAME}" -- "$@" )
@@ -89,6 +92,11 @@ get_options() {
                 RHSM_PWD="${REMAINING_OPTS[$j]}"
                 i=$(( $i + 2 ))
                 ;;
+            -y|--password-file)
+                j=$(( $i + 1 ))
+                RHSM_PWD_FILE="${REMAINING_OPTS[$j]}"
+                i=$(( $i + 2 ))
+                ;;
             *)  echo -e "Internal error - option '${RED}${arg}${NORMAL} was wrong!"
                 exit 1
                 ;;
@@ -115,6 +123,10 @@ get_options() {
         exit 1
     fi
 
+    if [[ -n "${RHSM_PWD_FILE}" && -f "${RHSM_PWD_FILE}" ]] ; then
+        RHSM_PWD=$( cat "${RHSM_PWD_FILE}" | head -n 1 )
+    fi
+
     if [[ -z "${RHSM_PWD}" ]] ; then
         error "No password of the user for registring at RedHat subscription management given."
         exit 1