Skip to content
Snippets Groups Projects
Commit b957d291 authored by Jenkins's avatar Jenkins Committed by Gerrit Code Review
Browse files

Merge "Optimize reconfiguration for grafana"

parents 8884422f 43813b8a
No related branches found
No related tags found
No related merge requests found
--- ---
project_name: "grafana" project_name: "grafana"
grafana_services:
grafana:
container_name: grafana
group: grafana
enabled: true
image: "{{ grafana_image_full }}"
volumes:
- "{{ node_config_directory }}/grafana/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "grafana:/var/lib/grafana/"
- "kolla_logs:/var/log/kolla/"
#################### ####################
# Database # Database
#################### ####################
......
---
- name: Restart grafana container
vars:
service_name: "grafana"
service: "{{ grafana_services[service_name] }}"
config_json: "{{ grafana_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
grafana_conf: "{{ grafana_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
grafana_container: "{{ check_grafana_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 grafana_ini.changed | bool
or grafana_container.changed | bool
--- ---
- name: Ensuring config directories exist - name: Ensuring config directories exist
file: file:
path: "{{ node_config_directory }}/{{ item }}" path: "{{ node_config_directory }}/{{ item.key }}"
state: "directory" state: "directory"
recurse: yes recurse: yes
with_items: when:
- "grafana" - inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ grafana_services }}"
- name: Copying over config.json files - name: Copying over config.json files
template: template:
src: "{{ item }}.json.j2" src: "{{ item.key }}.json.j2"
dest: "{{ node_config_directory }}/{{ item }}/config.json" dest: "{{ node_config_directory }}/{{ item.key }}/config.json"
with_items: register: grafana_config_jsons
- "grafana" when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ grafana_services }}"
notify:
- Restart grafana container
- name: Copying over grafana.ini - name: Copying over grafana.ini
merge_configs: merge_configs:
vars: vars:
service_name: "{{ item }}" service_name: "{{ item.key }}"
sources: sources:
- "{{ role_path }}/templates/grafana.ini.j2" - "{{ role_path }}/templates/grafana.ini.j2"
- "{{ node_custom_config }}/{{ item }}.ini" - "{{ node_custom_config }}/{{ item.key }}.ini"
- "{{ node_custom_config }}/grafana/{{ inventory_hostname }}/{{ item }}.ini" - "{{ node_custom_config }}/grafana/{{ inventory_hostname }}/{{ item.key }}.ini"
dest: "{{ node_config_directory }}/grafana/grafana.ini" dest: "{{ node_config_directory }}/grafana/grafana.ini"
with_items: register: grafana_confs
- "grafana" when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ grafana_services }}"
notify:
- Restart grafana container
- name: Check grafana 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_grafana_containers
when:
- action != "config"
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ grafana_services }}"
notify:
- Restart grafana container
...@@ -5,5 +5,5 @@ ...@@ -5,5 +5,5 @@
- include: bootstrap.yml - include: bootstrap.yml
when: inventory_hostname in groups['grafana'] when: inventory_hostname in groups['grafana']
- include: start.yml - name: Flush handlers
when: inventory_hostname in groups['grafana'] meta: flush_handlers
--- ---
- name: Ensuring the containers up - include: deploy.yml
kolla_docker:
name: "grafana"
action: "get_container_state"
register: container_state
failed_when: container_state.Running == false
when: inventory_hostname in groups['grafana']
- include: config.yml
- name: Check the configs
command: docker exec grafana /usr/local/bin/kolla_set_configs --check
changed_when: false
failed_when: false
register: check_results
when: inventory_hostname in groups['grafana']
# 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: "grafana"
action: "get_container_env"
register: container_envs
when: inventory_hostname in groups['grafana']
- name: Remove the containers
kolla_docker:
name: "grafana"
action: "remove_container"
register: remove_containers
when:
- config_strategy == "COPY_ONCE"
- inventory_hostname in groups['grafana']
- include: start.yml
when: remove_containers.changed
- name: Restart containers
kolla_docker:
name: "grafana"
action: "restart_container"
when:
- config_strategy == 'COPY_ALWAYS'
- inventory_hostname in groups['grafana']
---
- name: Starting grafana container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ grafana_image_full }}"
name: "grafana"
volumes:
- "{{ node_config_directory }}/grafana/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "grafana:/var/lib/grafana/"
- "kolla_logs:/var/log/kolla/"
when: inventory_hostname in groups['grafana']
--- ---
- include: config.yml - include: config.yml
- include: start.yml - name: Flush handlers
meta: flush_handlers
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment