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!

This Week's Community Digest - Splunk Community Happenings [9.26.22]

Get the latest news and updates from the Splunk Community here! Upcoming User Group Events! &#x1f44f; Check ...

BSides Splunk 2022 - The Call for Papers is now Open!

TLDR; Main Site: https://bsidessplunk.com CFP Site: https://bsidessplunk.com/cfp CFP Opens: December 15th, ...

Sending Metrics to Splunk Enterprise With the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. The OpenTelemetry project is the second largest ...