Last active
April 26, 2022 12:06
-
-
Save ralvares/fb3d521ff0bf05ae415170b73134fb76 to your computer and use it in GitHub Desktop.
upload manifest to ansible tower using bash
This file contains hidden or 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
USER=$(oc get AutomationController -n ansible-automation-platform -o=jsonpath='{.items..status.adminUser}') | |
PASS=$(oc get -n ansible-automation-platform secret $(oc get AutomationController -n ansible-automation-platform -o=jsonpath='{.items..status.adminPasswordSecret}') -o go-template='{{index .data "password" | base64decode}}') | |
FILENAME=$(cat manifest_ansible-tower.zip | base64) | |
ROUTE=$(oc get AutomationController -n ansible-automation-platform -o=jsonpath='{.items..status.URL}') | |
header="Content-Type: application/json" | |
request_body=$(cat <<EOF | |
{ | |
"eula_accepted": true, | |
"manifest": "$FILENAME" | |
} | |
EOF | |
) | |
_RETURN=$(curl -o /dev/null -k -i --user $USER:$PASS -sL --post302 -w "%{http_code}" -H "$header" -X POST -d "$request_body" "$ROUTE/api/v2/config/") | |
if [ $_RETURN == "200" ] ; | |
then | |
echo "OK: Manifest uploaded" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment