Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions molecule/elasticsearch_no-security/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,31 @@
- name: Include Elasticsearch
ansible.builtin.include_role:
name: oddly.elasticstack.elasticsearch

# Coverage for the `not ansible_check_mode` guards #154 added to the
# `Start Elasticsearch` and `Handle cluster setup without security`
# tasks/blocks, plus the `check_mode: false` shield this PR adds to
# the cluster-settings URI. Re-running the role with check_mode: true
# on the outer block previously exploded on the `.json` reference in
# elasticsearch-cluster-settings.yml because the URI honoured the
# check-mode override and returned without a body.
- name: "Re-include ES role in check mode (regression cover for #154)"
hosts: all
vars:
elasticsearch_security: false
elasticstack_security: false
elasticsearch_heap: "1"
elasticstack_release: "{{ lookup('env', 'ELASTIC_RELEASE') | default('9', true) | int }}"
elasticstack_no_log: false
elasticstack_elasticsearch_group_name: elasticsearchXYZ
tasks:
- name: Reset shared role import guard for re-run
ansible.builtin.set_fact:
_elasticstack_role_imported: false

- name: Wrap the re-include so check_mode propagates
check_mode: true
block:
- name: Re-include Elasticsearch in check mode
ansible.builtin.include_role:
name: oddly.elasticstack.elasticsearch
8 changes: 7 additions & 1 deletion roles/elasticsearch/tasks/elasticsearch-cluster-settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,19 @@
validate_certs: "{{ elasticsearch_validate_api_certs }}"
return_content: true
register: _elasticsearch_current_cluster_settings
# The uri module honours check_mode inherited from a block/task-level
# override even when the play itself is not in --check, and returns
# without hitting the endpoint. `.json` is then missing on the
# registered result; guard the downstream compare so a per-block
# check_mode caller doesn't crash us.
check_mode: false
no_log: "{{ elasticstack_no_log }}"

- name: elasticsearch-cluster-settings | Check if settings already match
ansible.builtin.set_fact:
_elasticsearch_cluster_settings_changed: "{{ _needs_update | trim }}"
vars:
_current: "{{ _elasticsearch_current_cluster_settings.json.persistent }}"
_current: "{{ (_elasticsearch_current_cluster_settings.json | default({})).persistent | default({}) }}"
_needs_update: >-
{% set ns = namespace(changed=false) %}
{% for key, value in _elasticsearch_effective_cluster_settings.items() %}
Expand Down
Loading