Last active
January 18, 2018 10:59
-
-
Save seanorama/c8627bab9daaafd77265e2cf66bd9dc1 to your computer and use it in GitHub Desktop.
automated ambari ldap sync
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
#!/usr/bin/env bash | |
## Description: Sync Ambari LDAP | |
## - Syncs existing users & groups | |
## Author: Sean Roberts http://github.com/seanorama | |
set -o errexit | |
set -o nounset | |
set -o pipefail | |
: ${ambari_user:="admin"} | |
: ${ambari_pass:="admin"} | |
: ${ambari_protocol:="http"} | |
: ${ambari_host:="localhost"} | |
: ${ambari_port:="8080"} | |
: ${ambari_api_base:="/api/v1"} | |
: ${ambari_api:="${ambari_protocol}://${ambari_host}:${ambari_port}${ambari_api_base}"} | |
: ${ambari_requested_by:="bash-ambari-ldap-sync"} | |
: ${ambari_curl_cmd:="curl -sS -k -u ${ambari_user}:${ambari_pass} -H ${ambari_requested_by}"} | |
: ${ambari_curl:="${ambari_curl_cmd} ${ambari_api}"} | |
read -r -d '' body <<EOF || echo ${body} | |
[ | |
{ | |
"Event": { | |
"specs": [ | |
{ | |
"principal_type": "users", | |
"sync_type": "existing" | |
}, | |
{ | |
"principal_type": "groups", | |
"sync_type": "existing" | |
} | |
] | |
} | |
} | |
] | |
EOF | |
echo ${body} | ${ambari_curl}/ldap_sync_events -sS -X POST -d @- | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment