Apache Ranger delivers a comprehensive approach to security for a Hadoop cluster. It provides a centralised platform to define, administer and manage security policies consistently across Hadoop components.
This article focuses on Export and Import of Ranger policies using API calls during HDP to CDP migration.
Export
List of Services configured in Ranger
### Command to get list of services
curl -s -u admin:pass -H "Accept: application/json" -H "Content-Type: application/json" -X GET "http://<hostname>:<ranger-port>/service/public/v2/api/service" > services.json
Export of Policies
### Export all policies
To export all policies
curl -X GET --header "text/json" -H "Content-Type: text/json" -o file.json -u admin:admin "http://<hostname>:<ranger-port>/service/plugins/policies/exportJson"
This exported json file.json contains all policies including Tag based policies
Export of users and Groups, which can be used for validation purposes.
## Api call to download all Users from Ranger
curl -s -u admin:pass -H "Accept: application/json" -H "Content-Type: application/json" -X GET "https://ranger.com/service/xusers/users" > users.json
## Api call to download all groups from Ranger
curl -s -u admin:pass -H "Accept: application/json" -H "Content-Type: application/json" -X GET "https://ranger.com/service/xusers/groups" > groups.json
Import
Importing policies into Target CDP cluster
Step 1: Prepare the Ranger service and make sure to configure all service plugins.
Step 2: Prepare servicemapping.json file which has mapping of Ranger service from HDP to CDP world