Skip to content

Instantly share code, notes, and snippets.

@seanorama
Last active January 18, 2018 10:59
Show Gist options
  • Save seanorama/c8627bab9daaafd77265e2cf66bd9dc1 to your computer and use it in GitHub Desktop.
Save seanorama/c8627bab9daaafd77265e2cf66bd9dc1 to your computer and use it in GitHub Desktop.
automated ambari ldap sync
#!/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