diff options
| author | Piotr Milewski <vurmil@gmail.com> | 2026-04-27 11:15:19 +0200 |
|---|---|---|
| committer | Piotr Milewski <vurmil@gmail.com> | 2026-04-27 18:42:02 +0200 |
| commit | 20c6740bfc8245a304e8d2a7f630269c31e3918f (patch) | |
| tree | 7536a90692eee44fa114adaf4e52143b28d07b0c /ansible | |
| parent | 33fe6fc5a6c5b71b5d3d4bbeb1eb2ed0de00441a (diff) | |
| download | kolla-ansible-20c6740bfc8245a304e8d2a7f630269c31e3918f.tar.gz kolla-ansible-20c6740bfc8245a304e8d2a7f630269c31e3918f.zip | |
opensearch: automate index pattern creation in dashboards
Previously, operators had to manually create the default index
pattern after the first login to OpenSearch Dashboards.
This commit automates the creation of the default index pattern
using the OpenSearch Dashboards Saved Objects API during the
post-config phase. The pattern is dynamically named based on the
opensearch_log_index_prefix variable (defaulting to "flog-*")
and automatically sets "@timestamp" as the time field.
Documentation has been updated to reflect that the first-login
manual setup is no longer required for the default log indices.
Change-Id: I8d49a270ace187b3b13103452e93d305505f6cbb
Signed-off-by: Piotr Milewski <vurmil@gmail.com>
Diffstat (limited to 'ansible')
| -rw-r--r-- | ansible/roles/opensearch/tasks/post-config.yml | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/ansible/roles/opensearch/tasks/post-config.yml b/ansible/roles/opensearch/tasks/post-config.yml index f35b36f78..290e88365 100644 --- a/ansible/roles/opensearch/tasks/post-config.yml +++ b/ansible/roles/opensearch/tasks/post-config.yml @@ -87,3 +87,30 @@ when: - not ansible_check_mode - opensearch_retention_policy_check.status == 404 + +- name: Create OpenSearch Dashboards Index Pattern + become: true + kolla_toolbox: + container_engine: "{{ kolla_container_engine }}" + module_name: uri + module_args: + url: "{{ opensearch_dashboards_internal_endpoint }}/api/saved_objects/index-pattern/{{ opensearch_log_index_prefix }}-pattern" + method: POST + status_code: 200, 409 + url_username: "{{ opensearch_dashboards_user }}" + url_password: "{{ opensearch_dashboards_password }}" + force_basic_auth: true + headers: + osd-xsrf: "true" + body: + attributes: + title: "{{ opensearch_log_index_prefix }}-*" + timeFieldName: "@timestamp" + body_format: json + ca_path: "{{ openstack_cacert }}" + register: opensearch_index_pattern_create + changed_when: opensearch_index_pattern_create.status == 200 + delegate_to: "{{ groups['opensearch'][0] }}" + run_once: true + when: + - not ansible_check_mode |
