mirror of
https://github.com/dj-wasabi/ansible-telegraf.git
synced 2025-07-17 08:46:37 +00:00
Fix merge issue
This commit is contained in:
@ -5,6 +5,7 @@ services:
|
|||||||
- docker
|
- docker
|
||||||
|
|
||||||
install:
|
install:
|
||||||
|
- curl -sSlo requirements.txt https://raw.githubusercontent.com/dj-wasabi/ansible-ci-base/master/requirements.txt
|
||||||
- pip install -r requirements.txt
|
- pip install -r requirements.txt
|
||||||
|
|
||||||
script:
|
script:
|
||||||
|
@ -39,10 +39,19 @@ provisioner:
|
|||||||
inventory:
|
inventory:
|
||||||
group_vars:
|
group_vars:
|
||||||
all:
|
all:
|
||||||
|
telegraf_plugins_extra:
|
||||||
|
percpu-usage:
|
||||||
|
plugin: cpu
|
||||||
|
config:
|
||||||
|
- percpu = true
|
||||||
|
- totalcpu = false
|
||||||
|
- name_override = "percpu_usage"
|
||||||
|
- fielddrop = ["cpu_time*"]
|
||||||
|
|
||||||
telegraf_plugins_default:
|
telegraf_plugins_default:
|
||||||
- plugin: cpu
|
- plugin: cpu
|
||||||
config:
|
config:
|
||||||
- percpu = true
|
- percpu = true
|
||||||
- plugin: disk
|
- plugin: disk
|
||||||
- plugin: io
|
- plugin: io
|
||||||
- plugin: mem
|
- plugin: mem
|
||||||
@ -54,14 +63,7 @@ provisioner:
|
|||||||
- plugin: kernel
|
- plugin: kernel
|
||||||
- plugin: nginx
|
- plugin: nginx
|
||||||
config:
|
config:
|
||||||
- urls = ["http://localhost/nginx_status"]
|
- urls = ["http://localhost/nginx_status"]
|
||||||
- plugin: logparser
|
|
||||||
config:
|
|
||||||
- files = ["/var/log/nginx/access.log"]
|
|
||||||
- from_beginning = true
|
|
||||||
- name_override = "nginx_access_log"
|
|
||||||
- \[logparser.grok\]
|
|
||||||
- patterns = ["%{COMBINED_LOG_FORMAT}"]
|
|
||||||
|
|
||||||
scenario:
|
scenario:
|
||||||
name: default
|
name: default
|
||||||
|
@ -1,22 +1,4 @@
|
|||||||
---
|
---
|
||||||
- hosts: all
|
- hosts: all
|
||||||
pre_tasks:
|
|
||||||
- name: "Installing which on CentOS"
|
|
||||||
yum:
|
|
||||||
name: which
|
|
||||||
state: present
|
|
||||||
when:
|
|
||||||
- ansible_os_family == 'RedHat'
|
|
||||||
|
|
||||||
- name: "Installing wget on Debian"
|
|
||||||
apt:
|
|
||||||
name: "{{ item }}"
|
|
||||||
state: present
|
|
||||||
when:
|
|
||||||
- ansible_os_family == 'Debian'
|
|
||||||
with_items:
|
|
||||||
- wget
|
|
||||||
- gpg
|
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
- role: ansible-telegraf
|
- role: ansible-telegraf
|
||||||
|
19
molecule/default/prepare.yml
Normal file
19
molecule/default/prepare.yml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- hosts: all
|
||||||
|
tasks:
|
||||||
|
- name: "Installing which on CentOS"
|
||||||
|
yum:
|
||||||
|
name: which
|
||||||
|
state: present
|
||||||
|
when:
|
||||||
|
- ansible_os_family == 'RedHat'
|
||||||
|
|
||||||
|
- name: "Installing wget on Debian"
|
||||||
|
apt:
|
||||||
|
name:
|
||||||
|
- wget
|
||||||
|
- gpg
|
||||||
|
state: present
|
||||||
|
when:
|
||||||
|
- ansible_os_family == 'Debian'
|
@ -21,6 +21,15 @@ def test_telegraf_dot_conf(File):
|
|||||||
assert telegraf.contains('[[inputs.cpu]]')
|
assert telegraf.contains('[[inputs.cpu]]')
|
||||||
|
|
||||||
|
|
||||||
|
def test_telegraf_dot_d(File):
|
||||||
|
telegraf = File("/etc/telegraf/telegraf.d/percpu-usage.conf")
|
||||||
|
assert telegraf.user == "telegraf"
|
||||||
|
assert telegraf.group == "telegraf"
|
||||||
|
assert telegraf.mode == 0o640
|
||||||
|
assert telegraf.contains('[[inputs.cpu]]')
|
||||||
|
assert telegraf.contains('totalcpu = false')
|
||||||
|
|
||||||
|
|
||||||
def test_telegraf_package(Package):
|
def test_telegraf_package(Package):
|
||||||
telegraf = Package('telegraf')
|
telegraf = Package('telegraf')
|
||||||
assert telegraf.is_installed
|
assert telegraf.is_installed
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
ansible==2.4.4.0
|
|
||||||
docker==3.3.0
|
|
||||||
molecule==2.13.1
|
|
||||||
testinfra==1.12.0
|
|
@ -15,6 +15,7 @@
|
|||||||
- name: Download Telegraf apt key.
|
- name: Download Telegraf apt key.
|
||||||
apt_key:
|
apt_key:
|
||||||
url: "https://repos.influxdata.com/influxdb.key"
|
url: "https://repos.influxdata.com/influxdb.key"
|
||||||
|
id: 2582E0C5
|
||||||
state: present
|
state: present
|
||||||
become: yes
|
become: yes
|
||||||
|
|
||||||
|
@ -67,6 +67,8 @@
|
|||||||
group: telegraf
|
group: telegraf
|
||||||
mode: 0640
|
mode: 0640
|
||||||
with_dict: "{{ telegraf_plugins_extra }}"
|
with_dict: "{{ telegraf_plugins_extra }}"
|
||||||
|
loop_control:
|
||||||
|
label: "{{ item.key }}"
|
||||||
when: "telegraf_plugins_extra is defined and telegraf_plugins_extra is iterable and item.value.state|default('present') != 'absent'"
|
when: "telegraf_plugins_extra is defined and telegraf_plugins_extra is iterable and item.value.state|default('present') != 'absent'"
|
||||||
become: yes
|
become: yes
|
||||||
notify: "Restart Telegraf"
|
notify: "Restart Telegraf"
|
||||||
@ -76,6 +78,8 @@
|
|||||||
path: "/etc/telegraf/telegraf.d/{{ item.key }}.conf"
|
path: "/etc/telegraf/telegraf.d/{{ item.key }}.conf"
|
||||||
state: absent
|
state: absent
|
||||||
with_dict: "{{ telegraf_plugins_extra }}"
|
with_dict: "{{ telegraf_plugins_extra }}"
|
||||||
|
loop_control:
|
||||||
|
label: "{{ item.key }}"
|
||||||
when: "telegraf_plugins_extra is defined and telegraf_plugins_extra is iterable and item.value.state|default('present') == 'absent'"
|
when: "telegraf_plugins_extra is defined and telegraf_plugins_extra is iterable and item.value.state|default('present') == 'absent'"
|
||||||
become: yes
|
become: yes
|
||||||
notify: "Restart Telegraf"
|
notify: "Restart Telegraf"
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% if item.value.config is defined and item.value.config is iterable %}
|
{% if item.value.config is defined and item.value.config is iterable %}
|
||||||
{% for items in item.value.config %}
|
{% for items in item.value.config %}
|
||||||
{% raw %}{{ items }}{% endraw %}}
|
{{ items }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if item.value.tags is defined and item.value.tags is iterable %}
|
{% if item.value.tags is defined and item.value.tags is iterable %}
|
||||||
|
Reference in New Issue
Block a user