<?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>topic Re: Constructing URL to add a splunk user via REST (or via ansible uri mod) in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Constructing-URL-to-add-a-splunk-user-via-REST-or-via-ansible/m-p/380124#M173948</link>
    <description>&lt;P&gt;Hey guys. I got it!&lt;/P&gt;

&lt;P&gt;So i have an ansible playbook as such:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;---
- name: Add Splunk Users via REST API
  uri:
    url: &lt;A href="https://localhost:8089/services/authentication/users" target="test_blank"&gt;https://localhost:8089/services/authentication/users&lt;/A&gt;
    method: POST
    validate_certs: no
    user: "{{ splunk_admin_user }}"
    password: "{{ splunk_admin_pass }}"
    body: "realname={{ item.comment }}&amp;amp;name={{ item.username }}&amp;amp;password={{ item.splunk_pass }}&amp;amp;roles=admin&amp;amp;email={{ item.email }}"
    force_basic_auth: yes
    status_code: 201,400
    headers:
      Content-Type: "application/x-www-form-urlencoded"
  with_items:
    - "{{ users }}"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Create an ansible dictionary variable:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;---
users:
  - { username: "123456789", splunk_pass: "bobsuncle", email: "new.user@domain.com", comment: "User, New" }
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Call that file at invocation of the playbook with -e @varfile.yml.&lt;/P&gt;

&lt;P&gt;This may seem like overkill but this allows me to manage outlier accounts on hundreds of servers, ansible style. I like doing it this way because the uri module is very flex and alows you to capture allot about the event, most namely to accept certain https exit codes as "OK".&lt;/P&gt;

&lt;P&gt;Hopefully this helps someone else out.&lt;/P&gt;</description>
    <pubDate>Mon, 24 Dec 2018 00:49:42 GMT</pubDate>
    <dc:creator>brent_weaver</dc:creator>
    <dc:date>2018-12-24T00:49:42Z</dc:date>
    <item>
      <title>Constructing URL to add a splunk user via REST (or via ansible uri mod)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Constructing-URL-to-add-a-splunk-user-via-REST-or-via-ansible/m-p/380120#M173944</link>
      <description>&lt;P&gt;So I need to add a bunch of local users to Splunk. We are an ansible shop, and we can leverage the uri modue:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;---

- name: Add Splunk Users
  uri:
    url: &lt;A href="https://localhost:8089/services/authentication/users" target="test_blank"&gt;https://localhost:8089/services/authentication/users&lt;/A&gt;
    method: POST
    validate_certs: no
    user: admin
    password: jonesville
    body: '{ name: "brent", password: "jonesville", roles: "admin" }'
    force_basic_auth: yes
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This does not work. How can I construct the body to take my input and add the user as necessary? I could also maybe string a whole url together and POST?!?!&lt;/P&gt;

&lt;P&gt;Any advice is MUCH appreciated.&lt;/P&gt;</description>
      <pubDate>Sat, 22 Dec 2018 21:31:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Constructing-URL-to-add-a-splunk-user-via-REST-or-via-ansible/m-p/380120#M173944</guid>
      <dc:creator>brent_weaver</dc:creator>
      <dc:date>2018-12-22T21:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: Constructing URL to add a splunk user via REST (or via ansible uri mod)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Constructing-URL-to-add-a-splunk-user-via-REST-or-via-ansible/m-p/380121#M173945</link>
      <description>&lt;P&gt;Which version of Splunk?  7.x introduced a new process that involves a seed file.&lt;/P&gt;</description>
      <pubDate>Sun, 23 Dec 2018 15:11:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Constructing-URL-to-add-a-splunk-user-via-REST-or-via-ansible/m-p/380121#M173945</guid>
      <dc:creator>jkat54</dc:creator>
      <dc:date>2018-12-23T15:11:34Z</dc:date>
    </item>
    <item>
      <title>Re: Constructing URL to add a splunk user via REST (or via ansible uri mod)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Constructing-URL-to-add-a-splunk-user-via-REST-or-via-ansible/m-p/380122#M173946</link>
      <description>&lt;P&gt;This is 7.2, but this is post install, i got the seed part down (and thats a nice feature)&lt;/P&gt;</description>
      <pubDate>Sun, 23 Dec 2018 18:53:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Constructing-URL-to-add-a-splunk-user-via-REST-or-via-ansible/m-p/380122#M173946</guid>
      <dc:creator>brent_weaver</dc:creator>
      <dc:date>2018-12-23T18:53:37Z</dc:date>
    </item>
    <item>
      <title>Re: Constructing URL to add a splunk user via REST (or via ansible uri mod)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Constructing-URL-to-add-a-splunk-user-via-REST-or-via-ansible/m-p/380123#M173947</link>
      <description>&lt;P&gt;Hey! Do you have debug  logs by any chance? would love to check the uri that is constructed against:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/RESTUM/RESTusing#URI_encoding"&gt;https://docs.splunk.com/Documentation/Splunk/latest/RESTUM/RESTusing#URI_encoding&lt;/A&gt;&lt;BR /&gt;
&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/RESTREF/RESTaccess#authentication.2Fusers"&gt;https://docs.splunk.com/Documentation/Splunk/latest/RESTREF/RESTaccess#authentication.2Fusers&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Dec 2018 19:26:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Constructing-URL-to-add-a-splunk-user-via-REST-or-via-ansible/m-p/380123#M173947</guid>
      <dc:creator>mattymo</dc:creator>
      <dc:date>2018-12-23T19:26:23Z</dc:date>
    </item>
    <item>
      <title>Re: Constructing URL to add a splunk user via REST (or via ansible uri mod)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Constructing-URL-to-add-a-splunk-user-via-REST-or-via-ansible/m-p/380124#M173948</link>
      <description>&lt;P&gt;Hey guys. I got it!&lt;/P&gt;

&lt;P&gt;So i have an ansible playbook as such:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;---
- name: Add Splunk Users via REST API
  uri:
    url: &lt;A href="https://localhost:8089/services/authentication/users" target="test_blank"&gt;https://localhost:8089/services/authentication/users&lt;/A&gt;
    method: POST
    validate_certs: no
    user: "{{ splunk_admin_user }}"
    password: "{{ splunk_admin_pass }}"
    body: "realname={{ item.comment }}&amp;amp;name={{ item.username }}&amp;amp;password={{ item.splunk_pass }}&amp;amp;roles=admin&amp;amp;email={{ item.email }}"
    force_basic_auth: yes
    status_code: 201,400
    headers:
      Content-Type: "application/x-www-form-urlencoded"
  with_items:
    - "{{ users }}"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Create an ansible dictionary variable:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;---
users:
  - { username: "123456789", splunk_pass: "bobsuncle", email: "new.user@domain.com", comment: "User, New" }
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Call that file at invocation of the playbook with -e @varfile.yml.&lt;/P&gt;

&lt;P&gt;This may seem like overkill but this allows me to manage outlier accounts on hundreds of servers, ansible style. I like doing it this way because the uri module is very flex and alows you to capture allot about the event, most namely to accept certain https exit codes as "OK".&lt;/P&gt;

&lt;P&gt;Hopefully this helps someone else out.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Dec 2018 00:49:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Constructing-URL-to-add-a-splunk-user-via-REST-or-via-ansible/m-p/380124#M173948</guid>
      <dc:creator>brent_weaver</dc:creator>
      <dc:date>2018-12-24T00:49:42Z</dc:date>
    </item>
  </channel>
</rss>

