From 4af9bbe2e3ce289a99e90e6a5c3252359fb9a2ab Mon Sep 17 00:00:00 2001 From: prithiv Date: Fri, 9 Sep 2016 10:20:18 +0100 Subject: [PATCH] Ansible roles for collectd Container Collectd-ceilometer-plugin is essential for further more detailed metrics collection, smarter scheduling and service assurance. Change-Id: I8da572980de370517ec120d745ad1d36e316b465 Implements: blueprint collectd-ceilometer-plugin --- ansible/group_vars/all.yml | 2 + ansible/inventory/all-in-one | 3 + ansible/inventory/multinode | 3 + ansible/roles/collectd/defaults/main.yml | 12 ++++ ansible/roles/collectd/meta/main.yml | 3 + ansible/roles/collectd/tasks/config.yml | 23 +++++++ ansible/roles/collectd/tasks/deploy.yml | 4 ++ .../roles/collectd/tasks/do_reconfigure.yml | 61 +++++++++++++++++++ ansible/roles/collectd/tasks/main.yml | 2 + ansible/roles/collectd/tasks/pull.yml | 6 ++ ansible/roles/collectd/tasks/reconfigure.yml | 3 + ansible/roles/collectd/tasks/start.yml | 15 +++++ ansible/roles/collectd/tasks/upgrade.yml | 4 ++ .../roles/collectd/templates/collectd.json.j2 | 3 + ansible/site.yml | 6 ++ .../notes/add-collectd-6e3387dfff75040a.yaml | 3 + 16 files changed, 153 insertions(+) create mode 100644 ansible/roles/collectd/defaults/main.yml create mode 100644 ansible/roles/collectd/meta/main.yml create mode 100644 ansible/roles/collectd/tasks/config.yml create mode 100644 ansible/roles/collectd/tasks/deploy.yml create mode 100644 ansible/roles/collectd/tasks/do_reconfigure.yml create mode 100644 ansible/roles/collectd/tasks/main.yml create mode 100644 ansible/roles/collectd/tasks/pull.yml create mode 100644 ansible/roles/collectd/tasks/reconfigure.yml create mode 100644 ansible/roles/collectd/tasks/start.yml create mode 100644 ansible/roles/collectd/tasks/upgrade.yml create mode 100644 ansible/roles/collectd/templates/collectd.json.j2 create mode 100644 releasenotes/notes/add-collectd-6e3387dfff75040a.yaml diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index f990737166..05bea988ae 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -268,6 +268,8 @@ nova_keystone_user: "nova" enable_nova_fake: "no" num_nova_fake_per_node: 5 +# Monitoring options are specified here +enable_collectd: "no" #################### # Logging options diff --git a/ansible/inventory/all-in-one b/ansible/inventory/all-in-one index 779c227733..e9ee7913fb 100644 --- a/ansible/inventory/all-in-one +++ b/ansible/inventory/all-in-one @@ -17,6 +17,9 @@ 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. +[collectd:children] +compute + [kibana:children] control diff --git a/ansible/inventory/multinode b/ansible/inventory/multinode index 2c8a7bb21c..3f91b86ff3 100644 --- a/ansible/inventory/multinode +++ b/ansible/inventory/multinode @@ -35,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. +[collectd:children] +compute + [influxdb:children] monitoring diff --git a/ansible/roles/collectd/defaults/main.yml b/ansible/roles/collectd/defaults/main.yml new file mode 100644 index 0000000000..93cfd4cf3c --- /dev/null +++ b/ansible/roles/collectd/defaults/main.yml @@ -0,0 +1,12 @@ +--- +#################### +# Docker +#################### +collectd_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-collectd" +collectd_tag: "{{ openstack_release }}" +collectd_image_full: "{{ collectd_image }}:{{ collectd_tag }}" + +#################### +# OpenStack +#################### +collectd_logging_debug: "{{ openstack_logging_debug }}" diff --git a/ansible/roles/collectd/meta/main.yml b/ansible/roles/collectd/meta/main.yml new file mode 100644 index 0000000000..6b4fff8fef --- /dev/null +++ b/ansible/roles/collectd/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - { role: common } diff --git a/ansible/roles/collectd/tasks/config.yml b/ansible/roles/collectd/tasks/config.yml new file mode 100644 index 0000000000..a9eaf08a55 --- /dev/null +++ b/ansible/roles/collectd/tasks/config.yml @@ -0,0 +1,23 @@ +--- +- name: Ensuring CollectD config directories exist + file: + path: "{{ node_config_directory }}/{{ item }}" + state: "directory" + recurse: yes + with_items: + - "collectd" + +- name: Ensuring Plugin directory exist + file: + path: "{{ node_config_directory }}/{{ item }}/collectd.conf.d" + state: "directory" + recurse: yes + with_items: + - "collectd" + +- name: Copying over config.json files for services + template: + src: "{{ item }}.json.j2" + dest: "{{ node_config_directory }}/{{ item }}/config.json" + with_items: + - "collectd" diff --git a/ansible/roles/collectd/tasks/deploy.yml b/ansible/roles/collectd/tasks/deploy.yml new file mode 100644 index 0000000000..1f16915ad9 --- /dev/null +++ b/ansible/roles/collectd/tasks/deploy.yml @@ -0,0 +1,4 @@ +--- +- include: config.yml + +- include: start.yml diff --git a/ansible/roles/collectd/tasks/do_reconfigure.yml b/ansible/roles/collectd/tasks/do_reconfigure.yml new file mode 100644 index 0000000000..602850983e --- /dev/null +++ b/ansible/roles/collectd/tasks/do_reconfigure.yml @@ -0,0 +1,61 @@ +--- +- 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: collectd, group: collectd } + +- 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: collectd, group: collectd } + +- 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: collectd, group: collectd } + +- 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: collectd, group: collectd }] + - "{{ 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: collectd, group: collectd }] + - "{{ container_envs.results }}" + - "{{ check_results.results }}" diff --git a/ansible/roles/collectd/tasks/main.yml b/ansible/roles/collectd/tasks/main.yml new file mode 100644 index 0000000000..b017e8b4ad --- /dev/null +++ b/ansible/roles/collectd/tasks/main.yml @@ -0,0 +1,2 @@ +--- +- include: "{{ action }}.yml" diff --git a/ansible/roles/collectd/tasks/pull.yml b/ansible/roles/collectd/tasks/pull.yml new file mode 100644 index 0000000000..300163f162 --- /dev/null +++ b/ansible/roles/collectd/tasks/pull.yml @@ -0,0 +1,6 @@ +--- +- name: Pulling CollectD image + kolla_docker: + action: "pull_image" + common_options: "{{ docker_common_options }}" + image: "{{ collectd_image_full }}" diff --git a/ansible/roles/collectd/tasks/reconfigure.yml b/ansible/roles/collectd/tasks/reconfigure.yml new file mode 100644 index 0000000000..859dc5cc00 --- /dev/null +++ b/ansible/roles/collectd/tasks/reconfigure.yml @@ -0,0 +1,3 @@ +--- +- include: do_reconfigure.yml + when: inventory_hostname in groups ['collectd'] diff --git a/ansible/roles/collectd/tasks/start.yml b/ansible/roles/collectd/tasks/start.yml new file mode 100644 index 0000000000..fbce11dadb --- /dev/null +++ b/ansible/roles/collectd/tasks/start.yml @@ -0,0 +1,15 @@ +--- +- name: Starting CollectD container + kolla_docker: + action: "start_container" + common_options: "{{ docker_common_options }}" + image: "{{ collectd_image_full }}" + name: "collectd" + privileged: True + volumes: + - "{{ node_config_directory }}/collectd/:{{ container_config_directory }}/:ro" + - "{{node_config_directory }}/collectd/collectd.conf.d/:/etc/collectd/collectd.conf.d/" + - "/etc/localtime:/etc/localtime:ro" + - "kolla_logs:/var/log/kolla/" + - "/sys/:/sys/:ro" + - "/dev/:/dev/:ro" diff --git a/ansible/roles/collectd/tasks/upgrade.yml b/ansible/roles/collectd/tasks/upgrade.yml new file mode 100644 index 0000000000..1f16915ad9 --- /dev/null +++ b/ansible/roles/collectd/tasks/upgrade.yml @@ -0,0 +1,4 @@ +--- +- include: config.yml + +- include: start.yml diff --git a/ansible/roles/collectd/templates/collectd.json.j2 b/ansible/roles/collectd/templates/collectd.json.j2 new file mode 100644 index 0000000000..7d70179270 --- /dev/null +++ b/ansible/roles/collectd/templates/collectd.json.j2 @@ -0,0 +1,3 @@ +{ + "command": "/usr/sbin/collectd -f" +} diff --git a/ansible/site.yml b/ansible/site.yml index cc6311ba10..da9d09cc54 100644 --- a/ansible/site.yml +++ b/ansible/site.yml @@ -8,6 +8,12 @@ tags: ceph, when: enable_ceph | bool } +- hosts: collectd + roles: + - { role: collectd, + tags: collectd, + when: enable_collectd | bool } + - hosts: elasticsearch roles: - { role: elasticsearch, diff --git a/releasenotes/notes/add-collectd-6e3387dfff75040a.yaml b/releasenotes/notes/add-collectd-6e3387dfff75040a.yaml new file mode 100644 index 0000000000..1b1ba4803a --- /dev/null +++ b/releasenotes/notes/add-collectd-6e3387dfff75040a.yaml @@ -0,0 +1,3 @@ +--- +features: + - Add collectd ansible role