Optimize reconfiguration for influxdb
Co-Authored-By: caoyuan <cao.yuan@99cloud.net> Change-Id: I8855edd9e6f71012b53cda6720a4ba3e08f166e8 Partially-implements: blueprint better-reconfigure
This commit is contained in:
parent
b87502b9c8
commit
5ecae12fec
@ -1,6 +1,19 @@
|
||||
---
|
||||
project_name: "influxdb"
|
||||
|
||||
influxdb_services:
|
||||
influxdb:
|
||||
container_name: influxdb
|
||||
group: influxdb
|
||||
enabled: true
|
||||
image: "{{ influxdb_image_full }}"
|
||||
volumes:
|
||||
- "{{ node_config_directory }}/influxdb/:{{ container_config_directory }}/:ro"
|
||||
- "/etc/localtime:/etc/localtime:ro"
|
||||
- "influxdb:/var/lib/influxdb"
|
||||
- "kolla_logs:/var/log/kolla/"
|
||||
|
||||
|
||||
####################
|
||||
# Docker
|
||||
####################
|
||||
|
20
ansible/roles/influxdb/handlers/main.yml
Normal file
20
ansible/roles/influxdb/handlers/main.yml
Normal file
@ -0,0 +1,20 @@
|
||||
---
|
||||
- name: Restart influxdb container
|
||||
vars:
|
||||
service_name: "influxdb"
|
||||
service: "{{ influxdb_services[service_name] }}"
|
||||
config_json: "{{ influxdb_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||
influxdb_container: "{{ check_influxdb_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 influxdb_confs.changed | bool
|
||||
or influxdb_container.changed | bool
|
@ -4,20 +4,50 @@
|
||||
path: "{{ node_config_directory }}/influxdb"
|
||||
state: "directory"
|
||||
recurse: yes
|
||||
when: inventory_hostname in groups['influxdb']
|
||||
when:
|
||||
- inventory_hostname in groups[item.value.group]
|
||||
- item.value.enabled | bool
|
||||
with_dict: "{{ influxdb_services }}"
|
||||
|
||||
- name: Copying over config.json files
|
||||
template:
|
||||
src: "{{ item }}.json.j2"
|
||||
src: "{{ item.key }}.json.j2"
|
||||
dest: "{{ node_config_directory }}/influxdb/config.json"
|
||||
when: inventory_hostname in groups['influxdb']
|
||||
with_items:
|
||||
- influxdb
|
||||
register: influxdb_config_jsons
|
||||
when:
|
||||
- inventory_hostname in groups[item.value.group]
|
||||
- item.value.enabled | bool
|
||||
with_dict: "{{ influxdb_services }}"
|
||||
notify:
|
||||
- Restart influxdb container
|
||||
|
||||
- name: Copying over influxdb config file
|
||||
vars:
|
||||
service: "{{ influxdb_services['influxdb']}}"
|
||||
template:
|
||||
src: "{{ role_path }}/templates/{{ item }}.conf.j2"
|
||||
dest: "{{ node_config_directory }}/influxdb/influxdb.conf"
|
||||
when: inventory_hostname in groups['influxdb']
|
||||
register: influxdb_confs
|
||||
when:
|
||||
- inventory_hostname in groups[service.group]
|
||||
- service.enabled | bool
|
||||
with_items:
|
||||
- influxdb
|
||||
- "influxdb"
|
||||
notify:
|
||||
- Restart influxdb container
|
||||
|
||||
- name: Check influxdb 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_influxdb_containers
|
||||
when:
|
||||
- action != "config"
|
||||
- inventory_hostname in groups[item.value.group]
|
||||
- item.value.enabled | bool
|
||||
with_dict: "{{ influxdb_services }}"
|
||||
notify:
|
||||
- Restart influxdb container
|
||||
|
@ -1,4 +1,5 @@
|
||||
---
|
||||
- include: config.yml
|
||||
|
||||
- include: start.yml
|
||||
- name: Flush handlers
|
||||
meta: flush_handlers
|
||||
|
@ -1,47 +1,2 @@
|
||||
---
|
||||
- name: Ensuring the containers up
|
||||
kolla_docker:
|
||||
name: "influxdb"
|
||||
action: "get_container_state"
|
||||
register: container_state
|
||||
failed_when: container_state.Running == false
|
||||
when: inventory_hostname in groups['influxdb']
|
||||
|
||||
- include: config.yml
|
||||
|
||||
- name: Check the configs
|
||||
command: docker exec influxdb /usr/local/bin/kolla_set_configs --check
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
register: check_results
|
||||
when: inventory_hostname in groups['influxdb']
|
||||
|
||||
# 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: "influxdb"
|
||||
action: "get_container_env"
|
||||
register: container_envs
|
||||
when: inventory_hostname in groups['influxdb']
|
||||
|
||||
- name: Remove the containers
|
||||
kolla_docker:
|
||||
name: "influxdb"
|
||||
action: "remove_container"
|
||||
register: remove_containers
|
||||
when:
|
||||
- config_strategy == "COPY_ONCE"
|
||||
- inventory_hostname in groups['influxdb']
|
||||
|
||||
- include: start.yml
|
||||
when: remove_containers.changed
|
||||
|
||||
- name: Restart containers
|
||||
kolla_docker:
|
||||
name: "influxdb"
|
||||
action: "restart_container"
|
||||
when:
|
||||
- config_strategy == 'COPY_ALWAYS'
|
||||
- inventory_hostname in groups['influxdb']
|
||||
- include: deploy.yml
|
||||
|
@ -1,13 +0,0 @@
|
||||
---
|
||||
- name: Starting influxdb container
|
||||
kolla_docker:
|
||||
action: "start_container"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
image: "{{ influxdb_image_full }}"
|
||||
name: "influxdb"
|
||||
volumes:
|
||||
- "{{ node_config_directory }}/influxdb/:{{ container_config_directory }}/:ro"
|
||||
- "/etc/localtime:/etc/localtime:ro"
|
||||
- "influxdb:/var/lib/influxdb"
|
||||
- "kolla_logs:/var/log/kolla/"
|
||||
when: inventory_hostname in groups['influxdb']
|
@ -1,4 +1,5 @@
|
||||
---
|
||||
- include: config.yml
|
||||
|
||||
- include: start.yml
|
||||
- name: Flush handlers
|
||||
meta: flush_handlers
|
||||
|
Loading…
Reference in New Issue
Block a user