From f94d4fb9ca5ffdea658113adc7cfaa8d21ec1a88 Mon Sep 17 00:00:00 2001 From: Leif Madsen Date: Wed, 19 Aug 2020 12:26:04 -0400 Subject: [PATCH 1/4] Import template and defaults changes Import template and defaults changes from https://github.com/infrawatch/osp-observability-ansible/pull/7 --- defaults/main/cpu.yml | 5 +++++ defaults/main/csv.yml | 5 +++++ defaults/main/df.yml | 14 +++++++++----- defaults/main/disk.yml | 6 ++++-- defaults/main/load.yml | 5 +++-- defaults/main/memory.yml | 5 +++++ defaults/main/unixsock.yml | 10 ++++++---- defaults/main/virt.yml | 13 +++++++------ templates/cpu.conf.j2 | 19 ++++++++++++------- templates/cpufreq.conf.j2 | 5 +++++ templates/cpusleep.conf.j2 | 5 +++++ templates/csv.conf.j2 | 7 +++++++ templates/df.conf.j2 | 22 ++++++++++++++++------ templates/disk.conf.j2 | 10 ++++++++-- templates/load.conf.j2 | 7 +++++-- templates/memory.conf.j2 | 11 ++++++++--- templates/unixsock.conf.j2 | 13 ++++++++++++- templates/uptime.conf.j2 | 4 ++++ templates/uuid.conf.j2 | 8 ++++++++ templates/virt.conf.j2 | 21 +++++++++++++++------ 20 files changed, 149 insertions(+), 46 deletions(-) create mode 100644 defaults/main/csv.yml create mode 100644 defaults/main/memory.yml create mode 100644 templates/cpufreq.conf.j2 create mode 100644 templates/cpusleep.conf.j2 create mode 100644 templates/csv.conf.j2 create mode 100644 templates/uuid.conf.j2 diff --git a/defaults/main/cpu.yml b/defaults/main/cpu.yml index ef689b1..2ad9317 100644 --- a/defaults/main/cpu.yml +++ b/defaults/main/cpu.yml @@ -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 diff --git a/defaults/main/csv.yml b/defaults/main/csv.yml new file mode 100644 index 0000000..e4a6b2e --- /dev/null +++ b/defaults/main/csv.yml @@ -0,0 +1,5 @@ +--- +# Ansible managed +# Defaults for csv plugin +collectd_plugin_csv_datadir: /var/log/collectd/csv/ +collectd_plugin_csv_storerates: false diff --git a/defaults/main/df.yml b/defaults/main/df.yml index 244877f..f974392 100644 --- a/defaults/main/df.yml +++ b/defaults/main/df.yml @@ -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 diff --git a/defaults/main/disk.yml b/defaults/main/disk.yml index a17bfa8..f346762 100644 --- a/defaults/main/disk.yml +++ b/defaults/main/disk.yml @@ -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 diff --git a/defaults/main/load.yml b/defaults/main/load.yml index 1012667..421ef33 100644 --- a/defaults/main/load.yml +++ b/defaults/main/load.yml @@ -1,3 +1,4 @@ --- -# defaults for load plugin -collectd_plugin_load_reportrelative: true +# Ansible managed +# Defaults for load plugin +collectd_plugin_load_reportrelative: True diff --git a/defaults/main/memory.yml b/defaults/main/memory.yml new file mode 100644 index 0000000..facf142 --- /dev/null +++ b/defaults/main/memory.yml @@ -0,0 +1,5 @@ +--- +# Ansible managed +# Defaults for memory plugin +collectd_plugin_memory_valuesabsolute: True +collectd_plugin_memory_valuespercentage: True diff --git a/defaults/main/unixsock.yml b/defaults/main/unixsock.yml index 321af70..3067941 100644 --- a/defaults/main/unixsock.yml +++ b/defaults/main/unixsock.yml @@ -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 diff --git a/defaults/main/virt.yml b/defaults/main/virt.yml index b407b9e..370f51c 100644 --- a/defaults/main/virt.yml +++ b/defaults/main/virt.yml @@ -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 diff --git a/templates/cpu.conf.j2 b/templates/cpu.conf.j2 index 14e8f73..ba39d7d 100644 --- a/templates/cpu.conf.j2 +++ b/templates/cpu.conf.j2 @@ -1,10 +1,15 @@ +# Ansible managed LoadPlugin 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 + + 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 %} diff --git a/templates/cpufreq.conf.j2 b/templates/cpufreq.conf.j2 new file mode 100644 index 0000000..3d1f7f3 --- /dev/null +++ b/templates/cpufreq.conf.j2 @@ -0,0 +1,5 @@ +# Ansible managed +LoadPlugin cpufreq + + + diff --git a/templates/cpusleep.conf.j2 b/templates/cpusleep.conf.j2 new file mode 100644 index 0000000..1e8a669 --- /dev/null +++ b/templates/cpusleep.conf.j2 @@ -0,0 +1,5 @@ +# Ansible managed +LoadPlugin cpusleep + + + diff --git a/templates/csv.conf.j2 b/templates/csv.conf.j2 new file mode 100644 index 0000000..04b8966 --- /dev/null +++ b/templates/csv.conf.j2 @@ -0,0 +1,7 @@ +# Ansible managed +LoadPlugin csv + + + DataDir "{{ collectd_plugin_csv_datadir }}" + StoreRates "{{ collectd_plugin_csv_storerates }}" + diff --git a/templates/df.conf.j2 b/templates/df.conf.j2 index 5850078..a406027 100644 --- a/templates/df.conf.j2 +++ b/templates/df.conf.j2 @@ -1,9 +1,19 @@ +# Ansible managed LoadPlugin df - - IgnoreSelected true - ReportByDevice {{ collectd_plugin_df_reportbydevice }} - ReportInodes true - ValuesAbsolute true - ValuesPercentage true + +{% 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 }}" diff --git a/templates/disk.conf.j2 b/templates/disk.conf.j2 index a75f564..dbb5514 100644 --- a/templates/disk.conf.j2 +++ b/templates/disk.conf.j2 @@ -1,5 +1,11 @@ +# Ansible managed LoadPlugin disk - - IgnoreSelected {{ collectd_plugin_disk_ignoreselected }} + +{% 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 }} diff --git a/templates/load.conf.j2 b/templates/load.conf.j2 index bbe8940..b0c0e2e 100644 --- a/templates/load.conf.j2 +++ b/templates/load.conf.j2 @@ -1,5 +1,8 @@ +# Ansible managed LoadPlugin load - - ReportRelative true + +{% if collectd_plugin_load_reportrelative is defined %} + ReportRelative {{ collectd_plugin_load_reportrelative| string | lower }} +{% endif %} diff --git a/templates/memory.conf.j2 b/templates/memory.conf.j2 index 49b0b03..cc2ea27 100644 --- a/templates/memory.conf.j2 +++ b/templates/memory.conf.j2 @@ -1,6 +1,11 @@ +# Ansible managed LoadPlugin memory - - ValuesAbsolute true - ValuesPercentage true + +{% 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 %} diff --git a/templates/unixsock.conf.j2 b/templates/unixsock.conf.j2 index 5392805..f6464a9 100644 --- a/templates/unixsock.conf.j2 +++ b/templates/unixsock.conf.j2 @@ -1,4 +1,15 @@ +# Ansible managed LoadPlugin 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 %} diff --git a/templates/uptime.conf.j2 b/templates/uptime.conf.j2 index 5b44d0c..3767e7c 100644 --- a/templates/uptime.conf.j2 +++ b/templates/uptime.conf.j2 @@ -1 +1,5 @@ +# Ansible managed LoadPlugin uptime + + + diff --git a/templates/uuid.conf.j2 b/templates/uuid.conf.j2 new file mode 100644 index 0000000..e34a27b --- /dev/null +++ b/templates/uuid.conf.j2 @@ -0,0 +1,8 @@ +# Ansible managed +LoadPlugin uuid + + +{% if collectd_plugin_uuid_uuidfile is defined %} + UUIDFile "{{ collectd_plugin_uuid_uuidfile }}" +{% endif %} + diff --git a/templates/virt.conf.j2 b/templates/virt.conf.j2 index c721729..86d78d9 100644 --- a/templates/virt.conf.j2 +++ b/templates/virt.conf.j2 @@ -1,9 +1,18 @@ +# Ansible managed LoadPlugin 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 }}" + + 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 %} From 4b4225b519bcd54a9eb374200f0c221de60bb78f Mon Sep 17 00:00:00 2001 From: Emma Foley Date: Wed, 19 Aug 2020 11:34:53 -0400 Subject: [PATCH 2/4] Fix formatting in .travis.yml Travis CI will ignore incorrect .travis.yml files. Fixing syntax issues so CI will be enabled --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 36bbf62..4c2dcf5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ sudo: false addons: apt: packages: - - python-pip + - python-pip install: # Install ansible @@ -26,4 +26,5 @@ script: - ansible-playbook tests/test.yml -i tests/inventory --syntax-check notifications: - webhooks: https://galaxy.ansible.com/api/v1/notifications/ \ No newline at end of file + webhooks: https://galaxy.ansible.com/api/v1/notifications/ + From 12a3856670f5a7051607813f9c8f8f8bfecb3a8f Mon Sep 17 00:00:00 2001 From: Emma Foley Date: Wed, 19 Aug 2020 14:30:47 -0400 Subject: [PATCH 3/4] Update jobs to run current role --- .travis.yml | 3 +++ tests/test.yml | 27 ++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4c2dcf5..3649973 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,6 +24,9 @@ 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 notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/tests/test.yml b/tests/test.yml index 57efd16..32bba23 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -2,4 +2,29 @@ - hosts: localhost remote_user: root roles: - - test-role \ No newline at end of file + - '../../collectd-config-ansible-role' + vars: + collectd_output_conf_dir: "/etc/collectd.conf.d" + collectd_plugins: + # - amqp1 + # - ceph + - connectivity + - cpu + - 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 From 19e6e1e9137dc99cabb40f7fed405595b6b33d9c Mon Sep 17 00:00:00 2001 From: Emma Foley Date: Wed, 19 Aug 2020 14:39:39 -0400 Subject: [PATCH 4/4] Add in the tests from osp-observability-ansible --- .ansible-lint | 3 +++ .travis.yml | 21 +++++++++++++++------ tests/inventory | 2 +- tests/kolla_config_files/config.json | 10 ++++++++++ tests/test.yml | 2 +- 5 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 .ansible-lint create mode 100644 tests/kolla_config_files/config.json diff --git a/.ansible-lint b/.ansible-lint new file mode 100644 index 0000000..67ed73b --- /dev/null +++ b/.ansible-lint @@ -0,0 +1,3 @@ +skip_list: + - '701' # Role info should contain platforms + - '703' # Should change default metadata diff --git a/.travis.yml b/.travis.yml index 3649973..0fe8dfe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 +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 @@ -26,8 +33,10 @@ script: - ansible-playbook tests/test.yml -i tests/inventory --syntax-check - ansible-lint # Run the role - - ansible-playbook tests/test.yml -i tests/inventory + - 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/ - diff --git a/tests/inventory b/tests/inventory index 878877b..49d4fe2 100644 --- a/tests/inventory +++ b/tests/inventory @@ -1,2 +1,2 @@ -localhost +localhost ansible_connection=local diff --git a/tests/kolla_config_files/config.json b/tests/kolla_config_files/config.json new file mode 100644 index 0000000..fb394e4 --- /dev/null +++ b/tests/kolla_config_files/config.json @@ -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 + } + ] +} diff --git a/tests/test.yml b/tests/test.yml index 32bba23..d073341 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -4,12 +4,12 @@ roles: - '../../collectd-config-ansible-role' vars: - collectd_output_conf_dir: "/etc/collectd.conf.d" collectd_plugins: # - amqp1 # - ceph - connectivity - cpu + - csv - df - disk - hugepages