From 883eec2c3f58432826b28e84b4edc3767b7c2d3c Mon Sep 17 00:00:00 2001 From: "Matthew C. Morgan" Date: Mon, 28 Apr 2025 20:22:24 -0400 Subject: [PATCH] remove jq --- config_job.tf | 51 ++++++++++++++------------------------------------- 1 file changed, 14 insertions(+), 37 deletions(-) diff --git a/config_job.tf b/config_job.tf index d103214..03396ef 100644 --- a/config_job.tf +++ b/config_job.tf @@ -94,11 +94,6 @@ GRANT -H "Authorization: Bearer $KC_TOKEN" \ "$KC_URL/auth/admin/realms/$realm_name") - if [ "$status" == "200" ]; then - echo "Realm $realm_name already exists" - return 0 - fi - # Create realm curl -s -X POST \ -H "Authorization: Bearer $KC_TOKEN" \ @@ -119,14 +114,9 @@ GRANT echo "Creating admin user: $username in realm $realm" # Check if user exists - local user_id=$(curl -s \ + curl -s \ -H "Authorization: Bearer $KC_TOKEN" \ - "$KC_URL/auth/admin/realms/$realm/users?username=$username") - - if [ "$user_id" != "null" ] && [ -n "$user_id" ]; then - echo "User $username already exists with ID $user_id" - return 0 - fi + "$KC_URL/auth/admin/realms/$realm/users?username=$username" # Create user curl -s -X POST \ @@ -136,9 +126,9 @@ GRANT "$KC_URL/auth/admin/realms/$realm/users" # Get user ID - user_id=$(curl -s \ + curl -s \ -H "Authorization: Bearer $KC_TOKEN" \ - "$KC_URL/auth/admin/realms/$realm/users?username=$username") + "$KC_URL/auth/admin/realms/$realm/users?username=$username" # Set password curl -s -X PUT \ @@ -159,14 +149,9 @@ GRANT echo "Creating realm role: $role_name in realm $realm" # Check if role exists - local status=$(curl -s -o /dev/null -w %%{http_code} \ + curl -s -o /dev/null -w %%{http_code} \ -H "Authorization: Bearer $KC_TOKEN" \ - "$KC_URL/auth/admin/realms/$realm/roles/$role_name") - - if [ "$status" == "200" ]; then - echo "Role $role_name already exists" - return 0 - fi + "$KC_URL/auth/admin/realms/$realm/roles/$role_name" # Create role curl -s -X POST \ @@ -187,14 +172,14 @@ GRANT echo "Adding role $role_name to user $username in realm $realm" # Get user ID - local user_id=$(curl -s \ + curl -s \ -H "Authorization: Bearer $KC_TOKEN" \ - "$KC_URL/auth/admin/realms/$realm/users?username=$username") + "$KC_URL/auth/admin/realms/$realm/users?username=$username" # Get role - local role=$(curl -s \ + curl -s \ -H "Authorization: Bearer $KC_TOKEN" \ - "$KC_URL/auth/admin/realms/$realm/roles/$role_name") + "$KC_URL/auth/admin/realms/$realm/roles/$role_name" # Add role to user curl -s -X POST \ @@ -220,9 +205,9 @@ GRANT echo "Creating client: $client_id in realm $realm" # Check if client exists - local clients=$(curl -s \ + curl -s \ -H "Authorization: Bearer $KC_TOKEN" \ - "$KC_URL/auth/admin/realms/$realm/clients?clientId=$client_id") + "$KC_URL/auth/admin/realms/$realm/clients?clientId=$client_id" # Create client curl -s -X POST \ @@ -239,9 +224,9 @@ GRANT local realm=$1 local client_id=$2 - local id=$(curl -s \ + curl -s \ -H "Authorization: Bearer $KC_TOKEN" \ - "$KC_URL/auth/admin/realms/$realm/clients?clientId=$client_id") + "$KC_URL/auth/admin/realms/$realm/clients?clientId=$client_id" echo $id } @@ -266,14 +251,6 @@ GRANT echo "Mapper $name added to client $client_id" } - # Restart Keycloak server - function restart_server { - echo "Restarting Keycloak server..." - kubectl rollout restart deployment/keycloak-keycloakx -n ${kubernetes_namespace.keycloak.metadata[0].name} - - echo "Keycloak restarted" - } - # Start configuration process echo "Starting configuration process"