99 lines
3.1 KiB
YAML
99 lines
3.1 KiB
YAML
---
|
|
# 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
|