Last active
October 3, 2019 12:04
-
-
Save SpComb/cfb7c87bef0ccc0f26758723c7ce002d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: Configure telegraf {{name}} | |
template: | |
src: "{{ src }}" | |
dest: "{{ dest }}" | |
owner: root | |
group: "{{ telegraf_group }}" | |
mode: 0640 | |
notify: reload telegraf | |
# mark for prune | |
- name: Touch telegraf {{name}} for prune | |
shell: "test -f {{ dest }} && touch {{ dest }}" | |
check_mode: no # always run | |
changed_when: false | |
failed_when: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: Configure telegraf agent | |
include_tasks: conf.yml | |
vars: | |
name: telegraf.conf | |
src: telegraf.conf.j2 | |
dest: /etc/telegraf/telegraf.conf | |
- ... | |
# relies on conf.yml touching each file | |
- name: Prune old configs | |
command: find /etc/telegraf/telegraf.d/ -type f -not -newer /etc/telegraf/telegraf.conf {% if not ansible_check_mode %}-delete {% endif %}-print | |
check_mode: no # always run, but without -delete if check_mode | |
register: prune_telegraf_configs | |
changed_when: prune_telegraf_configs.stdout_lines | |
notify: reload telegraf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment