Skip to content

Commit

Permalink
Switch tests to use Molecule and bump to Kibana 6.x.
Browse files Browse the repository at this point in the history
  • Loading branch information
geerlingguy committed Sep 28, 2018
1 parent e3f7a8b commit 5710f59
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 32 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
files/logstash-forwarder*
*.retry
tests/test.sh
*/__pycache__
*.pyc
27 changes: 19 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
---
language: python
services: docker

env:
- distro: centos7
- distro: ubuntu1604
- distro: ubuntu1404
global:
- ROLE_NAME: logstash
matrix:
- MOLECULE_DISTRO: centos7
MOLECULE_DOCKER_COMMAND: /usr/lib/systemd/systemd
- MOLECULE_DISTRO: ubuntu1604
- MOLECULE_DISTRO: ubuntu1404

script:
# Download test shim.
- wget -O ${PWD}/tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/
- chmod +x ${PWD}/tests/test.sh
install:
# Install test dependencies.
- pip install molecule docker

before_script:
# Use actual Ansible Galaxy role name for the project directory.
- cd ../
- mv ansible-role-$ROLE_NAME geerlingguy.$ROLE_NAME
- cd geerlingguy.$ROLE_NAME

script:
# Run tests.
- ${PWD}/tests/test.sh
- molecule test

notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ Note that filebeat and logstash may not work correctly with self-signed certific

Whether configuration for local syslog file (defined as `logstash_local_syslog_path`) should be added to logstash. Set this to `false` if you are monitoring the local syslog differently, or if you don't care about the local syslog file. Other local logs can be added by your own configuration files placed inside `/etc/logstash/conf.d`.

logstash_enabled_on_boot: yes
logstash_enabled_on_boot: true

Set this to `no` if you don't want logstash to run on system startup.
Set this to `false` if you don't want logstash to run on system startup.

logstash_install_plugins:
- logstash-input-beats
Expand Down
2 changes: 1 addition & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ logstash_ssl_dir: /etc/pki/logstash
logstash_ssl_certificate_file: ""
logstash_ssl_key_file: ""

logstash_enabled_on_boot: yes
logstash_enabled_on_boot: true

logstash_install_plugins:
- logstash-input-beats
12 changes: 8 additions & 4 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@ galaxy_info:
platforms:
- name: EL
versions:
- 6
- 7
- 6
- 7
- name: Debian
versions:
- all
- all
- name: Ubuntu
versions:
- all
- all
galaxy_tags:
- web
- system
- monitoring
- logging
- logs
- elk
- logstash
27 changes: 27 additions & 0 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
dependency:
name: galaxy
driver:
name: docker
lint:
name: yamllint
options:
config-file: molecule/default/yaml-lint.yml
platforms:
- name: instance
image: geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible
command: ${MOLECULE_DOCKER_COMMAND:-"sleep infinity"}
privileged: true
pre_build_image: true
provisioner:
name: ansible
lint:
name: ansible-lint
playbooks:
converge: ${MOLECULE_PLAYBOOK:-playbook.yml}
scenario:
name: default
verifier:
name: testinfra
lint:
name: flake8
10 changes: 6 additions & 4 deletions tests/test.yml → molecule/default/playbook.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
---
- hosts: all
- name: Converge
hosts: all
become: true

vars:
logstash_enabled_on_boot: no
logstash_enabled_on_boot: false

pre_tasks:
- name: Update apt cache.
apt: update_cache=yes cache_valid_time=600
apt: update_cache=true cache_valid_time=600
when: ansible_os_family == 'Debian'

roles:
- geerlingguy.java
- geerlingguy.elasticsearch
- role_under_test
- geerlingguy.logstash
File renamed without changes.
14 changes: 14 additions & 0 deletions molecule/default/tests/test_default.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import os

import testinfra.utils.ansible_runner

testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')


def test_hosts_file(host):
f = host.file('/etc/hosts')

assert f.exists
assert f.user == 'root'
assert f.group == 'root'
6 changes: 6 additions & 0 deletions molecule/default/yaml-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
extends: default
rules:
line-length:
max: 120
level: warning
11 changes: 0 additions & 11 deletions tests/README.md

This file was deleted.

0 comments on commit 5710f59

Please sign in to comment.