Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagebash
RANGER_SETUP_DIR="${IMPALA_HOME}/testdata/cluster/ranger/setup"

perl -wpl -e 's/\$\{([^}]+)\}/defined $ENV{$1} ? $ENV{$1} : $&/eg' \ 
  "${RANGER_SETUP_DIR}/impala_group_owner.json.template" > \ 
  "${RANGER_SETUP_DIR}/impala_group_owner.json"

export GROUP_ID_OWNER=$(wget -qO - --auth-no-challenge --user=admin --password=admin \
  --post-file="${RANGER_SETUP_DIR}/impala_group_owner.json" \
  --header="accept:application/json" \
  --header="Content-Type:application/json" \
  http://localhost:6080/service/xusers/secure/groups |
  python -c "import sys, json; print json.load(sys.stdin)['id']")

perl -wpl -e 's/\$\{([^}]+)\}/defined $ENV{$1} ? $ENV{$1} : $&/eg' \
  export GROUP_ID_NON_OWNER=$(wget -qO - --auth-no-challenge --user=admin \
  --password=admin --post-file="${RANGER_SETUP_DIR}/impala_group_non_owner.json" \
  --header="accept:application/json" \
  --header="Content-Type:application/json" \
  http://localhost:6080/service/xusers/secure/groups |
  python -c "import sys, json; print json.load(sys.stdin)['id']")

perl -wpl -e 's/\$\{([^}]+)\}/defined $ENV{$1} ? $ENV{$1} : $&/eg' \ 
  "${RANGER_SETUP_DIR}/impala_user_owner.json.template" > \ 
  "${RANGER_SETUP_DIR}/impala_user_owner.json"

perl -wpl -e 's/\$\{([^}]+)\}/defined $ENV{$1} ? $ENV{$1} : $&/eg' \ 
  "${RANGER_SETUP_DIR}/impala_user_non_owner.json.template" > \ 
  "${RANGER_SETUP_DIR}/impala_user_non_owner.json"

if grep "\${[A-Z_]*}" "${RANGER_SETUP_DIR}/impala_user_owner.json"; then
  echo "Found undefined variables in ${RANGER_SETUP_DIR}/impala_user_owner.json."
  exit 1 
fi

if grep "\${[A-Z_]*}" "${RANGER_SETUP_DIR}/impala_user_non_owner.json"; then
  echo "Found undefined variables in ${RANGER_SETUP_DIR}/impala_user_non_owner.json."
  exit 1 
fi

wget -O /dev/null --auth-no-challenge --user=admin --password=admin \ 
  --post-file="${RANGER_SETUP_DIR}/impala_user_owner.json" \ 
  --header="Content-Type:application/json" \ 
  http://localhost:6080/service/xusers/secure/users

wget -O /dev/null --auth-no-challenge --user=admin --password=admin \ 
  --post-file="${RANGER_SETUP_DIR}/impala_user_non_owner.json.template" >\ \
  "${RANGER_SETUP_DIR}/impala_user.json"

--header="Content-Type:application/json" \ 
  http://localhost:6080/service/xusers/secure/users

wget -O /dev/null --auth-no-challenge --user=admin --password=admin \ 
  --post-file="${RANGER_SETUP_DIR}/impala_userservice.json" \ 
  --header="Content-Type:application/json" \ 
  http://localhost:6080/service/xuserspublic/v2/secureapi/usersservice

wgetcurl -O /dev/null --auth-no-challenge --user=admin --password=admin \
  --post-file="${RANGER_SETUP_DIR}/impala_service.json" \
  --header=u admin:admin -H "Accept: application/json" -H "Content-Type: application/json" \ 
  -X PUT http://localhost:6080/service/public/v2/api/service/policy/4 \ 
  -d @"${RANGER_SETUP_DIR}/policy_4_revised.json"

Then you should be able to see the "test_impala" service in your Ranger portal (default to http://localhost:6080) like this

...