openstack-ansible-rsyslog_c.../tests/test.yml

87 lines
3.1 KiB
YAML

---
# Copyright 2015, Rackspace US, Inc.
#
# 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: Playbook for role testing
hosts: localhost
connection: local
roles:
- role: "{{ rolename | basename }}"
rsyslog_client_log_rotate_file: test_log_rotate
rsyslog_client_log_dir: "/var/log"
rsyslog_client_config_name: "99-test-rsyslog-client.conf"
rsyslog_client_log_files:
- /var/log/dmesg
- /var/log/udev
rsyslog_client_user_defined_targets:
- name: "test-splunk1"
proto: "tcp"
port: "20000"
hostname: "tcp.hostname.test.example.com"
- name: "test-loggly1"
proto: "udp"
port: "514"
hostname: "logs-01.test.example.com"
template: '$template LogglyFormat,"TESTING\n"'
action_options: 'LogglyFormat'
rsyslog_client_log_rotate_options:
- copytruncate
- weekly
- missingok
- rotate 14
- compress
- dateext
- maxage 60
- notifempty
- nocreate
- size 1G
post_tasks:
- name: Open rsyslog client file
slurp:
src: /etc/rsyslog.d/99-test-rsyslog-client.conf
register: rsyslog_test_client_file
- name: Open log rotate file
slurp:
src: /etc/logrotate.d/test_log_rotate
register: logrotate_client_file
- name: Read files
set_fact:
rsyslog_client_content: "{{ rsyslog_test_client_file.content | b64decode }}"
logrotate_client_content: "{{ logrotate_client_file.content | b64decode }}"
- name: Check rsyslog defaults file
stat:
path: /etc/rsyslog.d/50-default.conf
register: rsyslog_default_file
- name: Check rsyslog client file
stat:
path: /etc/rsyslog.d/99-test-rsyslog-client.conf
register: rsyslog_client_file
- name: Check logrotate file
stat:
path: /etc/logrotate.d/test_log_rotate
register: logrotate_file
- name: Check role functions
assert:
that:
- "'$ActionQueueFileName test1' in rsyslog_client_content"
- "'$ActionQueueFileName test2' in rsyslog_client_content"
- "'$ActionQueueFileName test-splunk1' in rsyslog_client_content"
- "'$ActionQueueFileName test-loggly1' in rsyslog_client_content"
- "'/var/log/dmesg' in logrotate_client_content"
- "'/var/log/udev' in logrotate_client_content"
- "'size 1G' in logrotate_client_content"
- "rsyslog_default_file.stat.exists"
- "rsyslog_client_file.stat.exists"
- "logrotate_file.stat.exists"