Skip to content

Commit

Permalink
Merge pull request #4 from infrawatch/import-templates-defaults
Browse files Browse the repository at this point in the history
Import template and defaults changes
  • Loading branch information
leifmadsen authored Aug 19, 2020
2 parents 942ab95 + 5d46c39 commit ff4645f
Show file tree
Hide file tree
Showing 25 changed files with 208 additions and 54 deletions.
3 changes: 3 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
skip_list:
- '701' # Role info should contain platforms
- '703' # Should change default metadata
25 changes: 19 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
---
os: linux
language: python
python: "2.7"

# Use the new container infrastructure
sudo: false
git:
depth: false

# Install ansible
addons:
apt:
update: true
packages:
- python-pip
- python-pip

services:
- docker

before_install:
- sudo docker pull docker.io/tripleomaster/centos-binary-collectd:current-tripleo-rdo

install:
# Install ansible
- pip install ansible
- pip install ansible ansible-lint

# Check ansible version
- ansible --version
Expand All @@ -24,6 +31,12 @@ install:
script:
# Basic role syntax check
- ansible-playbook tests/test.yml -i tests/inventory --syntax-check
- ansible-lint
# Run the role
- ansible-playbook tests/test.yml -i tests/inventory --extra-vars "collectd_conf_output_dir=$HOME/collectd.conf.d" && cat $HOME/collectd.conf.d/*
- sudo docker run -dti --name collectd-test --net=host -v $HOME/collectd.conf.d:/opt/collectd/etc/collectd.conf.d -v /var/run:/var/run -v /tmp:/tmp -v `pwd`/tests/kolla_config_files/:/var/lib/kolla/config_files/ -e KOLLA_CONFIG_STRATEGY=COPY_ALWAYS --privileged tripleomaster/centos-binary-collectd:current-tripleo-rdo
- sudo docker logs collectd-test
- sudo docker exec collectd-test collectdctl -s /var/run/collectd-socket listval

notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
webhooks: https://galaxy.ansible.com/api/v1/notifications/
5 changes: 5 additions & 0 deletions defaults/main/cpu.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
---
# Ansible managed
# Defaults for cpu plugin
collectd_plugin_cpu_reportbycpu: true
collectd_plugin_cpu_reportbystate: true
collectd_plugin_cpu_reportnumcpu: false
collectd_plugin_cpu_valuespercentage: true
# collectd_plugin_cpu_reportgueststate: true
# collectd_plugin_cpu_subtractgueststate: true
5 changes: 5 additions & 0 deletions defaults/main/csv.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
# Ansible managed
# Defaults for csv plugin
collectd_plugin_csv_datadir: /var/log/collectd/csv/
collectd_plugin_csv_storerates: false
14 changes: 9 additions & 5 deletions defaults/main/df.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
---
# defaults for configuring the df plugin
# Ansible managed
# Defaults for df plugin
# collectd_plugin_df_device: nil
# collectd_plugin_df_mountpoint: nil
# collectd_plugin_df_fstype: nil
collectd_plugin_df_ignoreselected: true
collectd_plugin_df_reportbydevice: true
#TODO: make this do something useful
collectd_plugin_df_fstypes: ['xfs']

#TODO: Add if def in templates for non-required plugin options
collectd_plugin_df_reportinodes: true
collectd_plugin_df_valuesabsolute: true
collectd_plugin_df_valuespercentage: true
6 changes: 4 additions & 2 deletions defaults/main/disk.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
---
# defaults for disk plugin
collectd_plugin_disk_ignoreselected: false
# Ansible managed
# Defaults for disk plugin
# collectd_plugin_disk_disk: []
collectd_plugin_disk_ignoreselected: False
5 changes: 3 additions & 2 deletions defaults/main/load.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# defaults for load plugin
collectd_plugin_load_reportrelative: true
# Ansible managed
# Defaults for load plugin
collectd_plugin_load_reportrelative: True
5 changes: 5 additions & 0 deletions defaults/main/memory.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
# Ansible managed
# Defaults for memory plugin
collectd_plugin_memory_valuesabsolute: True
collectd_plugin_memory_valuespercentage: True
10 changes: 6 additions & 4 deletions defaults/main/unixsock.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
# defaults for unixsock plugin
collectd_plugin_unixsock_socketgroup: "root"
collectd_plugin_unixsock_socketfile: "/var/run/collectd-socket"
collectd_plugin_unixsock_deletesocket: true
# Ansible managed
# Defaults for unixsock plugin
collectd_plugin_unixsock_socketfile: /var/run/collectd-socket
collectd_plugin_unixsock_socketgroup: root
# collectd_plugin_unixsock_socketperms: nil
collectd_plugin_unixsock_deletesocket: True
13 changes: 7 additions & 6 deletions defaults/main/virt.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
# default values for configuring the virt plugin
collectd_plugin_virt_connection: "qemu:///system"
collectd_plugin_virt_refresh_interval: 10
collectd_plugin_virt_hostname_format: "hostname"
collectd_plugin_virt_plugininstanceformat: "hostname uuid"
collectd_plugin_virt_extra_stats: "cpu_util disk disk_err pcpu job_stats_background perf vcpupin"
# Ansible managed
# Defaults for virt plugin
collectd_plugin_virt_connection: qemu:///system
collectd_plugin_virt_refreshinterval: 10
collectd_plugin_virt_hostnameformat: hostname
collectd_plugin_virt_plugininstanceformat: name
collectd_plugin_virt_extrastats: cpu_util disk disk_err pcpu job_stats_background perf vcpupin
19 changes: 12 additions & 7 deletions templates/cpu.conf.j2
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# Ansible managed
LoadPlugin cpu

<Plugin cpu>
ReportByState {{ collectd_plugin_cpu_reportbystate }}
ReportByCpu {{ collectd_plugin_cpu_reportbystate }}
ValuesPercentage {{ collectd_plugin_cpu_valuespercentage }}
ReportNumCpu {{ collectd_plugin_cpu_reportnumcpu }}
ReportGuestState true
SubtractGuestState true
<Plugin "cpu">
ReportByCpu "{{ collectd_plugin_cpu_reportbycpu }}"
ReportByState "{{ collectd_plugin_cpu_reportbystate }}"
ReportNumCpu "{{ collectd_plugin_cpu_reportnumcpu }}"
ValuesPercentage "{{ collectd_plugin_cpu_valuespercentage }}"
{% if collectd_plugin_cpu_reportgueststate is defined %}
ReportGuestState "{{ collectd_plugin_cpu_reportgueststate }}"
{% endif %}
{% if collectd_plugin_cpu_subtractgueststate is defined %}
SubtractGuestState "{{ collectd_plugin_cpu_subtractgueststate }}"
{% endif %}
</Plugin>
5 changes: 5 additions & 0 deletions templates/cpufreq.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Ansible managed
LoadPlugin cpufreq

<Plugin "cpufreq">
</Plugin>
5 changes: 5 additions & 0 deletions templates/cpusleep.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Ansible managed
LoadPlugin cpusleep

<Plugin "cpusleep">
</Plugin>
7 changes: 7 additions & 0 deletions templates/csv.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Ansible managed
LoadPlugin csv

<Plugin "csv">
DataDir "{{ collectd_plugin_csv_datadir }}"
StoreRates "{{ collectd_plugin_csv_storerates }}"
</Plugin>
22 changes: 16 additions & 6 deletions templates/df.conf.j2
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
# Ansible managed
LoadPlugin df

<Plugin df>
IgnoreSelected true
ReportByDevice {{ collectd_plugin_df_reportbydevice }}
ReportInodes true
ValuesAbsolute true
ValuesPercentage true
<Plugin "df">
{% if collectd_plugin_df_device is defined %}
Device "{{ collectd_plugin_df_device }}"
{% endif %}
{% if collectd_plugin_df_mountpoint is defined %}
MountPoint "{{ collectd_plugin_df_mountpoint }}"
{% endif %}
{% if collectd_plugin_df_fstype is defined %}
FSType "{{ collectd_plugin_df_fstype }}"
{% endif %}
IgnoreSelected "{{ collectd_plugin_df_ignoreselected }}"
ReportByDevice "{{ collectd_plugin_df_reportbydevice }}"
ReportInodes "{{ collectd_plugin_df_reportinodes }}"
ValuesAbsolute "{{ collectd_plugin_df_valuesabsolute }}"
ValuesPercentage "{{ collectd_plugin_df_valuespercentage }}"
</Plugin>
10 changes: 8 additions & 2 deletions templates/disk.conf.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Ansible managed
LoadPlugin disk

<Plugin disk>
IgnoreSelected {{ collectd_plugin_disk_ignoreselected }}
<Plugin "disk">
{% if collectd_plugin_disk_disk is defined %}
{% for disk in collectd_plugin_disk_disk %}
Disk "{{ disk }}"
{% endfor %}
{% endif %}
IgnoreSelected {{ collectd_plugin_disk_ignoreselected| string | lower }}
</Plugin>
7 changes: 5 additions & 2 deletions templates/load.conf.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Ansible managed
LoadPlugin load

<Plugin load>
ReportRelative true
<Plugin "load">
{% if collectd_plugin_load_reportrelative is defined %}
ReportRelative {{ collectd_plugin_load_reportrelative| string | lower }}
{% endif %}
</Plugin>
11 changes: 8 additions & 3 deletions templates/memory.conf.j2
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Ansible managed
LoadPlugin memory

<Plugin memory>
ValuesAbsolute true
ValuesPercentage true
<Plugin "memory">
{% if collectd_plugin_memory_valuesabsolute is defined %}
ValuesAbsolute {{ collectd_plugin_memory_valuesabsolute| string | lower }}
{% endif %}
{% if collectd_plugin_memory_valuespercentage is defined %}
ValuesPercentage {{ collectd_plugin_memory_valuespercentage| string | lower }}
{% endif %}
</Plugin>
13 changes: 12 additions & 1 deletion templates/unixsock.conf.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
# Ansible managed
LoadPlugin unixsock

<Plugin unixsock>
<Plugin "unixsock">
SocketFile "{{ collectd_plugin_unixsock_socketfile }}"
{% if collectd_plugin_unixsock_socketgroup is defined %}
SocketGroup "{{ collectd_plugin_unixsock_socketgroup }}"
{% endif %}
{% if collectd_plugin_unixsock_socketperms is defined %}
SocketPerms "{{ collectd_plugin_unixsock_socketperms }}"
{% endif %}
{% if collectd_plugin_unixsock_deletesocket is defined %}
DeleteSocket {{ collectd_plugin_unixsock_deletesocket| string | lower }}
{% endif %}
</Plugin>
4 changes: 4 additions & 0 deletions templates/uptime.conf.j2
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# Ansible managed
LoadPlugin uptime

<Plugin "uptime">
</Plugin>
8 changes: 8 additions & 0 deletions templates/uuid.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Ansible managed
LoadPlugin uuid

<Plugin "uuid">
{% if collectd_plugin_uuid_uuidfile is defined %}
UUIDFile "{{ collectd_plugin_uuid_uuidfile }}"
{% endif %}
</Plugin>
21 changes: 15 additions & 6 deletions templates/virt.conf.j2
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
# Ansible managed
LoadPlugin virt

<Plugin virt>
Connection {{ collectd_plugin_virt_connection }}
RefreshInterval {{ collectd_plugin_virt_refreshinterval }}
HostnameFormat {{ collectd_plugin_virt_hostnameformat }}
PluginInstanceFormat {{ collectd_plugin_virt_plugininstanceformat }}
ExtraStats "{{ collectd_plugin_extrastats }}"
<Plugin "virt">
Connection "{{ collectd_plugin_virt_connection }}"
{% if collectd_plugin_virt_refreshinterval is defined %}
RefreshInterval {{ collectd_plugin_virt_refreshinterval| string | lower }}
{% endif %}
{% if collectd_plugin_virt_hostnameformat is defined %}
HostnameFormat "{{ collectd_plugin_virt_hostnameformat }}"
{% endif %}
{% if collectd_plugin_virt_plugininstanceformat is defined %}
PluginInstanceFormat "{{ collectd_plugin_virt_plugininstanceformat }}"
{% endif %}
{% if collectd_plugin_virt_extrastats is defined %}
ExtraStats "{{ collectd_plugin_virt_extrastats }}"
{% endif %}
</Plugin>
2 changes: 1 addition & 1 deletion tests/inventory
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
localhost
localhost ansible_connection=local

10 changes: 10 additions & 0 deletions tests/kolla_config_files/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"command": "/usr/sbin/collectd -f -C /opt/collectd/etc/collectd.conf.d",
"permissions": [
{
"owner": "collectd:collectd",
"path": "/var/log/collectd",
"recurse": true
}
]
}
27 changes: 26 additions & 1 deletion tests/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,29 @@
- hosts: localhost
remote_user: root
roles:
- test-role
- '../../collectd-config-ansible-role'
vars:
collectd_plugins:
# - amqp1
# - ceph
- connectivity
- cpu
- csv
- df
- disk
- hugepages
- intel_rdt
- interface
# TODO: reenable this when there are reasonable defaults or the template has been updated
# - ipmi
- load
# - logfile
- memory
- network
- ovs_stats
- processes
- procevent
# - python
- unixsock
- uptime
# - virt

0 comments on commit ff4645f

Please sign in to comment.