<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Enabling and Disabling a Ranger Policy using command in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Enabling-and-Disabling-a-Ranger-Policy-using-command/m-p/191109#M153198</link>
    <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/2559/rajdipchaudhuri.html" nodeid="2559"&gt;@rajdip chaudhuri&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I am suspecting that your JSON file "/tmp/10_2.json" has the 
following line as well in it which is not right ... you should remove 
it.&lt;/P&gt;&lt;PRE&gt;HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Set-Cookie: RANGERADMINSESSIONID=EDCBDAFF124C9802A79BFD945662BC1A; Path=/; HttpOnly X-Frame-Options: DENY Content-Type: application/json Transfer-Encoding: chunked Date: Fri, 07 Apr 2017 07:00:49 GMT &lt;/PRE&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;Your  modified JSON file "/tmp/10_2.json" should contain only the JSON data part.  Looks like you have some additional data in it. (No other extra lines).&lt;/P&gt;&lt;PRE&gt;{"id":10,"guid":"c8afaae2-a4cc-4c25-b4b2-75ae9b0227eb","isEnabled":false,"createdBy":"Admin","updatedBy":"Admin","createTime":1491448221000,"updateTime":1491448221000,"version":1,"service":"TCSGEINTERNALCLUSTER_hive","name":"tcs_ge_user data masking test 2","policyType":1,"description":"tcs_ge_user data masking test 2","resourceSignature":"2cb6661609e66abfd9fbceaeac2be9d0","isAuditEnabled":true,"resources":{"database":{"values":["wells_fargo_poc"],"isExcludes":false,"isRecursive":false},"column":{"values":["card_number"],"isExcludes":false,"isRecursive":false},"table":{"values":["test_masked_2"],"isExcludes":false,"isRecursive":false}},"policyItems":[],"denyPolicyItems":[],"allowExceptions":[],"denyExceptions":[],"dataMaskPolicyItems":[{"accesses":[{"type":"select","isAllowed":true}],"users":["tcs_ge_user"],"groups":["tcs_ge_user"],"conditions":[],"delegateAdmin":false,"dataMaskInfo":{"dataMaskType":"MASK_HASH"}}],"rowFilterPolicyItems":[]}&lt;/PRE&gt;&lt;P&gt;.&lt;/P&gt;</description>
    <pubDate>Fri, 07 Apr 2017 14:09:54 GMT</pubDate>
    <dc:creator>jsensharma</dc:creator>
    <dc:date>2017-04-07T14:09:54Z</dc:date>
    <item>
      <title>Enabling and Disabling a Ranger Policy using command</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Enabling-and-Disabling-a-Ranger-Policy-using-command/m-p/191105#M153194</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;We use Ranger for column filtering and data masking. Our use case is we will be ingesting data into Hive from source systems using Talend / Informatica but while executing the jobs we are getting error. What we found out that if the data masking policy on a particular table in Hive is on, data cannot be inserted. However, we can make the policy enabled once the data insert is complete.&lt;/P&gt;&lt;P&gt;Can you please help for guiding us on how can the Ranger Data Masking policies be disabled and enabled using an Unix command so that we can include those in the data ingestion workflow so that there ain't any manual intervention?&lt;/P&gt;&lt;P&gt;Looking for your guidance.&lt;/P&gt;&lt;P&gt;Thanks and Regards,&lt;/P&gt;&lt;P&gt;Rajdip&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 22:35:57 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Enabling-and-Disabling-a-Ranger-Policy-using-command/m-p/191105#M153194</guid>
      <dc:creator>rajdip_chaudhur</dc:creator>
      <dc:date>2017-04-06T22:35:57Z</dc:date>
    </item>
    <item>
      <title>Re: Enabling and Disabling a Ranger Policy using command</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Enabling-and-Disabling-a-Ranger-Policy-using-command/m-p/191106#M153195</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/2559/rajdipchaudhuri.html" nodeid="2559"&gt;@rajdip chaudhuri&lt;/A&gt;&lt;/P&gt;&lt;P&gt;You can use Ranger Rest API to be invoked using simple "curl" commands in order to disable/enable various ranger policies.&lt;/P&gt;&lt;P&gt;1. Get the List of Policies using Rest API: &lt;A target="_blank" href="http://localhost:6080/service/plugins/policies"&gt;http://localhost:6080/service/plugins/policies&lt;/A&gt;
