Optimize reconfiguration for kibana
Change-Id: Ic4beb20361644b42dbed82fcffb7446c00f84e87 Partially-implements: blueprint better-reconfigure
This commit is contained in:
parent
d7bc9a01ad
commit
13eed1ba57
@ -1,4 +1,18 @@
|
||||
---
|
||||
project_name: "Kibana"
|
||||
|
||||
kibana_services:
|
||||
kibana:
|
||||
container_name: "kibana"
|
||||
image: "{{ kibana_image_full }}"
|
||||
enabled: true
|
||||
group: "kibana"
|
||||
volumes:
|
||||
- "{{ node_config_directory }}/kibana/:{{ container_config_directory }}/:ro"
|
||||
- "/etc/localtime:/etc/localtime:ro"
|
||||
- "kolla_logs:/var/log/kolla/"
|
||||
|
||||
|
||||
####################
|
||||
# Kibana
|
||||
####################
|
||||
|
21
ansible/roles/kibana/handlers/main.yml
Normal file
21
ansible/roles/kibana/handlers/main.yml
Normal file
@ -0,0 +1,21 @@
|
||||
---
|
||||
- name: Restart kibana container
|
||||
vars:
|
||||
service_name: "kibana"
|
||||
service: "{{ kibana_services[service_name] }}"
|
||||
config_json: "{{ kibana_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||
kibana_conf: "{{ kibana_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||
kibana_container: "{{ check_kibana_containers.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||
kolla_docker:
|
||||
action: "recreate_or_restart_container"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
name: "{{ service.container_name }}"
|
||||
image: "{{ service.image }}"
|
||||
volumes: "{{ service.volumes }}"
|
||||
when:
|
||||
- action != "config"
|
||||
- inventory_hostname in groups[service.group]
|
||||
- service.enabled | bool
|
||||
- config_json.changed | bool
|
||||
or kibana_conf.changed | bool
|
||||
or kibana_container.changed | bool
|
@ -1,22 +1,50 @@
|
||||
---
|
||||
- name: Ensuring kibana config directories exist
|
||||
file:
|
||||
path: "{{ node_config_directory }}/{{ item }}"
|
||||
path: "{{ node_config_directory }}/{{ item.key }}"
|
||||
state: "directory"
|
||||
recurse: yes
|
||||
with_items:
|
||||
- "kibana"
|
||||
when:
|
||||
- inventory_hostname in groups[item.value.group]
|
||||
- item.value.enabled | bool
|
||||
with_dict: "{{ kibana_services }}"
|
||||
|
||||
- name: Copying over config.json files for services
|
||||
template:
|
||||
src: "{{ item }}.json.j2"
|
||||
dest: "{{ node_config_directory }}/{{ item }}/config.json"
|
||||
with_items:
|
||||
- "kibana"
|
||||
src: "{{ item.key }}.json.j2"
|
||||
dest: "{{ node_config_directory }}/{{ item.key }}/config.json"
|
||||
register: kibana_config_json
|
||||
when:
|
||||
- inventory_hostname in groups[item.value.group]
|
||||
- item.value.enabled | bool
|
||||
with_dict: "{{ kibana_services }}"
|
||||
notify:
|
||||
- Restart kibana container
|
||||
|
||||
- name: Copying over Kibana configuration file
|
||||
template:
|
||||
src: "{{ item }}.yml.j2"
|
||||
dest: "{{ node_config_directory }}/{{ item }}/{{ item }}.yml"
|
||||
with_items:
|
||||
- "kibana"
|
||||
src: "{{ item.key }}.yml.j2"
|
||||
dest: "{{ node_config_directory }}/{{ item.key }}/{{ item.key }}.yml"
|
||||
register: kibana_confs
|
||||
when:
|
||||
- inventory_hostname in groups[item.value.group]
|
||||
- item.value.enabled | bool
|
||||
with_dict: "{{ kibana_services }}"
|
||||
notify:
|
||||
- Restart kibana container
|
||||
|
||||
- name: Check kibana containers
|
||||
kolla_docker:
|
||||
action: "compare_container"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
name: "{{ item.value.container_name }}"
|
||||
image: "{{ item.value.image }}"
|
||||
volumes: "{{ item.value.volumes }}"
|
||||
register: check_kibana_containers
|
||||
when:
|
||||
- action != "config"
|
||||
- inventory_hostname in groups[item.value.group]
|
||||
- item.value.enabled | bool
|
||||
with_dict: "{{ kibana_services }}"
|
||||
notify:
|
||||
- Restart kibana container
|
||||
|
@ -1,4 +1,5 @@
|
||||
---
|
||||
- include: config.yml
|
||||
|
||||
- include: start.yml
|
||||
- name: Flush handlers
|
||||
meta: flush_handlers
|
||||
|
@ -3,4 +3,8 @@
|
||||
kolla_docker:
|
||||
action: "pull_image"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
image: "{{ kibana_image_full }}"
|
||||
image: "{{ item.value.image }}"
|
||||
when:
|
||||
- inventory_hostname in groups[item.value.group]
|
||||
- item.value.enabled | bool
|
||||
with_dict: "{{ kibana_services }}"
|
||||
|
@ -1,64 +1,2 @@
|
||||
---
|
||||
- name: Ensuring the containers up
|
||||
kolla_docker:
|
||||
name: "{{ item.name }}"
|
||||
action: "get_container_state"
|
||||
register: container_state
|
||||
failed_when: container_state.Running == false
|
||||
when: inventory_hostname in groups[item.group]
|
||||
with_items:
|
||||
- { name: kibana, group: kibana }
|
||||
|
||||
- include: config.yml
|
||||
|
||||
- name: Check the configs
|
||||
command: docker exec {{ item.name }} /usr/local/bin/kolla_set_configs --check
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
register: check_results
|
||||
when: inventory_hostname in groups[item.group]
|
||||
with_items:
|
||||
- { name: kibana, group: kibana }
|
||||
|
||||
# NOTE(jeffrey4l): when config_strategy == 'COPY_ALWAYS'
|
||||
# and container env['KOLLA_CONFIG_STRATEGY'] == 'COPY_ONCE',
|
||||
# just remove the container and start again
|
||||
- name: Containers config strategy
|
||||
kolla_docker:
|
||||
name: "{{ item.name }}"
|
||||
action: "get_container_env"
|
||||
register: container_envs
|
||||
when: inventory_hostname in groups[item.group]
|
||||
with_items:
|
||||
- { name: kibana, group: kibana }
|
||||
|
||||
- name: Remove the containers
|
||||
kolla_docker:
|
||||
name: "{{ item[0]['name'] }}"
|
||||
action: "remove_container"
|
||||
register: remove_containers
|
||||
when:
|
||||
- config_strategy == "COPY_ONCE" or item[1]['KOLLA_CONFIG_STRATEGY'] == 'COPY_ONCE'
|
||||
- item[2]['rc'] == 1
|
||||
- inventory_hostname in groups[item[0]['group']]
|
||||
with_together:
|
||||
- [{ name: kibana, group: kibana }]
|
||||
- "{{ container_envs.results }}"
|
||||
- "{{ check_results.results }}"
|
||||
|
||||
- include: start.yml
|
||||
when: remove_containers.changed
|
||||
|
||||
- name: Restart containers
|
||||
kolla_docker:
|
||||
name: "{{ item[0]['name'] }}"
|
||||
action: "restart_container"
|
||||
when:
|
||||
- config_strategy == 'COPY_ALWAYS'
|
||||
- item[1]['KOLLA_CONFIG_STRATEGY'] != 'COPY_ONCE'
|
||||
- item[2]['rc'] == 1
|
||||
- inventory_hostname in groups[item[0]['group']]
|
||||
with_together:
|
||||
- [{ name: kibana, group: kibana }]
|
||||
- "{{ container_envs.results }}"
|
||||
- "{{ check_results.results }}"
|
||||
- include: deploy.yml
|
||||
|
@ -1,11 +0,0 @@
|
||||
---
|
||||
- name: Starting Kibana container
|
||||
kolla_docker:
|
||||
action: "start_container"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
image: "{{ kibana_image_full }}"
|
||||
name: "kibana"
|
||||
volumes:
|
||||
- "{{ node_config_directory }}/kibana/:{{ container_config_directory }}/:ro"
|
||||
- "/etc/localtime:/etc/localtime:ro"
|
||||
- "kolla_logs:/var/log/kolla/"
|
@ -1,4 +1,5 @@
|
||||
---
|
||||
- include: config.yml
|
||||
|
||||
- include: start.yml
|
||||
- name: Flush handlers
|
||||
meta: flush_handlers
|
||||
|
Loading…
Reference in New Issue
Block a user