Browse Source

Ansible for collectd

* Intended to replace puppet implementation
* Molecule tests included

Change-Id: Ib75702bf17a76cae3a811db503d3365e6aacf663
changes/09/776709/14
Emma Foley 7 months ago
parent
commit
9ebb8b20b7
  1. 6
      doc/source/roles/role-tripleo_collectd.rst
  2. 228
      tripleo_ansible/roles/tripleo_collectd/defaults/main.yml
  3. 2
      tripleo_ansible/roles/tripleo_collectd/files/openstack-healthcheck.conf
  4. 33
      tripleo_ansible/roles/tripleo_collectd/meta/main.yml
  5. 35
      tripleo_ansible/roles/tripleo_collectd/molecule/amqp_connection/converge.yml
  6. 59
      tripleo_ansible/roles/tripleo_collectd/molecule/amqp_connection/molecule.yml
  7. 28
      tripleo_ansible/roles/tripleo_collectd/molecule/amqp_connection/verify.yml
  8. 37
      tripleo_ansible/roles/tripleo_collectd/molecule/amqp_default_interval/converge.yml
  9. 59
      tripleo_ansible/roles/tripleo_collectd/molecule/amqp_default_interval/molecule.yml
  10. 36
      tripleo_ansible/roles/tripleo_collectd/molecule/amqp_default_interval/verify.yml
  11. 43
      tripleo_ansible/roles/tripleo_collectd/molecule/collectd_connection/converge.yml
  12. 85
      tripleo_ansible/roles/tripleo_collectd/molecule/collectd_connection/molecule.yml
  13. 98
      tripleo_ansible/roles/tripleo_collectd/molecule/collectd_connection/verify.yml
  14. 36
      tripleo_ansible/roles/tripleo_collectd/molecule/common/Dockerfile
  15. 59
      tripleo_ansible/roles/tripleo_collectd/molecule/common/prepare.yml
  16. 7
      tripleo_ansible/roles/tripleo_collectd/molecule/common/requirements.yml
  17. 89
      tripleo_ansible/roles/tripleo_collectd/molecule/common/verify.yml
  18. 33
      tripleo_ansible/roles/tripleo_collectd/molecule/default/converge.yml
  19. 65
      tripleo_ansible/roles/tripleo_collectd/molecule/default/molecule.yml
  20. 39
      tripleo_ansible/roles/tripleo_collectd/molecule/default/verify.yml
  21. 34
      tripleo_ansible/roles/tripleo_collectd/molecule/enable_libpodstats/converge.yml
  22. 59
      tripleo_ansible/roles/tripleo_collectd/molecule/enable_libpodstats/molecule.yml
  23. 52
      tripleo_ansible/roles/tripleo_collectd/molecule/enable_libpodstats/verify.yml
  24. 18
      tripleo_ansible/roles/tripleo_collectd/molecule/enable_sensubility/converge.yml
  25. 59
      tripleo_ansible/roles/tripleo_collectd/molecule/enable_sensubility/molecule.yml
  26. 61
      tripleo_ansible/roles/tripleo_collectd/molecule/enable_sensubility/verify.yml
  27. 34
      tripleo_ansible/roles/tripleo_collectd/molecule/enable_sqlalchemy/converge.yml
  28. 59
      tripleo_ansible/roles/tripleo_collectd/molecule/enable_sqlalchemy/molecule.yml
  29. 7
      tripleo_ansible/roles/tripleo_collectd/molecule/enable_sqlalchemy/requirements.yml
  30. 46
      tripleo_ansible/roles/tripleo_collectd/molecule/enable_sqlalchemy/verify.yml
  31. 34
      tripleo_ansible/roles/tripleo_collectd/molecule/enable_stf/converge.yml
  32. 59
      tripleo_ansible/roles/tripleo_collectd/molecule/enable_stf/molecule.yml
  33. 36
      tripleo_ansible/roles/tripleo_collectd/molecule/enable_stf/verify.yml
  34. 226
      tripleo_ansible/roles/tripleo_collectd/tasks/configure_collectd.yml
  35. 47
      tripleo_ansible/roles/tripleo_collectd/tasks/configure_healthcheck.yml
  36. 22
      tripleo_ansible/roles/tripleo_collectd/tasks/configure_host_software.yml
  37. 30
      tripleo_ansible/roles/tripleo_collectd/tasks/create_persistent_directories.yml
  38. 33
      tripleo_ansible/roles/tripleo_collectd/tasks/main.yml
  39. 52
      tripleo_ansible/roles/tripleo_collectd/templates/collectd-sensubility.conf.j2
  40. 50
      tripleo_ansible/roles/tripleo_collectd/vars/main.yml
  41. 10
      zuul.d/molecule.yaml

6
doc/source/roles/role-tripleo_collectd.rst

@ -0,0 +1,6 @@
=======================
Role - tripleo_collectd
=======================
.. ansibleautoplugin::
:role: tripleo_ansible/roles/tripleo_collectd

228
tripleo_ansible/roles/tripleo_collectd/defaults/main.yml

