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 - 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:

View File

@ -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

View File

@ -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

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]]') 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

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. - 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

View File

@ -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"

View File

@ -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 %}