Security

how to add new role from CLI

imrago
Contributor

How could I add a new role from the CLI or REST API?

I am adding new users externally from a script and some of them needs to have a new separate role with Restricted search terms.

One solution could be to change the conf files and restart Splunk. Is there a more elegant answer to my problem?

Tags (3)
1 Solution

Ayn
Legend

As far as I know there is no such functionality built in as a CLI parameter, however if you want to add roles programatically you can use the REST API: http://docs.splunk.com/Documentation/Splunk/latest/RESTAPI/RESTaccess#authorization.2Froles

View solution in original post

drutstein
Explorer

You can do this a couple ways:

Through the CLI you can use the Splunk_TA_aws/bin/tools/configure/configure.py script with the following command:

/opt/splunk/bin/splunk cmd python aws_config_cli.py iam-role create --config-file input.json --hostname localhost

Create your input.json and splunk-info.json files based on the samples found in Splunk_TA_aws/bin/tools/configure/config_examples


You can also manually edit the password.conf and splunk_ta_aws_iam_roles.conf files in Splunk_TA_aws/local

Here's a passwords.conf example:

[credential:__REST_CREDENTIAL__#Splunk_TA_aws#configs/conf-splunk_ta_aws_iam_roles#BaseRestHandler:my-iam-role:]
password =

Here's a splunk_ta_aws_iam_roles.conf example:

[my-iam-role]
arn = arn:aws:iam::<aws_account_id>:role/my-iam-role

They key is to leave the password entry blank since the "credential" value isn't encrypted.

0 Karma

Ayn
Legend

As far as I know there is no such functionality built in as a CLI parameter, however if you want to add roles programatically you can use the REST API: http://docs.splunk.com/Documentation/Splunk/latest/RESTAPI/RESTaccess#authorization.2Froles

Ayn
Legend

Correcting myself here - while there is no 'shortcut' to doing this using the CLI, what you can do is issue REST requests using the CLI. See this blog post: http://blogs.splunk.com/2009/12/10/poke-at-our-api/

0 Karma

rroberts
Splunk Employee
Splunk Employee

Do you not have SplunkWeb access? You can add roles directly via the manager view.

http://localhost:8000/splunk/en-US/manager/launcher/authentication/roles/_new?action=edit&ns=launche...

0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...