For example you want to disable the policy ID = 14  (Example&lt;STRONG&gt; "HDFS Global Allow") &lt;/STRONG&gt;The do the following:&lt;/P&gt;&lt;P&gt;Using Ranger API get the policy data:&lt;/P&gt;&lt;PRE&gt;curl -i -u admin:admin -H "Content-Type: application/json" -X GET &lt;A href="http://localhost:6080/service/plugins/policies/14" target="_blank"&gt;http://localhost:6080/service/plugins/policies/14&lt;/A&gt; &lt;/PRE&gt;&lt;P&gt;
2. Then you get some JSON output like following:&lt;/P&gt;&lt;PRE&gt;{"id":14,"guid":"eb167192-29a5-490c-9655-8be40c2363eb","isEnabled":true,"createdBy":"Admin","updatedBy":"Admin","createTime":1473764849000,"updateTime":1473764849000,"version":1,"service":"Sandbox_hadoop","name":"HDFS Global Allow","policyType":0,"description":"This policy gives global permission for all users. Disable this to test Apache Ranger","resourceSignature":"6be1f1907223a25472365fea64a3d450","isAuditEnabled":true,"resources":{"path":{"values":["/","/*"],"isExcludes":false,"isRecursive":true}},"policyItems":[{"accesses":[{"type":"read","isAllowed":true},{"type":"write","isAllowed":true},{"type":"execute","isAllowed":true}],"users":[],"groups":["public"],"conditions":[],"delegateAdmin":true}],"denyPolicyItems":[],"allowExceptions":[],"denyExceptions":[],"dataMaskPolicyItems":[],"rowFilterPolicyItems":[]}&lt;/PRE&gt;&lt;P&gt;
&lt;STRONG&gt;Notice it has ["isEnabled":true]&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;3. Now Paste the output to a file &lt;STRONG&gt;"/tmp/14.json"&lt;/STRONG&gt;, then change it to ["isEnabled":false]  and then PUT the data using curl. Content of "14.json" file as following:&lt;/P&gt;&lt;PRE&gt;{"id":14,"guid":"eb167192-29a5-490c-9655-8be40c2363eb","isEnabled":false,"createdBy":"Admin","updatedBy":"Admin","createTime":1473764849000,"updateTime":1473764849000,"version":1,"service":"Sandbox_hadoop","name":"HDFS Global Allow","policyType":0,"description":"This policy gives global permission for all users. Disable this to test Apache Ranger","resourceSignature":"6be1f1907223a25472365fea64a3d450","isAuditEnabled":true,"resources":{"path":{"values":["/","/*"],"isExcludes":false,"isRecursive":true}},"policyItems":[{"accesses":[{"type":"read","isAllowed":true},{"type":"write","isAllowed":true},{"type":"execute","isAllowed":true}],"users":[],"groups":["public"],"conditions":[],"delegateAdmin":true}],"denyPolicyItems":[],"allowExceptions":[],"denyExceptions":[],"dataMaskPolicyItems":[],"rowFilterPolicyItems":[]}
 &lt;/PRE&gt;&lt;P&gt;
