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!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...