Fix merge issue

This commit is contained in:
Werner Dijkerman
2018-11-21 19:27:51 +01:00
9 changed files with 46 additions and 32 deletions

View File

@ -5,6 +5,7 @@ services:
- docker
install:
- curl -sSlo requirements.txt https://raw.githubusercontent.com/dj-wasabi/ansible-ci-base/master/requirements.txt
- pip install -r requirements.txt
script:

View File

@ -39,6 +39,15 @@ provisioner:
inventory:
group_vars:
all:
telegraf_plugins_extra:
percpu-usage:
plugin: cpu
config:
- percpu = true
- totalcpu = false
- name_override = "percpu_usage"
- fielddrop = ["cpu_time*"]
telegraf_plugins_default:
- plugin: cpu
config:
@ -55,13 +64,6 @@ provisioner:
- plugin: nginx
config:
- 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:
name: default

View File

@ -1,22 +1,4 @@
---
- 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:
- role: ansible-telegraf

View 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'

View File

@ -21,6 +21,15 @@ def test_telegraf_dot_conf(File):
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):
telegraf = Package('telegraf')
assert telegraf.is_installed

View File

@ -1,4 +0,0 @@
ansible==2.4.4.0
docker==3.3.0
molecule==2.13.1
testinfra==1.12.0

View File

@ -15,6 +15,7 @@
- name: Download Telegraf apt key.
apt_key:
url: "https://repos.influxdata.com/influxdb.key"
id: 2582E0C5
state: present
become: yes

View File

@ -67,6 +67,8 @@
group: telegraf
mode: 0640
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'"
become: yes
notify: "Restart Telegraf"
@ -76,6 +78,8 @@
path: "/etc/telegraf/telegraf.d/{{ item.key }}.conf"
state: absent
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'"
become: yes
notify: "Restart Telegraf"

View File

@ -6,7 +6,7 @@
{% endif %}
{% if item.value.config is defined and item.value.config is iterable %}
{% for items in item.value.config %}
{% raw %}{{ items }}{% endraw %}}
{{ items }}
{% endfor %}
{% endif %}
{% if item.value.tags is defined and item.value.tags is iterable %}