4. Now run the following curl command:&lt;/P&gt;&lt;PRE&gt;curl -i -u admin:admin -H "Content-Type: application/json" -X PUT -d@/tmp/14.json  &lt;A href="http://localhost:6080/service/plugins/policies/14" target="_blank"&gt;http://localhost:6080/service/plugins/policies/14&lt;/A&gt; &lt;/PRE&gt;&lt;P&gt;
&lt;STRONG&gt;More details:  &lt;/STRONG&gt;&lt;A href="https://cwiki.apache.org/confluence/display/RANGER/REST+APIs+for+Policy+Management" target="_blank"&gt;https://cwiki.apache.org/confluence/display/RANGER/REST+APIs+for+Policy+Management&lt;/A&gt;&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 22:56:21 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Enabling-and-Disabling-a-Ranger-Policy-using-command/m-p/191106#M153195</guid>
      <dc:creator>jsensharma</dc:creator>
      <dc:date>2017-04-06T22:56:21Z</dc:date>
    </item>
    <item>
      <title>Re: Enabling and Disabling a Ranger Policy using command</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Enabling-and-Disabling-a-Ranger-Policy-using-command/m-p/191107#M153196</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/2559/rajdipchaudhuri.html" nodeid="2559"&gt;@rajdip chaudhuri&lt;/A&gt;&lt;/P&gt;&lt;P&gt;To add to &lt;A rel="user" href="https://community.cloudera.com/users/3418/jsensharma.html" nodeid="3418"&gt;@Jay SenSharma&lt;/A&gt;'s answer: Please use a newer and better version of REST APIs as documented &lt;A href="https://cwiki.apache.org/confluence/display/RANGER/REST+APIs+for+Service+Definition%2C+Service+and+Policy+Management#RESTAPIsforServiceDefinition,ServiceandPolicyManagement-Deletepolicybyid"&gt;here&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2017 01:30:37 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Enabling-and-Disabling-a-Ranger-Policy-using-command/m-p/191107#M153196</guid>
      <dc:creator>akulkarni1</dc:creator>
      <dc:date>2017-04-07T01:30:37Z</dc:date>
    </item>
    <item>
      <title>Re: Enabling and Disabling a Ranger Policy using command</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Enabling-and-Disabling-a-Ranger-Policy-using-command/m-p/191108#M153197</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Am not sure if I am missing any steps here but while executing am getting error. Have followed &lt;A rel="user" href="https://community.cloudera.com/users/3418/jsensharma.html" nodeid="3418"&gt;@Jay SenSharma&lt;/A&gt; comments and able to get the json output and updated the flag in json. But while uploading the JSON after changes using PUT am facing error and it is not working.&lt;/P&gt;&lt;P&gt;Note that the RANGER is up and can perform operations from UI, but REST API PUT is not working (may be my error). Also the ip mentioned in below command contains the RANGER service.&lt;/P&gt;&lt;P&gt;Need you help as we are stuck here and everytime we had to do work manually which we want to bypass.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;CURL command used to PUT the changed JSON is :&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;curl -i -u admin:admin -H "Content-Type: application/json" -X PUT -d@/tmp/10_2.json &lt;A href="http://xx.xx.xx.207:6080/service/plugins/policies/10" target="_blank"&gt;http://xx.xx.xx.207:6080/service/plugins/policies/10&lt;/A&gt;&lt;/P&gt;&lt;P&gt;(changed the ip)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Error thrown:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;HTTP/1.1 404 Not Found Server: Apache-Coyote/1.1 Set-Cookie: RANGERADMINSESSIONID=03A8D6199168A17D4C19D442E8C55617; Path=/; HttpOnly X-Frame-Options: DENY Content-Length: 0 Date: Fri, 07 Apr 2017 06:56:50 GMT&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Modified JSON:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Set-Cookie: RANGERADMINSESSIONID=EDCBDAFF124C9802A79BFD945662BC1A; Path=/; HttpOnly X-Frame-Options: DENY Content-Type: application/json Transfer-Encoding: chunked Date: Fri, 07 Apr 2017 07:00:49 GMT {"id":10,"guid":"c8afaae2-a4cc-4c25-b4b2-75ae9b0227eb",&lt;STRONG&gt;"isEnabled":false&lt;/STRONG&gt;,"createdBy":"Admin","updatedBy":"Admin","createTime":1491448221000,"updateTime":1491448221000,"version":1,"service":"TCSGEINTERNALCLUSTER_hive","name":"tcs_ge_user data masking test 2","policyType":1,"description":"tcs_ge_user data masking test 2","resourceSignature":"2cb6661609e66abfd9fbceaeac2be9d0","isAuditEnabled":true,"resources":{"database":{"values":["wells_fargo_poc"],"isExcludes":false,"isRecursive":false},"column":{"values":["card_number"],"isExcludes":false,"isRecursive":false},"table":{"values":["test_masked_2"],"isExcludes":false,"isRecursive":false}},"policyItems":[],"denyPolicyItems":[],"allowExceptions":[],"denyExceptions":[],"dataMaskPolicyItems":[{"accesses":[{"type":"select","isAllowed":true}],"users":["tcs_ge_user"],"groups":["tcs_ge_user"],"conditions":[],"delegateAdmin":false,"dataMaskInfo":{"dataMaskType":"MASK_HASH"}}],"rowFilterPolicyItems":[]}&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2017 14:01:23 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Enabling-and-Disabling-a-Ranger-Policy-using-command/m-p/191108#M153197</guid>
      <dc:creator>rajdip_chaudhur</dc:creator>
      <dc:date>2017-04-07T14:01:23Z</dc:date>
    </item>
    <item>
      <title>Re: Enabling and Disabling a Ranger Policy using command</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Enabling-and-Disabling-a-Ranger-Policy-using-command/m-p/191109#M153198</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/2559/rajdipchaudhuri.html" nodeid="2559"&gt;@rajdip chaudhuri&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I am suspecting that your JSON file "/tmp/10_2.json" has the 
