This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
tsg-tsg-os-buildimage/ansible/roles/telegraf_statistic/tasks/main.yml
2021-06-30 10:15:12 +08:00

48 lines
1.3 KiB
YAML

- name: "copy telegraf.rpm to destination server"
copy:
src: "{{ role_path }}/files/telegraf-1.13.0-1.x86_64.rpm"
dest: /tmp
- name: "install telegraf"
yum:
name:
- /tmp/telegraf-1.13.0-1.x86_64.rpm
state: present
- name: "Templates telegraf.conf"
template:
src: "{{role_path}}/templates/telegraf_statistic.conf.j2.j2"
dest: /opt/tsg/tsg-os-provision/templates/telegraf_statistic.conf.j2
tags: template
- name: "copy telegraf_statistic.service to destination server"
copy:
src: "{{ role_path }}/files/telegraf_statistic.service"
dest: /usr/lib/systemd/system
mode: 0644
- name: "Create /usr/lib/systemd/system/telegraf_statistic.service.d/ directory if it does not exist"
file:
path: "{{ item }}"
state: directory
mode: '0755'
with_items:
- /usr/lib/systemd/system/telegraf_statistic.service.d
- name: "copy slice file to telegraf_statistic.service.d"
copy:
src: "{{ role_path }}/templates/service_override_slice.conf.j2"
dest: /usr/lib/systemd/system/telegraf_statistic.service.d/service_override_slice.conf
mode: 0644
##################### telegraf #####################
- name: "disable telegraf"
systemd:
name: telegraf.service
enabled: no
- name: "Start telegraf_statistic"
systemd:
name: telegraf_statistic.service
enabled: yes