Make some test queries do by using admin; change index output

The es_username is used by the logsender to push data to the OpenSearch.
Currently, the tests are using admin user to do that, but in the future
it will be replaced by dedidacated user, that will have limited access.
This commit is providing new variables just for the current tests to
execute command as admin user.
Also this commit also fix an issue when the es_index_prefix is set.

Change-Id: I4759f6ee009e3ef32160a79f9da742a78576161e
This commit is contained in:
Daniel Pawlik 2024-04-30 14:00:33 +02:00
parent db57e103e6
commit 3ac0c035e8
No known key found for this signature in database
2 changed files with 14 additions and 12 deletions

View File

@ -19,6 +19,8 @@
es_index: logstash-logscraper
logscraper_dir: /etc/logscraper
subunit_index_prefix: "subunit-"
es_admin_username: admin
es_admin_password: admin
tasks:
- name: Run check services
include_role:

View File

@ -18,8 +18,8 @@
- name: Get indices - es_index
uri:
url: "https://{{ item.es_host }}:{{ item.es_port }}/_cat/indices"
user: "{{ item.es_username }}"
password: "{{ item.es_password }}"
user: "{{ item.es_admin_username }}"
password: "{{ item.es_admin_password }}"
force_basic_auth: true
method: GET
validate_certs: false
@ -35,8 +35,8 @@
- name: Check if build_branch exists in index content - es_index
uri:
url: "https://{{ item.es_host }}:{{ item.es_port }}/{{ item.es_index }}"
user: "{{ item.es_username }}"
password: "{{ item.es_password }}"
user: "{{ item.es_admin_username }}"
password: "{{ item.es_admin_password }}"
force_basic_auth: true
method: GET
validate_certs: false
@ -52,8 +52,8 @@
- name: Get indices - es_index_prefix
uri:
url: "https://{{ item.es_host }}:{{ item.es_port }}/_cat/indices"
user: "{{ item.es_username }}"
password: "{{ item.es_password }}"
user: "{{ item.es_admin_username }}"
password: "{{ item.es_admin_password }}"
force_basic_auth: true
method: GET
validate_certs: false
@ -67,12 +67,12 @@
when: "'es_index_prefix' in item and item.es_index_prefix"
# The es_index_prefix looks like: logstash-logscraper-
# Where the full indices in OpenSearch looks like: logstash-logscraper-2024-04-30
# Where the full indices in OpenSearch looks like: logstash-logscraper-2024.04.30
- name: Check if build_branch exists in index content - es_index_prefix
uri:
url: "https://{{ item.es_host }}:{{ item.es_port }}/{{ item.es_index_prefix }}{{ now(utc=true,fmt='%Y-%m-%d') }}"
user: "{{ item.es_username }}"
password: "{{ item.es_password }}"
url: "https://{{ item.es_host }}:{{ item.es_port }}/{{ item.es_index_prefix }}{{ now(utc=true,fmt='%Y.%m.%d') }}"
user: "{{ item.es_admin_username }}"
password: "{{ item.es_admin_password }}"
force_basic_auth: true
method: GET
validate_certs: false
@ -107,8 +107,8 @@
- name: Get indices to fail the test
uri:
url: "https://{{ item.es_host }}:{{ item.es_port }}/_cat/indices"
user: "{{ item.es_username }}"
password: "{{ item.es_password }}"
user: "{{ item.es_admin_username }}"
password: "{{ item.es_admin_password }}"
force_basic_auth: true
method: GET
validate_certs: false