following line as well in it which is not right ... you should remove 
it.&lt;/P&gt;&lt;PRE&gt;HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Set-Cookie: RANGERADMINSESSIONID=EDCBDAFF124C9802A79BFD945662BC1A; Path=/; HttpOnly X-Frame-Options: DENY Content-Type: application/json Transfer-Encoding: chunked Date: Fri, 07 Apr 2017 07:00:49 GMT &lt;/PRE&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;Your  modified JSON file "/tmp/10_2.json" should contain only the JSON data part.  Looks like you have some additional data in it. (No other extra lines).&lt;/P&gt;&lt;PRE&gt;{"id":10,"guid":"c8afaae2-a4cc-4c25-b4b2-75ae9b0227eb","isEnabled":false,"createdBy":"Admin","updatedBy":"Admin","createTime":1491448221000,"updateTime":1491448221000,"version":1,"service":"TCSGEINTERNALCLUSTER_hive","name":"tcs_ge_user data masking test 2","policyType":1,"description":"tcs_ge_user data masking test 2","resourceSignature":"2cb6661609e66abfd9fbceaeac2be9d0","isAuditEnabled":true,"resources":{"database":{"values":["wells_fargo_poc"],"isExcludes":false,"isRecursive":false},"column":{"values":["card_number"],"isExcludes":false,"isRecursive":false},"table":{"values":["test_masked_2"],"isExcludes":false,"isRecursive":false}},"policyItems":[],"denyPolicyItems":[],"allowExceptions":[],"denyExceptions":[],"dataMaskPolicyItems":[{"accesses":[{"type":"select","isAllowed":true}],"users":["tcs_ge_user"],"groups":["tcs_ge_user"],"conditions":[],"delegateAdmin":false,"dataMaskInfo":{"dataMaskType":"MASK_HASH"}}],"rowFilterPolicyItems":[]}&lt;/PRE&gt;&lt;P&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2017 14:09:54 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Enabling-and-Disabling-a-Ranger-Policy-using-command/m-p/191109#M153198</guid>
      <dc:creator>jsensharma</dc:creator>
      <dc:date>2017-04-07T14:09:54Z</dc:date>
    </item>
    <item>
      <title>Re: Enabling and Disabling a Ranger Policy using command</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Enabling-and-Disabling-a-Ranger-Policy-using-command/m-p/191110#M153199</link>
      <description>&lt;P&gt;Yes, you are absolutely correct. Can this part be removed somehow? Actually we are using "sed" to change the flag to false as we are trying to automate the whole process. If you can guide for removing that part then it will be of great help.&lt;/P&gt;&lt;P&gt;Thanks and Rajdip,&lt;/P&gt;&lt;P&gt;Rajdip&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2017 14:13:30 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Enabling-and-Disabling-a-Ranger-Policy-using-command/m-p/191110#M153199</guid>
      <dc:creator>rajdip_chaudhur</dc:creator>
      <dc:date>2017-04-07T14:13:30Z</dc:date>
    </item>
    <item>
      <title>Re: Enabling and Disabling a Ranger Policy using command</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Enabling-and-Disabling-a-Ranger-Policy-using-command/m-p/191111#M153200</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/2559/rajdipchaudhuri.html" nodeid="2559"&gt;@rajdip chaudhuri&lt;/A&gt;&lt;/P&gt;&lt;P&gt;In that case please do not use "-i" option in your curl GET command and redirect the output to a file as following using "-o" option:&lt;/P&gt;&lt;PRE&gt;curl  -u admin:admin -H "Content-Type: application/json" -X GET &lt;A href="http://xx.xx.xx.207:6080/service/plugins/policies/10" target="_blank"&gt;http://xx.xx.xx.207:6080/service/plugins/policies/10&lt;/A&gt;  -o /tmp/10_2.json&lt;/PRE&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;So that you only get the desired data not the response metadata.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2017 14:21:59 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Enabling-and-Disabling-a-Ranger-Policy-using-command/m-p/191111#M153200</guid>
      <dc:creator>jsensharma</dc:creator>
      <dc:date>2017-04-07T14:21:59Z</dc:date>
    </item>
    <item>
      <title>Re: Enabling and Disabling a Ranger Policy using command</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Enabling-and-Disabling-a-Ranger-Policy-using-command/m-p/191112#M153201</link>
      <description>&lt;P&gt;It worked. Thanks a lot. Have also accepted the best answer.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2017 15:01:47 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Enabling-and-Disabling-a-Ranger-Policy-using-command/m-p/191112#M153201</guid>
      <dc:creator>rajdip_chaudhur</dc:creator>
      <dc:date>2017-04-07T15:01:47Z</dc:date>
    </item>
  </channel>
</rss>

