diff --git a/salt/docker/defaults.yaml b/salt/docker/defaults.yaml index ea656f3dd..b1e0d9162 100644 --- a/salt/docker/defaults.yaml +++ b/salt/docker/defaults.yaml @@ -73,9 +73,9 @@ docker: ulimits: [] 'so-hydra': final_octet: 30 + networks: ['soauth'] port_bindings: - 0.0.0.0:4444:4444 - - 0.0.0.0:4445:4445 custom_bind_mounts: [] extra_hosts: [] extra_env: [] diff --git a/salt/hydra/enabled.sls b/salt/hydra/enabled.sls index 74106f550..13fce79cf 100644 --- a/salt/hydra/enabled.sls +++ b/salt/hydra/enabled.sls @@ -26,8 +26,8 @@ so-hydra: - hostname: hydra - name: so-hydra - networks: - - sobridge: - - ipv4_address: {{ DOCKERMERGED.containers['so-hydra'].ip }} + - soauth: + - ipv4_address: {{ DOCKERMERGED.containers['so-hydra'].ips['soauth'] }} - binds: - /opt/so/conf/hydra/:/hydra-conf:ro - /opt/so/log/hydra/:/hydra-log:rw @@ -73,7 +73,7 @@ delete_so-hydra_so-status.disabled: wait_for_hydra: http.wait_for_successful_query: - - name: 'http://{{ GLOBALS.manager }}:4444/health/alive' + - name: 'http://{{ DOCKERMERGED.containers['so-hydra'].ips['soauth'] }}:4444/health/alive' - ssl: True - verify_ssl: False - status: diff --git a/salt/manager/tools/sbin/so-client b/salt/manager/tools/sbin/so-client index f979d7bc0..0bafde603 100755 --- a/salt/manager/tools/sbin/so-client +++ b/salt/manager/tools/sbin/so-client @@ -106,7 +106,8 @@ while [[ $# -gt 0 ]]; do esac done -hydraUrl=${HYDRA_URL:-http://127.0.0.1:4445} +hydraContainer=${HYDRA_CONTAINER:-so-hydra} +hydraUrl=${HYDRA_URL:-http://localhost:4445} socRolesFile=${SOC_ROLES_FILE:-/opt/so/conf/soc/soc_clients_roles} soUID=${SOCORE_UID:-939} soGID=${SOCORE_GID:-939} @@ -124,6 +125,10 @@ function fail() { exit 1 } +function hydraCurl() { + docker exec -i "$hydraContainer" curl "$@" +} + function require() { cmd=$1 which "$1" 2>&1 > /dev/null @@ -133,8 +138,8 @@ function require() { # Verify this environment is capable of running this script function verifyEnvironment() { require "jq" - require "curl" - response=$(curl -Ss -L ${hydraUrl}/health/alive) + require "docker" + response=$(hydraCurl -Ss -L ${hydraUrl}/health/alive) [[ "$response" != '{"status":"ok"}' ]] && fail "Unable to communicate with Hydra; specify URL via HYDRA_URL environment variable" } @@ -164,7 +169,7 @@ function ensureRoleFileExists() { } function listClients() { - response=$(curl -Ss -L -f ${hydraUrl}/admin/clients) + response=$(hydraCurl -Ss -L -f ${hydraUrl}/admin/clients) [[ $? != 0 ]] && fail "Unable to communicate with Hydra" clientIds=$(echo "${response}" | jq -r ".[] | .client_id" | sort) @@ -251,7 +256,7 @@ function createClient() { EOF ) - response=$(curl -Ss -L --fail-with-body -X POST ${hydraUrl}/admin/clients -d "$body") + response=$(hydraCurl -Ss -L --fail-with-body -X POST ${hydraUrl}/admin/clients -d "$body") if [[ $? != 0 ]]; then error=$(echo $response | jq .error) fail "Failed to submit request to Hydra: $error" @@ -283,7 +288,7 @@ function update() { EOF ) - response=$(curl -Ss -L --fail-with-body -X PATCH ${hydraUrl}/admin/clients/$id -d "$body") + response=$(hydraCurl -Ss -L --fail-with-body -X PATCH ${hydraUrl}/admin/clients/$id -d "$body") if [[ $? != 0 ]]; then error=$(echo $response | jq .error) fail "Failed to submit request to Hydra: $error" @@ -305,7 +310,7 @@ function generateSecret() { EOF ) - response=$(curl -Ss -L --fail-with-body -X PATCH ${hydraUrl}/admin/clients/$id -d "$body") + response=$(hydraCurl -Ss -L --fail-with-body -X PATCH ${hydraUrl}/admin/clients/$id -d "$body") if [[ $? != 0 ]]; then error=$(echo $response | jq .error) fail "Failed to submit request to Hydra: $error" @@ -317,7 +322,7 @@ function deleteClient() { [[ ${identityId} == "" ]] && fail "Client not found" - response=$(curl -Ss -XDELETE -L --fail-with-body "${hydraUrl}/admin/clients/$identityId") + response=$(hydraCurl -Ss -XDELETE -L --fail-with-body "${hydraUrl}/admin/clients/$identityId") if [[ $? != 0 ]]; then error=$(echo $response | jq .error) fail "Failed to submit request to Hydra: $error" diff --git a/salt/manager/tools/sbin/soup b/salt/manager/tools/sbin/soup index 2bc1ea9e8..62bc7d266 100755 --- a/salt/manager/tools/sbin/soup +++ b/salt/manager/tools/sbin/soup @@ -1100,8 +1100,8 @@ post_to_3.3.0() { up_to_3.4.0() { set_soauth_range - echo "Removing so-kratos and so-soc so they are recreated on the soauth network." - docker rm -f so-kratos so-soc >> $SOUP_LOG 2>&1 + echo "Removing so-kratos, so-hydra and so-soc so they are recreated on the soauth network." + docker rm -f so-kratos so-hydra so-soc >> $SOUP_LOG 2>&1 INSTALLEDVERSION=3.4.0 } diff --git a/salt/vars/globals.map.jinja b/salt/vars/globals.map.jinja index 772fe8797..5060806d5 100644 --- a/salt/vars/globals.map.jinja +++ b/salt/vars/globals.map.jinja @@ -54,7 +54,7 @@ {% do GLOBALS.update({ 'application_urls': { - 'hydra': 'http://' ~ GLOBALS.manager ~ ':4445/', + 'hydra': 'http://' ~ DOCKERMERGED.containers['so-hydra'].ips['soauth'] ~ ':4445/', 'kratos': 'http://' ~ DOCKERMERGED.containers['so-kratos'].ips['soauth'] ~ ':4434/', 'elastic': 'https://' ~ GLOBALS.manager ~ ':9200/', 'influxdb': 'https://' ~ GLOBALS.manager ~ ':8086/'