@ -0,0 +1,228 @@
---
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# Corresponds to MetricsQdrPort in THT
# Service name or port number on which the qdrouterd will accept connections.
metrics_qdr_port: 5666
# Corresponds to MetricsQdrUsername in THT
# Username which should be used to authenticate to the deployed qdrouterd.
metrics_qdr_username: guest
# Corresponds to MetricsQdrPassword in THT
# Password which should be used to authenticate to the deployed qdrouterd.
metrics_qdr_password: guest
# Corresponds to MonitoringSubscriptionCollectd in THT
tripleo_collectd_monitoring_subscription: overcloud-collectd
# Corresponds to CollectdConnectionType in THT
# Define which write plugin should collectd use. Currently supported are 'amqp1',
# 'network' and 'gnocchi'.
tripleo_collectd_connection_type: amqp1
# Corresponds to CollectdDefaultPollingInterval in THT
# Controls how often registered read functions are called and with that the
# resolution of the collected data. This value can be overridden per plugin(per
# role) by setting "::collectd::plugin::<plugin_name>::interval" key in
# ExtraConfig(<role_name>ExtraConfig).
tripleo_collectd_default_polling_interval: 120
# Corresponds to CollectdDefaultPlugins in THT
# List of collectd plugins to activate on all overcloud hosts. See the
# documentation for the puppet-collectd module for a list plugins supported by
# the module (https://github.com/voxpupuli/puppet-collectd). Set this key to
# override the default list of plugins. Use CollectdExtraPlugins if you want to
# load additional plugins without overriding the defaults.
tripleo_collectd_default_plugins: ['cpu', 'df', 'disk', 'hugepages', 'interface', 'load', 'memory', 'processes', 'unixsock', 'uptime']
# Corresponds to CollectdExtraPlugins in THT
# List of collectd plugins to activate on all overcloud hosts. See the
# documentation for the puppet-collectd module for a list plugins supported by
# the module (https://github.com/voxpupuli/puppet-collectd). Set this key to load
# plugins in addition to those in CollectdDefaultPlugins.
tripleo_collectd_extra_plugins: []
# Corresponds to CollectdServer in THT
# Address of remote collectd server to which we will send metrics.
tripleo_collectd_server:
# Corresponds to CollectdServerPort in THT
# Port on remote collectd server to which we will send metrics.
tripleo_collectd_server_port: 25826
# Corresponds to CollectdUsername in THT
# Username for authenticating to the remote collectd server. The default is to
# not configure any authentication.
tripleo_collectd_username:
# Corresponds to CollectdPassword in THT
# Password for authenticating to the remote collectd server. The default is to
# not configure any authentication.
tripleo_collectd_password:
# Corresponds to CollectdSecurityLevel in THT
# Security level setting for remote collectd connection. If it is set to Sign or
# Encrypt the CollectdPassword and CollectdUsername parameters need to be set.
tripleo_collectd_security_level: None
# Corresponds to EnableSQLAlchemyCollectd in THT
# Set to true to enable the SQLAlchemy-collectd server plugin
tripleo_collectd_enable_sqlalchemy: false
# Corresponds to CollectdSQLAlchemyLogMessages in THT
# set to "debug" to enable message logging.
tripleo_collectd_sqlalchemy_log_messages: info
# Corresponds to CollectdSQLAlchemyBindHost in THT
# hostname for SQLAlchemy-collectd plugin to bind on. defaults to localhost.
tripleo_collectd_sqlalchemy_bind_host: localhost
# Corresponds to CollectdAmqpHost in THT
# Hostname or IP address of the AMQP 1.0 intermediary.
tripleo_collectd_amqp_host: nil
# Corresponds to CollectdAmqpPort in THT
# Service name or port number on which the AMQP 1.0 intermediary accepts
# connections. This argument must be a string, even if the numeric form is used.
tripleo_collectd_amqp_port: 5666
# Corresponds to CollectdAmqpUser in THT
# User part of credentials used to authenticate to the AMQP 1.0 intermediary.
tripleo_collectd_amqp_user: guest
# Corresponds to CollectdAmqpPassword in THT
# Password part of credentials used to authenticate to the AMQP 1.0 intermediary.
tripleo_collectd_amqp_password: guest
# Corresponds to CollectdAmqpTransportName in THT
# Name of the AMQP 1.0 transport.
tripleo_collectd_amqp_transport_name: metrics
# Corresponds to CollectdAmqpAddress in THT
# This option specifies the prefix for the send-to value in the message.
tripleo_collectd_amqp_address: collectd
# Corresponds to CollectdAmqpInstances in THT
# Hash of hashes. Each inner hash represent Instance block in plugin
# configuration file. Key of outter hash represents instance name. The 'address'
# value concatenated with the 'name' given will be used as the send-to address
# for communications over the messaging link.
tripleo_collectd_amqp_instances: {}
# Corresponds to CollectdAmqpRetryDelay in THT
# When the AMQP 1.0 connection is lost, defines the time in seconds to wait
# before attempting to reconnect.
tripleo_collectd_amqp_retry_delay: 1
# Corresponds to CollectdAmqpInterval in THT
# Interval on which metrics should be sent to AMQP intermediary. If not set the
# default for all collectd plugins is used.
tripleo_collectd_amqp_interval: -666
# Corresponds to CollectdAmqpSendQueueLimit in THT
# Number of data sets to be kept in memory, older sets will be discarded,
# if set to -1, this feature is disabled.
tripleo_collectd_amqp_send_queue_limit: -1
# Corresponds to CollectdEnableSensubility in THT
# Set to true if sensubility should be executed by exec plugin.
tripleo_collectd_enable_sensubility: false
# Corresponds to CollectdSensubilityExecSudoRule in THT
# Given rule will be created in /etc/sudoers.d for sensubility to enable it
# calling restricted commands via sensubility executor.
tripleo_collectd_sensubility_exec_sudo_rule: ''
# Corresponds to CollectdSensubilityLogLevel in THT
# Use for override the default logging level (WARNING).
tripleo_collectd_sensubility_log_level: WARNING
# Corresponds to CollectdSensubilityConnection in THT
# URL to Sensu sever side
tripleo_collectd_sensubility_connection: amqp://sensu:sensu@localhost:5672//sensu
tripleo_collectd_sensubility_subscriptions: []
# Corresponds to CollectdSensubilityKeepaliveInterval in THT
# Interval in seconds for sending keepalive messages to Sensu server side.
tripleo_collectd_sensubility_keepalive_interval: 20
# Corresponds to CollectdSensubilityTmpDir in THT
# Path to temporary directory which is used for creation of check scripts.
tripleo_collectd_sensubility_tmp_dir: /var/tmp/collectd-sensubility-checks
# Corresponds to CollectdSensubilityShellPath in THT
# Path to shell used for executing check scripts.
tripleo_collectd_sensubility_shell_path: /usr/bin/sh
# Corresponds to CollectdSensubilityWorkerCount in THT
# Number of goroutines spawned for executing check scripts.
tripleo_collectd_sensubility_worker_count: 2
# Corresponds to CollectdSensubilityChecks in THT
# JSON formated definition of standalone checks to be scheduled on client side.
tripleo_collectd_sensubility_checks: {}
# Corresponds to CollectdSensubilityTransport in THT
# Bus type for sent data. Options are 'sensu' (rabbitmq) and 'amqp1'
tripleo_collectd_sensubility_transport: sensu
# Corresponds to CollectdSensubilityResultsChannel in THT
# AMQP1 channel address
tripleo_collectd_sensubility_results_channel: 'collectd/notify'
# Corresponds to CollectdEnableContainerHealthCheck in THT
# Set to false if container health check should not be defined and attached to
# CollectdEnableContainerHealthCheck.
tripleo_collectd_enable_container_health_check: true
# Corresponds to CollectdContainerHealthCheckCommand in THT
# The command to be run by sensubility when the health check is enabled.
# Defaults to a script that is expected to be placed by TripleO at the given
# location.
tripleo_collectd_container_health_check_command: /scripts/collectd_check_health.py
# Corresponds to CollectdContainerHealthCheckInterval in THT
# The frequency in seconds the docker health check is executed.
tripleo_collectd_container_health_check_interval: 10
# Corresponds to CollectdContainerHealthCheckHandlers in THT
# The Sensu event handler to use for events created by the docker health check.
tripleo_collectd_container_health_check_handlers: []
# Corresponds to CollectdContainerHealthCheckOccurrences in THT
# The number of event occurrences before sensu-plugin-aware handler should take
# action.
tripleo_collectd_container_health_check_occurrences: 3
# Corresponds to CollectdContainerHealthCheckRefresh in THT
# The number of seconds sensu-plugin-aware handlers should wait before taking
# second action.
tripleo_collectd_container_health_check_refresh: 90
# Corresponds to EnableSTF in THT
# Set to true to enable configuration for STF client.
tripleo_collectd_enable_stf: false
# Corresponds to CollectdEnableMcelog in THT
# Set to true to enable mcelog
tripleo_collectd_enable_mcelog: false
# Corresponds to CollectdEnableLibpodstats in THT
# Set to true if collectd should run the libpodstats plugin
tripleo_collectd_enable_libpodstats: false

