Support Questions

Find answers, ask questions, and share your expertise

Automation of Ranger Policy

Hi Team,

I use the following command to extract ranger policies:

curl -iv -u admin:admin -H "Content-type:application/json" -X GET http://sandbox.com:6080/service/public/api/policy > /tmp

Is there anyway wherein I can automate the above script such that there is no need to key-in admin username & passwd

I am planning to schedule a cron job such that every 6 hrs it should extract policy and dump the o/p in a path.

Thanks

6 REPLIES 6

Hi - you need to provide authentication to ranger for the API call.

Can not automate the ranger admin curl command wherein it doesn't ask for username and passwd for ranger credentials

Cloudera Employee

@sudi ts Please try:

curl -iv -u admin:admin -H "Content-type:application/json" -X GET http://sandbox.com:6080/service/public/v2/api/policy

I have the same command: curl -iv -u admin:admin -H "Content-type:application/json" -X GET http://sandbox.com:6080/service/public/v2/api/policy

My question: Is it possible to automate the above command such that it doesn't ask for ranger admin user name and password and it authenticates via kerboros authentication

Hi Can anyone please let me know how to proceed with the request??

I can extract ranger policies via the following command: curl -iv -u username:passwd -H "Content-type:application/json" -X GET http://sandbox.com:6080/service/public/v2/api/policy

I need the automate the script such that it there is no need to enter the username and passwd... is it possible ??

is there any API from which i can test it....

Cloudera Employee

@sudi ts

If your cluster is kerberized, then first kinit with a principal with admin privilege in Ranger, and then use

curl --negotiate -vk -u : -H "Content-type:application/json" -X GET http://sandbox.com:6080/service/public/v2/api/policy

Thanks!