From 9b8dfe435b7f865e41eab4726197799ea282c3f0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?V=C3=A1clav=20Barto=C5=A1?= <bartos@cesnet.cz>
Date: Tue, 3 Jan 2023 13:58:35 +0100
Subject: [PATCH] MISP - use different API key

Use API key of the predefined admin user, instead of the first soctools user (which can be easily removed).
---
 roles/misp/tasks/config.yml | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/roles/misp/tasks/config.yml b/roles/misp/tasks/config.yml
index be9bbde..cb05220 100644
--- a/roles/misp/tasks/config.yml
+++ b/roles/misp/tasks/config.yml
@@ -42,6 +42,12 @@
    misp_api_key: "{{ get_output.stdout }}"
   when: '"initialised" in init_output.stdout'   
 
+- name: Store API key
+  copy:
+    content: "{{ misp_api_key }}"
+    dest: "{{playbook_dir}}/secrets/tokens/misp"
+  delegate_to: 127.0.0.1
+
 - name: add users
   uri:
    url: "https://{{soctoolsproxy}}:6443/admin/users/add/1"
@@ -56,16 +62,6 @@
   with_items:
     - "{{soctools_users}}"
 
-- name: Get user API key
-  shell: '/var/www/MISP/app/Console/cake Admin getAuthkey {{soctools_users[0].email}} | /usr/bin/tail -n1'
-  register: user_key
-
-- name: Store user API key
-  copy:
-    content: "{{ user_key.stdout }}"
-    dest: "{{playbook_dir}}/secrets/tokens/misp"
-  delegate_to: 127.0.0.1
-
 - name: Enable feed
   uri:
    url: "https://{{soctoolsproxy}}:6443/feeds/edit/1"
-- 
GitLab