From 49f7359b0ce55cec28b258fc964b1bbc3200fe29 Mon Sep 17 00:00:00 2001 From: Mathias Ewald Date: Wed, 27 Jul 2016 06:23:29 +0000 Subject: [PATCH] Added influxdb role Added ansible role for influxdb Introduced host groups for monitoring and influxdb and assign role Monitoring is deployed on a separate node called monitoring01 by default Co-Authored-By: zhubingbing Change-Id: If2465a14b18c6c3fd657af587a0b85f6b7a0191a Partially-Implements: Blueprint performance-monitoring --- ansible/group_vars/all.yml | 4 ++ ansible/inventory/all-in-one | 5 ++ ansible/inventory/multinode | 6 ++ ansible/roles/influxdb/defaults/main.yml | 9 +++ ansible/roles/influxdb/meta/main.yml | 3 + ansible/roles/influxdb/tasks/config.yml | 23 ++++++++ ansible/roles/influxdb/tasks/deploy.yml | 4 ++ .../roles/influxdb/tasks/do_reconfigure.yml | 47 +++++++++++++++ ansible/roles/influxdb/tasks/main.yml | 2 + ansible/roles/influxdb/tasks/pull.yml | 7 +++ ansible/roles/influxdb/tasks/reconfigure.yml | 4 ++ ansible/roles/influxdb/tasks/start.yml | 13 +++++ ansible/roles/influxdb/tasks/upgrade.yml | 5 ++ .../roles/influxdb/templates/influxdb.conf.j2 | 57 +++++++++++++++++++ .../roles/influxdb/templates/influxdb.json.j2 | 11 ++++ ansible/site.yml | 6 ++ etc/kolla/globals.yml | 1 + 17 files changed, 207 insertions(+) create mode 100644 ansible/roles/influxdb/defaults/main.yml create mode 100644 ansible/roles/influxdb/meta/main.yml create mode 100644 ansible/roles/influxdb/tasks/config.yml create mode 100644 ansible/roles/influxdb/tasks/deploy.yml create mode 100644 ansible/roles/influxdb/tasks/do_reconfigure.yml create mode 100644 ansible/roles/influxdb/tasks/main.yml create mode 100644 ansible/roles/influxdb/tasks/pull.yml create mode 100644 ansible/roles/influxdb/tasks/reconfigure.yml create mode 100644 ansible/roles/influxdb/tasks/start.yml create mode 100644 ansible/roles/influxdb/tasks/upgrade.yml create mode 100644 ansible/roles/influxdb/templates/influxdb.conf.j2 create mode 100644 ansible/roles/influxdb/templates/influxdb.json.j2 diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index 583c2b84ec..7be8e415bd 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -182,6 +182,9 @@ manila_api_port: "8786" watcher_api_port: "9322" +influxdb_admin_port: "8083" +influxdb_http_port: "8086" + public_protocol: "{{ 'https' if kolla_enable_tls_external | bool else 'http' }}" internal_protocol: "http" admin_protocol: "http" @@ -232,6 +235,7 @@ enable_cinder_backend_lvm: "no" enable_congress: "no" enable_heat: "yes" enable_horizon: "yes" +enable_influxdb: "no" enable_ironic: "no" enable_magnum: "no" enable_manila: "no" diff --git a/ansible/inventory/all-in-one b/ansible/inventory/all-in-one index ac28357747..c18362a612 100644 --- a/ansible/inventory/all-in-one +++ b/ansible/inventory/all-in-one @@ -12,6 +12,8 @@ localhost ansible_connection=local [storage] localhost ansible_connection=local +[monitoring] +localhost ansible_connection=local # You can explicitly specify which hosts run each project by updating the # groups in the sections below. Common services are grouped together. @@ -75,6 +77,9 @@ storage [ironic:children] control +[influxdb:children] +monitoring + [magnum:children] control diff --git a/ansible/inventory/multinode b/ansible/inventory/multinode index dcdcdc7d07..682afab69f 100644 --- a/ansible/inventory/multinode +++ b/ansible/inventory/multinode @@ -17,6 +17,9 @@ network01 [compute] compute01 +[monitoring] +monitoring01 + # When compute nodes and control nodes use different interfaces, # you can specify "api_interface" and another interfaces like below: #compute01 neutron_external_interface=eth0 api_interface=em1 storage_interface=em1 tunnel_interface=em1 @@ -32,6 +35,9 @@ storage # You can explicitly specify which hosts run each project by updating the # groups in the sections below. Common services are grouped together. +[influxdb:children] +monitoring + [kibana:children] control diff --git a/ansible/roles/influxdb/defaults/main.yml b/ansible/roles/influxdb/defaults/main.yml new file mode 100644 index 0000000000..4633af3e2b --- /dev/null +++ b/ansible/roles/influxdb/defaults/main.yml @@ -0,0 +1,9 @@ +--- +project_name: "influxdb" + +#################### +# Docker +#################### +influxdb_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-influxdb" +influxdb_tag: "{{ openstack_release }}" +influxdb_image_full: "{{ influxdb_image }}:{{ influxdb_tag }}" diff --git a/ansible/roles/influxdb/meta/main.yml b/ansible/roles/influxdb/meta/main.yml new file mode 100644 index 0000000000..6b4fff8fef --- /dev/null +++ b/ansible/roles/influxdb/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - { role: common } diff --git a/ansible/roles/influxdb/tasks/config.yml b/ansible/roles/influxdb/tasks/config.yml new file mode 100644 index 0000000000..f9b7544f89 --- /dev/null +++ b/ansible/roles/influxdb/tasks/config.yml @@ -0,0 +1,23 @@ +--- +- name: Ensuring config directories exist + file: + path: "{{ node_config_directory }}/influxdb" + state: "directory" + recurse: yes + when: inventory_hostname in groups['influxdb'] + +- name: Copying over config.json files + template: + src: "{{ item }}.json.j2" + dest: "{{ node_config_directory }}/influxdb/config.json" + when: inventory_hostname in groups['influxdb'] + with_items: + - influxdb + +- name: Copying over influxdb config file + template: + src: "{{ role_path }}/templates/{{ item }}.conf.j2" + dest: "{{ node_config_directory }}/influxdb/influxdb.conf" + when: inventory_hostname in groups['influxdb'] + with_items: + - influxdb diff --git a/ansible/roles/influxdb/tasks/deploy.yml b/ansible/roles/influxdb/tasks/deploy.yml new file mode 100644 index 0000000000..1f16915ad9 --- /dev/null +++ b/ansible/roles/influxdb/tasks/deploy.yml @@ -0,0 +1,4 @@ +--- +- include: config.yml + +- include: start.yml diff --git a/ansible/roles/influxdb/tasks/do_reconfigure.yml b/ansible/roles/influxdb/tasks/do_reconfigure.yml new file mode 100644 index 0000000000..6049df4746 --- /dev/null +++ b/ansible/roles/influxdb/tasks/do_reconfigure.yml @@ -0,0 +1,47 @@ +--- +- 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'] diff --git a/ansible/roles/influxdb/tasks/main.yml b/ansible/roles/influxdb/tasks/main.yml new file mode 100644 index 0000000000..b017e8b4ad --- /dev/null +++ b/ansible/roles/influxdb/tasks/main.yml @@ -0,0 +1,2 @@ +--- +- include: "{{ action }}.yml" diff --git a/ansible/roles/influxdb/tasks/pull.yml b/ansible/roles/influxdb/tasks/pull.yml new file mode 100644 index 0000000000..c611eebd4e --- /dev/null +++ b/ansible/roles/influxdb/tasks/pull.yml @@ -0,0 +1,7 @@ +--- +- name: Pulling influxdb image + kolla_docker: + action: "pull_image" + common_options: "{{ docker_common_options }}" + image: "{{ influxdb_image_full }}" + when: inventory_hostname in groups['influxdb'] diff --git a/ansible/roles/influxdb/tasks/reconfigure.yml b/ansible/roles/influxdb/tasks/reconfigure.yml new file mode 100644 index 0000000000..8be80caa56 --- /dev/null +++ b/ansible/roles/influxdb/tasks/reconfigure.yml @@ -0,0 +1,4 @@ +--- +- include: do_reconfigure.yml + serial: "30%" + when: inventory_hostname in groups['influxdb'] diff --git a/ansible/roles/influxdb/tasks/start.yml b/ansible/roles/influxdb/tasks/start.yml new file mode 100644 index 0000000000..1a98e71234 --- /dev/null +++ b/ansible/roles/influxdb/tasks/start.yml @@ -0,0 +1,13 @@ +--- +- 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'] diff --git a/ansible/roles/influxdb/tasks/upgrade.yml b/ansible/roles/influxdb/tasks/upgrade.yml new file mode 100644 index 0000000000..4586b4fabc --- /dev/null +++ b/ansible/roles/influxdb/tasks/upgrade.yml @@ -0,0 +1,5 @@ +--- +- include: config.yml + +- include: start.yml + serial: "30%" diff --git a/ansible/roles/influxdb/templates/influxdb.conf.j2 b/ansible/roles/influxdb/templates/influxdb.conf.j2 new file mode 100644 index 0000000000..cded6fbe68 --- /dev/null +++ b/ansible/roles/influxdb/templates/influxdb.conf.j2 @@ -0,0 +1,57 @@ +reporting-disabled = false +[logging] +level = "info" +file = "/var/log/kolla/influxdb/influxdb.log" +[meta] + dir = "/var/lib/influxdb/meta" + retention-autocreate = true + logging-enabled = true + pprof-enabled = false + lease-duration = "1m0s" +[data] + enabled = true + dir = "/var/lib/influxdb/data" + wal-dir = "/var/lib/influxdb/wal" + wal-logging-enabled = true + data-logging-enabled = true +[cluster] + shard-writer-timeout = "5s" + write-timeout = "10s" + max-concurrent-queries = 0 + query-timeout = "0s" + max-select-point = 0 + max-select-series = 0 + max-select-buckets = 0 +[retention] + enabled = true + check-interval = "30m" +[shard-precreation] + enabled = true + check-interval = "10m" + advance-period = "30m" +[monitor] + store-enabled = true + store-database = "_internal" + store-interval = "10s" +[admin] + enabled = true + bind-address = "{{ api_interface_address }}:{{ influxdb_admin_port }}" + https-enabled = false +[http] + enabled = true + bind-address = "{{ api_interface_address }}:{{ influxdb_http_port }}" + auth-enabled = false + log-enabled = true + write-tracing = false + pprof-enabled = false + https-enabled = false + max-row-limit = 10000 +[[graphite]] + enabled = false +[[opentsdb]] + enabled = false +[[udp]] + enabled = false +[continuous_queries] + log-enabled = true + enabled = true diff --git a/ansible/roles/influxdb/templates/influxdb.json.j2 b/ansible/roles/influxdb/templates/influxdb.json.j2 new file mode 100644 index 0000000000..2c4c6b3b09 --- /dev/null +++ b/ansible/roles/influxdb/templates/influxdb.json.j2 @@ -0,0 +1,11 @@ +{ + "command": "/usr/bin/influxd -config /etc/influxdb/influxdb.conf", + "config_files": [ + { + "source": "{{ container_config_directory }}/influxdb.conf", + "dest": "/etc/influxdb/influxdb.conf", + "owner": "influxdb", + "perm": "0600" + } + ] +} diff --git a/ansible/site.yml b/ansible/site.yml index 5508c4f222..75ae3837a3 100644 --- a/ansible/site.yml +++ b/ansible/site.yml @@ -14,6 +14,12 @@ tags: elasticsearch, when: enable_elasticsearch | bool } +- hosts: influxdb + roles: + - { role: influxdb, + tags: influxdb, + when: enable_influxdb | bool } + - hosts: haproxy roles: - { role: haproxy, diff --git a/etc/kolla/globals.yml b/etc/kolla/globals.yml index bef77a1e25..65bd137ff9 100644 --- a/etc/kolla/globals.yml +++ b/etc/kolla/globals.yml @@ -130,6 +130,7 @@ kolla_internal_vip_address: "10.10.10.254" #enable_congress: "no" #enable_heat: "yes" #enable_horizon: "yes" +#enable_influxdb: "no" #enable_ironic: "no" #enable_magnum: "no" #enable_manila: "no"