2
tripleo_ansible/roles/tripleo_collectd/files/openstack-healthcheck.conf

@ -0,0 +1,2 @@
if ($programname startswith 'podman' and ($msg contains 'container exec' or $msg contains 'healthy')) or ($programname startswith 'systemd' and $msg contains 'podman healthcheck run') then -/var/log/containers/collectd/healthchecks.stdout
& stop

33
tripleo_ansible/roles/tripleo_collectd/meta/main.yml

@ -0,0 +1,33 @@
---
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
galaxy_info:
author: OpenStack
description: TripleO OpenStack Role -- tripleo_collectd
company: Red Hat
license: Apache-2.0
min_ansible_version: 2.9
platforms:
- name: CentOS
versions:
- 7
- 8
galaxy_tags:
- tripleo
dependencies: []

35
tripleo_ansible/roles/tripleo_collectd/molecule/amqp_connection/converge.yml

@ -0,0 +1,35 @@
---
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- name: Converge
hosts: all
tasks:
- name: "Set up expected THT vars"
set_fact:
tripleo_role_name: "SomeRole"
service_net_map:
some_role_metrics_qdr_network: "ctlplane"
ctlplane_ip: "10.0.0.42"
- name: "Use the tripleo_collectd role to configure collectd to export metrics to amqp"
include_role:
name: "{{ playbook_dir }}/../../../tripleo_collectd"
tasks_from: configure_collectd
vars:
collectd_conf_output_dir: "/etc/collectd.d/"
# This is not the right things to put here... need to check tripleo_collectd
tripleo_collectd_connection_type: 'amqp1'

59
tripleo_ansible/roles/tripleo_collectd/molecule/amqp_connection/molecule.yml

@ -0,0 +1,59 @@
---
driver:
name: podman
platforms:
- name: collectd-test
hostname: collectd-test
image: ubi8/ubi-init
registry:
url: registry.access.redhat.com
dockerfile: ../common/Dockerfile
pkg_extras: python*setuptools
volumes:
- /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
privileged: true
environment: &env
http_proxy: "{{ lookup('env', 'http_proxy') }}"
https_proxy: "{{ lookup('env', 'https_proxy') }}"
CONTAINER_BIN: podman
ulimits: &ulimit
- host
provisioner:
inventory:
hosts:
all:
hosts:
collectd-test:
ansible_python_interpreter: /usr/bin/python3
host_vars:
collectd-test:
collectd_conf_output_dir: "/etc/collectd.d/"
name: ansible
log: true
env:
ANSIBLE_STDOUT_CALLBACK: yaml
ANSIBLE_FILTER_PLUGINS: "${ANSIBLE_FILTER_PLUGINS:-\
/usr/share/ansible/plugins/filter}"
playbooks:
prepare: ../common/prepare.yml
verifier:
name: ansible
dependency:
name: galaxy
options:
role-file: molecule/common/requirements.yml
scenario:
test_sequence:
- destroy
- dependency
- create
- prepare
- converge
- check
- verify
- destroy

28
tripleo_ansible/roles/tripleo_collectd/molecule/amqp_connection/verify.yml

@ -0,0 +1,28 @@
---
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- import_playbook: ../common/verify.yml
- name: Verify
hosts: all
tasks:
- name: "Get amqp conf"
stat:
path: "{{ collectd_conf_output_dir }}/amqp1.conf"
register: amqp_conf
failed_when:
- not amqp_conf.stat.exists

37
tripleo_ansible/roles/tripleo_collectd/molecule/amqp_default_interval/converge.yml

