From 354081e2f64073cf646f9dd47ba75f6deb4738c8 Mon Sep 17 00:00:00 2001 From: Jared Ledvina Date: Sun, 29 Mar 2020 13:51:44 -0400 Subject: [PATCH] Sensu: Ensure we initialize the backend w/ the normal defaults Signed-off-by: Jared Ledvina --- defaults/main.yml | 3 +++ tasks/service/backend.yml | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/defaults/main.yml b/defaults/main.yml index b95b4b5..bb8dec5 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -98,6 +98,9 @@ sensu_go_configs: - ws://127.0.0.1:8081 cache-dir: /var/cache/sensu/sensu-agent +sensu_go_backend_init_admin_username: admin +sensu_go_backend_init_admin_password: P@ssw0rd! + sensu_go_services_override: {} sensu_go_services: backend: diff --git a/tasks/service/backend.yml b/tasks/service/backend.yml index 72ef56d..98c0d87 100644 --- a/tasks/service/backend.yml +++ b/tasks/service/backend.yml @@ -17,3 +17,13 @@ when: - sensu_go_services.backend.state == 'started' - sensu_go_backend_service_state is changed + +- name: Ensure sensu-backend is initialized + command: + cmd: sensu-backend init + environment: + SENSU_BACKEND_CLUSTER_ADMIN_USERNAME: "{{ sensu_go_backend_init_admin_username }}" + SENSU_BACKEND_CLUSTER_ADMIN_PASSWORD: "{{ sensu_go_backend_init_admin_password }}" + register: sensu_backend_init_result + failed_when: sensu_backend_init_result.rc not in (0, 3) + changed_when: sensu_backend_init_result.rc == 0