adminuser.yml 1.22 KB
Newer Older
Arne Øslebø's avatar
Arne Øslebø committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
---

- name: copy json file for admin user
  remote_user: root
  template:
    src: admin.json
    dest: /tmp/admin.json

- name: get admin user id
  remote_user: root
  shell: "curl -X POST http://127.0.0.1:9000/api/login -b /tmp/cookie.txt -c /tmp/cookie.txt -H 'Content-Type: application/json' -d @/tmp/admin.json | cut -d\\\" -f4"
  register: adminuser
  args:
    warn: false

- set_fact:
    adminuserid={{ adminuser.stdout }}

- name: create admin user API KEY
  shell: "curl -X POST http://127.0.0.1:9000/api/v1/user/{{ adminuserid }}/key/renew -b /tmp/cookie.txt -c /tmp/cookie.txt 2> /dev/null | tee /tmp/thehive_secret_key"
  register: adminuserkey
  args:
    warn: false

- set_fact:
    adminuserapikey={{ adminuserkey.stdout }}

- name: copy API key to local file
  local_action: copy content="{{adminuserapikey}}" dest=secrets/tokens/thehive_secret_key

- name: copy json file for admin pass
  remote_user: root
  template:
    src: adminpass.json
    dest: /tmp/adminpass.json

- name: change password for admin user
  shell: "curl -X POST http://127.0.0.1:9000/api/v1/user/{{ adminuserid }}/password/set -b /tmp/cookie.txt -c /tmp/cookie.txt -H 'Content-Type: application/json' -d @/tmp/adminpass.json"
  args:
    warn: false