@ -0,0 +1,37 @@
---
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- name: Converge
hosts: all
tasks:
- name: "Set up expected THT vars"
set_fact:
tripleo_role_name: "SomeRole"
service_net_map:
some_role_metrics_qdr_network: "ctlplane"
ctlplane_ip: "10.0.0.42"
- name: "Use tripleo_collectd to configure collectd using the default interval for amqp"
include_role:
name: "{{ playbook_dir }}/../../../tripleo_collectd"
tasks_from: configure_collectd
vars:
collectd_conf_output_dir: "/etc/collectd.d/"
tripleo_collectd_amqp_host: collectd-test
# This is not the right things to put here... need to check tripleo_collectd
tripleo_collectd_connection_type: 'amqp1'
tripleo_collectd_amqp_interval: -666

59
tripleo_ansible/roles/tripleo_collectd/molecule/amqp_default_interval/molecule.yml

@ -0,0 +1,59 @@
---
driver:
name: podman
platforms:
- name: collectd-test
hostname: collectd-test
image: ubi8/ubi-init
registry:
url: registry.access.redhat.com
dockerfile: ../common/Dockerfile
pkg_extras: python*setuptools
volumes:
- /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
privileged: true
environment: &env
http_proxy: "{{ lookup('env', 'http_proxy') }}"
https_proxy: "{{ lookup('env', 'https_proxy') }}"
CONTAINER_BIN: podman
ulimits: &ulimit
- host
provisioner:
inventory:
hosts:
all:
hosts:
collectd-test:
ansible_python_interpreter: /usr/bin/python3
host_vars:
collectd-test:
collectd_conf_output_dir: "/etc/collectd.d/"
name: ansible
log: true
env:
ANSIBLE_STDOUT_CALLBACK: yaml
ANSIBLE_FILTER_PLUGINS: "${ANSIBLE_FILTER_PLUGINS:-\
/usr/share/ansible/plugins/filter}"
playbooks:
prepare: ../common/prepare.yml
verifier:
name: ansible
dependency:
name: galaxy
options:
role-file: molecule/common/requirements.yml
scenario:
test_sequence:
- destroy
- dependency
- create
- prepare
- converge
- check
- verify
- destroy

36
tripleo_ansible/roles/tripleo_collectd/molecule/amqp_default_interval/verify.yml

@ -0,0 +1,36 @@
---
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- import_playbook: ../common/verify.yml
- name: Verify
hosts: all
tasks:
- name: "Get amqp conf"
stat:
path: "{{ collectd_conf_output_dir }}/amqp1.conf"
register: amqp_conf
failed_when:
- not amqp_conf.stat.exists
- name: "Check that default interval was unchanged"
command:
grep "Interval" {{ collectd_conf_output_dir }}/amqp1.conf
register: interval
changed_when: false
failed_when:
- ( interval.stdout | length != 0 ) or ( interval.stderr_lines | length != 0 )

43
tripleo_ansible/roles/tripleo_collectd/molecule/collectd_connection/converge.yml

@ -0,0 +1,43 @@
---
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- name: Converge
hosts: collectd-test
tasks:
- name: "Use tripleo_collectd to configure collectd to sent metrics using the network plugin"
include_role:
name: "{{ playbook_dir }}/../../../tripleo_collectd"
tasks_from: configure_collectd
vars:
collectd_conf_output_dir: "/etc/collectd.d/"
tripleo_collectd_connection_type: 'network'
tripleo_collectd_server: '192.168.42.2'
- name: Converge collectd-server
hosts: collectd-server
tasks:
- name: "Configure collectd on the server to receive metrics"
include_role:
name: collectd_config
vars:
collectd_conf_output_dir: "/etc/collectd.d/"
collectd_plugin_network_listen:
- address: "192.168.42.2"
collectd_plugins:
- logfile
- network
- unixsock

85
tripleo_ansible/roles/tripleo_collectd/molecule/collectd_connection/molecule.yml

@ -0,0 +1,85 @@
---
dependency:
name: galaxy
options:
role-file: molecule/common/requirements.yml
driver:
name: podman
platforms:
- name: collectd-test
hostname: collectd-test
image: ubi8/ubi-init
registry:
url: registry.access.redhat.com
dockerfile: ../common/Dockerfile
pkg_extras: python*setuptools
volumes:
- /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
privileged: true
environment: &env
http_proxy: "{{ lookup('env', 'http_proxy') }}"
https_proxy: "{{ lookup('env', 'https_proxy') }}"
CONTAINER_BIN: podman
ulimits: &ulimit
- host
docker_networks:
- name: collectd
ipam_config:
- subnet: "192.168.42.0/24"
gateway: "192.168.42.254"
networks:
- name: collectd
ipv4_address: "192.168.42.1"
- name: collectd-server
hostname: collectd-server
image: ubi8/ubi-init
registry:
url: registry.access.redhat.com
dockerfile: ../common/Dockerfile
pkg_extras: python*setuptools
volumes:
- /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
privileged: true
environment:
http_proxy: "{{ lookup('env', 'http_proxy') }}"
https_proxy: "{{ lookup('env', 'https_proxy') }}"
CONTAINER_BIN: podman
ulimits:
- host
networks:
- name: collectd
ipv4_address: "192.168.42.2"
provisioner:
inventory:
hosts:
all:
hosts:
collectd-test:
ansible_python_interpreter: /usr/bin/python3
host_vars:
collectd-test:
collectd_conf_output_dir: "/etc/collectd.d/"
name: ansible
log: true
env:
ANSIBLE_STDOUT_CALLBACK: yaml
ANSIBLE_FILTER_PLUGINS: "${ANSIBLE_FILTER_PLUGINS:-\
/usr/share/ansible/plugins/filter}"
playbooks:
prepare: ../common/prepare.yml
verifier:
name: ansible
scenario:
test_sequence:
- destroy
- dependency
- create
- prepare
- converge
- verify
- destroy
- cleanup

98
tripleo_ansible/roles/tripleo_collectd/molecule/collectd_connection/verify.yml

