ansible/roles/telegraf/tasks/main.yaml

66 lines
1.6 KiB
YAML
Raw Normal View History

2019-10-27 23:33:06 +00:00
---
#- name: gather OS specific variables
# include_vars: "{{ item }}"
# with_first_found:
# - "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yaml"
# - "{{ ansible_distribution }}.yaml"
# - "{{ ansible_os_family }}.yaml"
- name: run os specific tasks
include: "{{ item }}"
with_first_found:
- "{{ ansible_os_family }}.yaml"
- name: manage package
package:
name: "{{ telegraf_package_name }}"
state: "{{ telegraf_package_state }}"
- name: configure
template:
src: telegraf.conf.j2
dest: /etc/telegraf/telegraf.conf
owner: root
group: root
mode: 0644
notify: reload telegraf
2020-01-05 22:44:37 +00:00
- name: configure telegraf.d files
template:
src: telegraf_d.conf.j2
dest: "/etc/telegraf/telegraf.d/{{ '%02d' | format(idx) }}-{{ item.name }}.conf"
owner: root
group: root
mode: 0644
notify: reload telegraf
loop: "{{ telegraf_config_d | default([]) }}"
loop_control:
index_var: idx
2019-10-27 23:33:06 +00:00
- name: create systemd override directory
file:
path: /etc/systemd/system/telegraf.service.d
owner: root
group: root
mode: 0755
state: directory
- name: patch systemd unit
copy:
dest: /etc/systemd/system/telegraf.service.d/override.conf
owner: root
group: root
mode: 0644
content: |
[Service]
CapabilityBoundingSet=CAP_NET_RAW CAP_NET_ADMIN
AmbientCapabilities=CAP_NET_RAW CAP_NET_ADMIN
notify: telegraf daemon-reload
- name: manage service
service:
name: "{{ telegraf_service_name }}"
state: "{{ telegraf_service_state }}"
enabled: "{{ telegraf_service_enabled }}"
when: telegraf_package_state != "absent"