Usage as a role dependency
The debops.kibana
role can be used as a dependency by other Ansible roles
to manage Kibana main configuration file idempotently. Configuration options
from multiple roles can be merged together and included in the configuration
file, or removed conditionally.
Dependent role variables
The role exposes three default variables that can be used by other Ansible roles as dependent variables:
kibana__dependent_name
Required. Name of the role that uses the
debops.kibana
as a dependency. This will be used to store the configuration in its own YAML dictionary. The selected name shouldn't be changed, otherwise configuration will be desynchronized.kibana__dependent_configuration
Required. List of the Kibana configuration options defined in the same format as the main configuration. See kibana__configuration for more details.
kibana__dependent_state
Optional. If not specified or
present
, the configuration will be included in the/etc/kibana/kibana.yml
configuration file and stored in thesecret/
directory on the Ansible Controller. ifabsent
, the configuration will be removed from the generated configuration file.
Dependent configuration storage and retrieval
The dependent configuration from other roles is stored in the secret/
directory on the Ansible Controller (see debops.secret for more details) in
a JSON file, with each role configuration in a separate dictionary. The
debops.kibana
role reads this file when Ansible local facts indicate that
the Kibana service is installed, otherwise a new empty file is created. This
ensures that the stale configuration is not present on a new or re-installed
host.
The YAML dictionaries from different roles are be merged with the main
configuration in the kibana__combined_configuration
variable that is
used to generate the final configuration. The merge order of the different
kibana__*_configuration
variables allows to further affect the dependent
configuration through Ansible inventory if necessary, therefore the Ansible
roles that use this method don't need to provide additional variables for this
purpose themselves.
Example role variables
This file shows an example set of default variables included in a role that
uses the debops.kibana
role as a dependency:
---
# State of the application deployment
application__deploy_state: 'present'
# Kibana configuration for application
application__kibana__dependent_configuration:
- name: 'application.option'
value: True
- 'application.other.option': False
Example role playbook
This file shows an example playbook for a role that uses the
debops.kibana
role as a dependency:
---
- name: Manage application
collections: [ 'debops.debops' ]
hosts: [ 'debops_service_kibana_application' ]
become: True
environment: '{{ inventory__environment | d({})
| combine(inventory__group_environment | d({}))
| combine(inventory__host_environment | d({})) }}'
pre_tasks:
- name: Prepare kibana environment
ansible.builtin.import_role:
name: 'kibana'
tasks_from: 'main_env'
tags: [ 'role::kibana', 'role::secret', 'role::kibana:config' ]
roles:
- role: secret
tags: [ 'role::secret', 'role::kibana', 'role::kibana:config' ]
secret__directories:
- '{{ kibana__secret__directories }}'
- role: kibana
tags: [ 'role::kibana' ]
kibana__dependent_role: 'application'
kibana__dependent_state: '{{ application__deploy_state }}'
kibana__dependent_configuration:
- '{{ application__kibana__dependent_configuration }}'
- role: application
tags: [ 'role::application' ]