@ -0,0 +1,98 @@
---
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# TODO: Reconsider this later, but it seems like a bad fit right now, since
# there are two hosts in the scenario, and this relies on there being one, and
# using podman
# - import_playbook: ../common/verify.yml
- name: Verify collectd-test
hosts: collectd-test
tasks:
- name: "Check that network.conf exists"
stat:
path: "{{ collectd_conf_output_dir }}/network.conf"
register: network_conf
failed_when:
- not network_conf.stat.exists
- name: "Get the network.conf is configuration"
slurp:
path: "{{ collectd_conf_output_dir }}/network.conf"
register: network_conf
- name: "Check the contents of network.conf"
assert:
that:
- '"<Server \"192.168.42.2\" \"25826\">" in network_conf.content | b64decode'
- '"SecurityLevel \"None\"" in network_conf.content | b64decode'
- not "Username" in network_conf.content | b64decode
- not "Password" in network_conf.content | b64decode
fail_msg: "Incorrect contents in network.conf: {{ network_conf.content | b64decode }}"
- name: "(Re)start collectd service"
hosts:
- all
tasks:
- name: "Kill running collectd process"
command:
pkill -e -c collectd
ignore_errors: true
changed_when: false
- name: "Start collectd"
command:
/usr/sbin/collectd -C /etc/collectd.conf
changed_when: false
- name: Verify collectd-server
hosts: collectd-server
tasks:
- name: Check for files in conf output dir
find:
paths: /etc/collectd.d
patterns: '*.conf'
register: output
failed_when:
- output.files | length == 0
- name: "Check for collectd.conf"
find:
paths: /etc/
patterns: collectd.conf
register: conf
failed_when:
- conf.files | length != 1
- name: "Check for metrics received by the collectd server"
command:
collectdctl -s /var/run/collectd-socket listval
retries: 3
delay: 5
register: plugins
until: plugins.stdout_lines | length > 0
changed_when: false
failed_when:
- ( plugins.stderr | length > 0 ) or ( plugins.rc != 0 )
- name: "Make sure the metrics on collectd-server are from collectd-test"
shell: |
set -o pipefail
collectdctl -s /var/run/collectd-socket listval | grep ^collectd-test/ | wc -l
register: test_plugins
changed_when: false
failed_when:
- plugins.stdout_lines | length != test_plugins.stdout | int

36
tripleo_ansible/roles/tripleo_collectd/molecule/common/Dockerfile

@ -0,0 +1,36 @@
# Molecule managed
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
{% if item.registry is defined %}
FROM {{ item.registry.url }}/{{ item.image }}
{% else %}
FROM {{ item.image }}
{% endif %}
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install sudo python*-devel python*-dnf bash {{ item.pkg_extras | default('') }} && dnf clean all; \
elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl python-setuptools bash {{ item.pkg_extras | default('') }} && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml {{ item.pkg_extras | default('') }} && zypper clean -a; \
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates {{ item.pkg_extras | default('') }}; \
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates {{ item.pkg_extras | default('') }} && xbps-remove -O; fi
{% for pkg in item.easy_install | default([]) %}
# install pip for centos where there is no python-pip rpm in default repos
RUN easy_install {{ pkg }}
{% endfor %}
CMD ["sh", "-c", "while true; do sleep 10000; done"]

59
tripleo_ansible/roles/tripleo_collectd/molecule/common/prepare.yml

@ -0,0 +1,59 @@
---
# Copyright 2020 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- name: Prepare
hosts: all
tasks:
- name: "Enable delorean repos"
command: |
dnf config-manager --add-repo https://trunk.rdoproject.org/centos{{ ansible_facts['distribution_major_version'] }}/current/delorean.repo
- name: "Install tripleo-repos"
package:
name: "python*tripleo-repos"
state: present
- name: "Set-up tripleo-repos"
command: |
tripleo-repos -b master current-tripleo
- name: "Install collectd plugin packages"
package:
name:
- collectd
- collectd-amqp1
- collectd-disk
- collectd-hugepages
# for collectdctl
- collectd-utils
# enable_stf
- collectd-connectivity
- collectd-ipmi
- collectd-procevent
- collectd-rdt
# enable_sqlalchemy
- collectd-python
- python3-sqlalchemy-collectd
# libpodstats
- collectd-libpod-stats
state: present
- name: "Create a directory for the log file"
file:
path: /var/log/collectd/
state: directory
mode: 0766

7
tripleo_ansible/roles/tripleo_collectd/molecule/common/requirements.yml

@ -0,0 +1,7 @@
---
roles:
- src: git+https://github.com/infrawatch/functional-tests
name: functional_tests
- src: git+http://github.com/infrawatch/collectd-config-ansible-role
name: collectd_config

89
tripleo_ansible/roles/tripleo_collectd/molecule/common/verify.yml

@ -0,0 +1,89 @@
---
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- name: "Common Verify tasks"
hosts: all
tasks:
- name: Check for files in conf output dir
find:
paths: "{{ collectd_conf_output_dir }}"
patterns: '*.conf'
register: plugins
failed_when:
- plugins.files | length == 0
- name: "Check for collectd.conf"
stat:
path: "{{ collectd_conf_output_dir }}/../collectd.conf"
register: conf
failed_when:
- not conf.stat.exists
- name: "Check what plugins were enabled."
command: |
ls {{ collectd_conf_output_dir }}
register: plugins
changed_when: false
failed_when: >
( plugins.stdout_lines | length < 1 ) or
( 'logfile.conf' not in plugins.stdout_lines )
- name: "Debug -- list of plugins, one per line"
debug:
var: plugins.stdout_lines
- name: "(Re)start collectd service"
block:
- name: "Kill running collectd process"
command:
pkill -e -c collectd
ignore_errors: true
- name: "Start collectd"
command:
/usr/sbin/collectd -C /etc/collectd.conf
- name: "Get logfile path"
shell: |
set -o pipefail
grep "File" {{ collectd_conf_output_dir }}/logfile.conf | awk '{ print $NF }'
register: logfile_path
changed_when: false
- name: "Make sure there is a directory for the logfile to live in since collectd doesn't seem to create this by default"
stat:
path: "{{ logfile_path.stdout | regex_replace('\"', '') | dirname }}"
register: logfile_stat
failed_when:
- not logfile_stat.stat.exists
- name: "Make sure the logfile is created"
stat:
path: "{{ logfile_path.stdout | regex_replace('\"', '') }}"
register: logfile_stat
failed_when:
- not logfile_stat.stat.exists
- hosts: localhost
tasks:
- name: "Run the collectd test from STF functional-tests"
include_role:
name: functional_tests
tasks_from: test_collectd
vars:
collectd_container_name: 'collectd-test'
container_bin: "{{ lookup('env', 'CONTAINER_BIN') | default('podman', True) }}"

