Automate the Ambari LDAP sync
Today we are using below command to sync all the AD users to get access to Ambari Views/Operation server.
ambari-server sync-ldap --groups groups.txt
We can't schedule cron tab because we need to pass admin credentials at the time of sync. It's hard to run daily as the users get added to the group and deleted which are managed in AD.
By using below curl command we can automate the Ambari LDAP sync. We can add this command to bash script and schedule it using confab. Whenever new users get added/deleted to the LDAP group, it will get automatically synced the same with Ambari Views. We need to run below command as Ambari user.
This can avoid running ‘ambari-server sync-ldap’command. Here even no need to run any unset proxy commands.
curl -k -u admin:<password> -H
'X-Requested-By: ambari' -X POST -d '[{"Event": {"specs":
[{"principal_type": "users", "sync_type":
"specific", "names":
"sredd66,sreddyuw"},{"principal_type":"groups","sync_type":"specific",
"names": "hadoopadmin,hadoopusers"}]}}]' https://ambarihostname:8080/api/v1/ldap_sync_events
Steps to remove an LDAP group from Ambari and still have the group in LDAP:
Command to GET/DELETE groups from Ambari by not touching AD.
GET:
curl --insecure -u admin:<password> -H
'X-Requested-By: ambari' -X GET https://ambarihostname:8080/api/v1/groups/
DELETE:
curl --insecure -u admin:<password> -H
'X-Requested-By: ambari' -X DELETE https://ambarihostname:8080/api/v1/groups/<group
name you wanted to delete>
Let me know if you have any questions.

