Uses a dedicated telegraf role

Change-Id: I17651120ac4b77fc6e0d4cbcde99e4e1fa36d1d1
This commit is contained in:
Mathieu Grzybek 2017-12-01 14:13:25 +01:00
parent 17a30dacc0
commit 98b4699bc7
2 changed files with 16 additions and 49 deletions

View File

@ -17,57 +17,18 @@
hosts: "all"
gather_facts: true
user: root
tasks:
- name: Add influxdata apt-keys
apt_key:
url: "https://repos.influxdata.com/influxdb.key"
state: "present"
- name: Add influxdata repo
apt_repository:
repo: "deb https://repos.influxdata.com/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable"
state: "present"
update_cache: yes
- name: Install telegraf
apt:
pkg: "telegraf"
state: "latest"
- name: Create telegraf plugin dir
file:
path: "/opt/telegraf"
state: directory
mode: "0755"
- name: Drop telegraf plugin file(s)
template:
src: "templates/telegraf-plugins/{{ item.value.plugin_name }}"
dest: "/opt/telegraf/{{ item.value.plugin_name }}"
mode: '0755'
with_dict: "{{ command_plugins }}"
when:
- item.value.when_group | bool
- item.value.group == inventory_hostname or
inventory_hostname in item.value.group | default([])
- name: Drop telegraf config file
template:
src: templates/telegraf.conf.j2
dest: /etc/telegraf/telegraf.conf
register: telegraf_config
- name: Enable and restart telegraf
service:
name: "telegraf"
enabled: true
state: restarted
when: telegraf_config | changed
- name: Enable and start telegraf
service:
name: "telegraf"
enabled: true
state: started
when: not telegraf_config | changed
roles:
- { role: openstack-ansible-telegraf }
vars_files:
- vars.yml
vars:
telegraf_output: influxdb
telegraf_output_influxdb_database: "{{ influxdb_db_name }}"
telegraf_output_influxdb_username: "{{ influxdb_db_metric_user }}"
telegraf_output_influxdb_password: "{{ influxdb_db_metric_password }}"
telegraf_openstack_scripts_data_format: influx
commands : []
command_plugins:
telegraf_openstack_scripts:
ironic:
plugin_name: "ironic_nodes.py"
command:
@ -86,5 +47,5 @@
- "python /opt/telegraf/cinder_pools_usage.py"
group: "{{ groups['utility_all'][0] }}"
when_group: "{{ (groups['cinder_volumes'] | default([]) | length) > 0 }}"
influx_telegraf_targets:
telegraf_output_influxdb_targets:
- "{{ influxdb_protocol|default('http') }}://{{ influxdb_host|default(internal_lb_vip_address) }}:{{ influxdb_port }}"

View File

@ -52,9 +52,15 @@ Install InfluxDB
openstack-ansible playbook-influx-db.yml
Clone the Telegraf repo
.. code-block:: bash
git clone https://github.com/mgrzybek/openstack-ansible-telegraf /etc/ansibles/roles/openstack-ansible-telegraf
Install Influx Telegraf
If you wish to install telegraf and point it at a specific target, or list of targets, set the ``influx_telegraf_targets``
If you wish to install telegraf and point it at a specific target, or list of targets, set the ``telegraf_output_influxdb_targets``
variable in the ``user_variables.yml`` file as a list containing all targets that telegraf should ship metrics to.
.. code-block:: bash