33
tripleo_ansible/roles/tripleo_collectd/molecule/default/converge.yml

@ -0,0 +1,33 @@
---
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- name: Converge
hosts: all
tasks:
- name: "Set up expected THT vars"
set_fact:
tripleo_role_name: "SomeRole"
service_net_map:
some_role_metrics_qdr_network: "ctlplane"
ctlplane_ip: "10.0.0.42"
- name: "Use tripleo_collectd to configure collectd with defaults"
include_role:
name: "{{ playbook_dir }}/../../../tripleo_collectd"
tasks_from: configure_collectd
vars:
collectd_conf_output_dir: "/etc/collectd.d/"

65
tripleo_ansible/roles/tripleo_collectd/molecule/default/molecule.yml

@ -0,0 +1,65 @@
---
driver:
name: podman
platforms:
- name: collectd-test
hostname: collectd-test
image: ubi8/ubi-init
registry:
url: registry.access.redhat.com
dockerfile: ../common/Dockerfile
pkg_extras: python*setuptools
volumes:
- /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
- /etc/pki/rpm-gpg:/etc/pki/rpm-gpg
privileged: true
environment: &env
http_proxy: "{{ lookup('env', 'http_proxy') }}"
https_proxy: "{{ lookup('env', 'https_proxy') }}"
CONTAINER_BIN: podman
ulimits: &ulimit
- host
provisioner:
inventory:
hosts:
all:
hosts:
collectd-test:
ansible_python_interpreter: /usr/bin/python3
host_vars:
collectd-test:
collectd_conf_output_dir: "/etc/collectd.d/"
name: ansible
log: true
env:
ANSIBLE_STDOUT_CALLBACK: yaml
ANSIBLE_FILTER_PLUGINS: "${ANSIBLE_FILTER_PLUGINS:-\
/usr/share/ansible/plugins/filter}"
playbooks:
prepare: ../common/prepare.yml
verify: ../common/verify.yml
lint: |
ansible-lint **/*.yml
verifier:
name: ansible
dependency:
name: galaxy
options:
role-file: molecule/common/requirements.yml
scenario:
name: default
test_sequence:
- destroy
- dependency
- create
- prepare
- converge
- check
- verify
- destroy

39
tripleo_ansible/roles/tripleo_collectd/molecule/default/verify.yml

@ -0,0 +1,39 @@
---
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- import_playbook: ../common/verify.yml
- name: Verify
hosts: all
tasks:
- name: "Check that the right plugins are enabled"
stat:
path: "{{ collectd_conf_output_dir }}/{{ item }}.conf"
register: conf
failed_when:
- not conf.stat.exists
loop:
- cpu
- df
- disk
- hugepages
- interface
- load
- memory
- processes
- unixsock
- uptime

34
tripleo_ansible/roles/tripleo_collectd/molecule/enable_libpodstats/converge.yml

@ -0,0 +1,34 @@
---
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- name: Converge
hosts: all
tasks:
- set_fact:
tripleo_role_name: "SomeRole"
service_net_map:
some_role_metrics_qdr_network: "ctlplane"
ctlplane_ip: "10.0.0.42"
fqdn_ctlplane: "standalone.ctlplane.localdomain"
- name: "Use tripleo_collectd to configure collectd with defaults"
include_role:
name: '{{ playbook_dir }}/../../../tripleo_collectd'
tasks_from: configure_collectd
vars:
collectd_conf_output_dir: "/etc/collectd.d"
tripleo_collectd_enable_libpodstats: true

59
tripleo_ansible/roles/tripleo_collectd/molecule/enable_libpodstats/molecule.yml

@ -0,0 +1,59 @@
---
driver:
name: podman
platforms:
- name: collectd-test
hostname: collectd-test
image: ubi8/ubi-init
registry:
url: registry.access.redhat.com
dockerfile: ../common/Dockerfile
pkg_extras: python*setuptools
volumes:
- /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
privileged: true
environment: &env
http_proxy: "{{ lookup('env', 'http_proxy') }}"
https_proxy: "{{ lookup('env', 'https_proxy') }}"
CONTAINER_BIN: podman
ulimits: &ulimit
- host
provisioner:
inventory:
hosts:
all:
hosts:
collectd-test:
ansible_python_interpreter: /usr/bin/python3
host_vars:
collectd-test:
collectd_conf_output_dir: "/etc/collectd.d/"
name: ansible
log: true
env:
ANSIBLE_STDOUT_CALLBACK: yaml
ANSIBLE_FILTER_PLUGINS: "${ANSIBLE_FILTER_PLUGINS:-\
/usr/share/ansible/plugins/filter}"
playbooks:
prepare: ../common/prepare.yml
verifier:
name: ansible
dependency:
name: galaxy
options:
role-file: molecule/common/requirements.yml
scenario:
test_sequence:
- destroy
- dependency
- create
- prepare
- converge
- check
- verify
- destroy

52
tripleo_ansible/roles/tripleo_collectd/molecule/enable_libpodstats/verify.yml

@ -0,0 +1,52 @@
---
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- import_playbook: ../common/verify.yml
- name: "Verify collectd libpodstats plugin"
hosts: all
tasks:
- name: Check that the libpodstats conf file exists
stat:
path: '/etc/collectd.d/libpodstats.conf'
register: output
failed_when:
- not output.stat.exists
- name: Get contents of libpodstats.conf
slurp:
src: /etc/collectd.d/libpodstats.conf
register: libpodstats_conf
failed_when:
- not 'LoadPlugin "libpodstats"' in libpodstats_conf.content | b64decode
- not '<Plugin "libpodstats">' in libpodstats_conf.content | b64decode
- not '</Plugin>' in libpodstats_conf.content | b64decode
- name: "Check that the TypesDB has been updated"
slurp:
src: /etc/collectd.conf
register: output
failed_when:
- not "TypesDB \"/etc/collectd.d/types.db.libpodstats\"" in output.content | b64decode
- name: "Check that the contents of types.db.libpodstats are as expected"
slurp:
src: /etc/collectd.d/types.db.libpodstats
register: typesdb
failed_when:
- not "pod_cpu percent:GAUGE:0:100.1, time:DERIVE:0:U" in typesdb.content | b64decode
- not "pod_memory value:GAUGE:0:281474976710656" in typesdb.content | b64decode

18
tripleo_ansible/roles/tripleo_collectd/molecule/enable_sensubility/converge.yml

@ -0,0 +1,18 @@
---
- name: Converge
hosts: all
tasks:
- set_fact:
tripleo_role_name: "SomeRole"
service_net_map:
some_role_metrics_qdr_network: "ctlplane"
ctlplane_ip: "10.0.0.42"
fqdn_ctlplane: "standalone.ctlplane.localdomain"
- include_role:
name: '{{ playbook_dir }}/../../../tripleo_collectd'
tasks_from: configure_collectd
vars:
collectd_conf_output_dir: "/etc/collectd.d/"
tripleo_collectd_enable_sensubility: true
tripleo_collectd_sensubility_exec_sudo_rule: "collectd ALL = NOPASSWD: ALL"

59
tripleo_ansible/roles/tripleo_collectd/molecule/enable_sensubility/molecule.yml

@ -0,0 +1,59 @@
---
driver:
name: podman
platforms:
- name: collectd-test
hostname: collectd-test
image: ubi8/ubi-init
registry:
url: registry.access.redhat.com
dockerfile: ../common/Dockerfile
pkg_extras: python*setuptools
volumes:
- /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
privileged: true
environment: &env
http_proxy: "{{ lookup('env', 'http_proxy') }}"
https_proxy: "{{ lookup('env', 'https_proxy') }}"
CONTAINER_BIN: podman
ulimits: &ulimit
- host
provisioner:
inventory:
hosts:
all:
hosts:
collectd-test:
ansible_python_interpreter: /usr/bin/python3
host_vars:
collectd-test:
collectd_conf_output_dir: "/etc/collectd.d/"
name: ansible
log: true
env:
ANSIBLE_STDOUT_CALLBACK: yaml
ANSIBLE_FILTER_PLUGINS: "${ANSIBLE_FILTER_PLUGINS:-\
/usr/share/ansible/plugins/filter}"
playbooks:
prepare: ../common/prepare.yml
verifier:
name: ansible
dependency:
name: galaxy
options:
role-file: molecule/common/requirements.yml
scenario:
test_sequence:
- destroy
- dependency
- create
- prepare
- converge
- check
- verify
- destroy

61
tripleo_ansible/roles/tripleo_collectd/molecule/enable_sensubility/verify.yml

@ -0,0 +1,61 @@
---
- import_playbook: ../common/verify.yml
- name: "Verify collectd exec plugin"
hosts: all
tasks:
- name: "Check that the exec plugin config file exists"
stat:
path: '/etc/collectd.d/exec.conf'
register: output
failed_when:
- not output.stat.exists
- name: "Get contents of exec file"
slurp:
path: /etc/collectd.d/exec.conf
register: exec_conf
failed_when:
- '"Exec \"collectd:collectd\" \"collectd-sensubility\"" not in exec_conf.content | b64decode'
- name: Check that the sensubility file exists
stat:
path: '/etc/collectd-sensubility.conf'
register: output
failed_when:
- not output.stat.exists
- name: "Get contents of the generated collectd-sensubility file"
slurp:
src: /etc/collectd-sensubility.conf
register: sensubility_conf
- name: "Show the contents of generated collectd-sensubility file"
debug:
msg: "{{ sensubility_conf.content | b64decode }}"
- name: "Check the contents of generated collectd-sensubility.conf file"
assert:
that:
- '"connection=amqp://sensu:sensu@localhost:5672//sensu" in sensubility_conf.content | b64decode'
- '"client_name=standalone.ctlplane.localdomain" in sensubility_conf.content | b64decode'
- '"client_address=10.0.0.42" in sensubility_conf.content | b64decode'
- '"keepalive_interval=20" in sensubility_conf.content | b64decode'
- '"tmp_base_dir=/var/tmp/collectd-sensubility-checks" in sensubility_conf.content | b64decode'
- '"shell_path=/usr/bin/sh" in sensubility_conf.content | b64decode'
- '"worker_count=2" in sensubility_conf.content | b64decode'
success_msg: "Expected content found in collectd-sensubility.conf"
- name: "Check that the sensubility sudoers file has been created"
stat:
path: /etc/sudoers.d/sensubility_collectd
register: sudoer_file
failed_when:
- not sudoer_file.stat.exists
- name: "Check that the sensubility sudoers file has been populated"
slurp:
src: /etc/sudoers.d/sensubility_collectd
register: sensubility_sudoers
failed_when:
- 'not "collectd ALL = NOPASSWD: ALL" in sensubility_sudoers.content | b64decode'

34
tripleo_ansible/roles/tripleo_collectd/molecule/enable_sqlalchemy/converge.yml

@ -0,0 +1,34 @@
---
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- name: Converge
hosts: all
tasks:
- name: "Set up expected THT vars"
set_fact:
tripleo_role_name: "SomeRole"
service_net_map:
some_role_metrics_qdr_network: "ctlplane"
ctlplane_ip: "10.0.0.42"
- name: "Include tripleo-collectd-ansible-role"
include_role:
name: '{{ playbook_dir }}/../../../tripleo_collectd'
tasks_from: configure_collectd
vars:
collectd_conf_output_dir: "/etc/collectd.d/"
tripleo_collectd_enable_sqlalchemy: true

59
tripleo_ansible/roles/tripleo_collectd/molecule/enable_sqlalchemy/molecule.yml

@ -0,0 +1,59 @@
---
driver:
name: podman
platforms:
- name: collectd-test
hostname: collectd-test
image: ubi8/ubi-init
registry:
url: registry.access.redhat.com
dockerfile: ../common/Dockerfile
pkg_extras: python*setuptools
volumes:
- /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
privileged: true
environment: &env
http_proxy: "{{ lookup('env', 'http_proxy') }}"
https_proxy: "{{ lookup('env', 'https_proxy') }}"
CONTAINER_BIN: podman
ulimits: &ulimit
- host
provisioner:
inventory:
hosts:
all:
hosts:
collectd-test:
ansible_python_interpreter: /usr/bin/python3
host_vars:
collectd-test:
collectd_conf_output_dir: "/etc/collectd.d/"
name: ansible
log: true
env:
ANSIBLE_STDOUT_CALLBACK: yaml
ANSIBLE_FILTER_PLUGINS: "${ANSIBLE_FILTER_PLUGINS:-\
/usr/share/ansible/plugins/filter}"
playbooks:
prepare: ../common/prepare.yml
verifier:
name: ansible
dependency:
name: galaxy
options:
role-file: molecule/common/requirements.yml
scenario:
test_sequence:
- destroy
- dependency
- create
- prepare
- converge
- check
- verify
- destroy

7
tripleo_ansible/roles/tripleo_collectd/molecule/enable_sqlalchemy/requirements.yml

@ -0,0 +1,7 @@
---
- src: git+https://github.com/infrawatch/functional-tests
name: functional_tests
- src: git+http://github.com/infrawatch/collectd-config-ansible-role
name: collectd_config
version: plugin/python

46
tripleo_ansible/roles/tripleo_collectd/molecule/enable_sqlalchemy/verify.yml

@ -0,0 +1,46 @@
---
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- import_playbook: ../common/verify.yml
- name: Verify
hosts: all
tasks:
- name: "Make sure python.conf exists"
stat:
path: "{{ collectd_conf_output_dir }}/python.conf"
register: python_conf
failed_when:
- not python_conf.stat.exists
- name: "Get contents of python.conf"
slurp:
path: "{{ collectd_conf_output_dir }}/python.conf"
register: python_conf
- name: "Check that the config imports sqlalchemy"
assert:
that:
- '"Import \"sqlalchemy_collectd.server.plugin\"" in python_conf.content | b64decode'
fail_msg: "SQLAlchemy is not imported by python config"
- name: "Check that collectd_sqlalchemy is configured as expected"
assert:
that:
- '"<Module \"sqlalchemy_collectd.server.plugin\">" in python_conf.content | b64decode'
- '"listen \"localhost\" 25827" in python_conf.content | b64decode'
- '"loglevel \"info\"" in python_conf.content | b64decode'

34
tripleo_ansible/roles/tripleo_collectd/molecule/enable_stf/converge.yml

@ -0,0 +1,34 @@
---
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- name: Converge
hosts: all
tasks:
- name: "Set up expected THT vars"
set_fact:
tripleo_role_name: "SomeRole"
service_net_map:
some_role_metrics_qdr_network: "ctlplane"
ctlplane_ip: "10.0.0.42"
- name: "Include tripleo-collectd-ansible-role"
include_role:
name: "{{ playbook_dir }}/../../../tripleo_collectd"
tasks_from: configure_collectd
vars:
collectd_conf_output_dir: "/etc/collectd.d/"
tripleo_collectd_enable_stf: true

59
tripleo_ansible/roles/tripleo_collectd/molecule/enable_stf/molecule.yml

@ -0,0 +1,59 @@
---
driver:
name: podman
platforms:
- name: collectd-test
hostname: collectd-test
image: ubi8/ubi-init
registry:
url: registry.access.redhat.com
dockerfile: ../common/Dockerfile
pkg_extras: python*setuptools
volumes:
- /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
privileged: true
environment: &env
http_proxy: "{{ lookup('env', 'http_proxy') }}"
https_proxy: "{{ lookup('env', 'https_proxy') }}"
CONTAINER_BIN: podman
ulimits: &ulimit
- host
provisioner:
inventory:
hosts:
all:
hosts:
collectd-test:
ansible_python_interpreter: /usr/bin/python3
host_vars:
collectd-test:
collectd_conf_output_dir: "/etc/collectd.d/"
name: ansible
log: true
env:
ANSIBLE_STDOUT_CALLBACK: yaml
ANSIBLE_FILTER_PLUGINS: "${ANSIBLE_FILTER_PLUGINS:-\
/usr/share/ansible/plugins/filter}"
playbooks:
prepare: ../common/prepare.yml
verifier:
name: ansible
dependency:
name: galaxy
options:
role-file: molecule/common/requirements.yml
scenario:
test_sequence:
- destroy
- dependency
- create
- prepare
- converge
- check
- verify
- destroy

36
tripleo_ansible/roles/tripleo_collectd/molecule/enable_stf/verify.yml

@ -0,0 +1,36 @@
---
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- import_playbook: ../common/verify.yml
- name: Verify
hosts: all
tasks:
- name: "Check that the right plugins are enabled"
stat:
path: "{{ collectd_conf_output_dir }}/{{ item }}.conf"
register: conf
failed_when:
- not conf.stat.exists
loop:
- cpu
- df
- load
- connectivity
- intel_rdt
- ipmi
- procevent

226
tripleo_ansible/roles/tripleo_collectd/tasks/configure_collectd.yml

@ -0,0 +1,226 @@
---
# Copyright 2021 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- name: "Create initial plugins list and other vars for collectd_config"
set_fact:
collectd_plugins: "{{ tripleo_collectd_default_plugins | union(tripleo_collectd_extra_plugins) | union(['logfile']) | unique }}"
collectd_interval: "{{ tripleo_collectd_default_polling_interval }}"
- name: "Enable read plugins for STF"
when: