test: replace kitchen to molecule
This commit is contained in:
parent
a108dfbb55
commit
1afd1fcf6c
12 changed files with 78 additions and 202 deletions
molecule/default
20
molecule/default/converge.yml
Normal file
20
molecule/default/converge.yml
Normal file
|
@ -0,0 +1,20 @@
|
|||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
roles:
|
||||
- ansible-role-filebeat
|
||||
vars:
|
||||
filebeat_config:
|
||||
filebeat.inputs:
|
||||
- type: log
|
||||
paths:
|
||||
- /var/log/messages
|
||||
- /var/log/*.log
|
||||
output.file:
|
||||
path: "/tmp/filebeat"
|
||||
filename: filebeat
|
||||
|
||||
pre_tasks:
|
||||
- name: update apt cache
|
||||
ansible.builtin.apt:
|
||||
update_cache: true
|
26
molecule/default/molecule.yml
Normal file
26
molecule/default/molecule.yml
Normal file
|
@ -0,0 +1,26 @@
|
|||
---
|
||||
driver:
|
||||
name: docker
|
||||
platforms:
|
||||
- name: debian10
|
||||
image: nishiki/debian10:molecule
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
command: /bin/systemd
|
||||
capabilities:
|
||||
- SYS_ADMIN
|
||||
- name: debian11
|
||||
image: nishiki/debian11:molecule
|
||||
privileged: true
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||
command: /bin/systemd
|
||||
capabilities:
|
||||
- SYS_ADMIN
|
||||
lint: |
|
||||
set -e
|
||||
yamllint .
|
||||
ansible-lint .
|
||||
verifier:
|
||||
name: testinfra
|
26
molecule/default/tests/test_default.py
Normal file
26
molecule/default/tests/test_default.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
import testinfra.utils.ansible_runner
|
||||
import time
|
||||
|
||||
def test_packages(host):
|
||||
package = host.package('filebeat')
|
||||
assert package.is_installed
|
||||
|
||||
def test_config_file(host):
|
||||
path = host.file('/etc/filebeat/filebeat.yml')
|
||||
assert path.exists
|
||||
assert path.is_file
|
||||
assert path.user == 'root'
|
||||
assert path.group == 'root'
|
||||
assert path.mode == 0o644
|
||||
|
||||
def test_service(host):
|
||||
service = host.service('filebeat')
|
||||
assert service.is_running
|
||||
assert service.is_enabled
|
||||
|
||||
def test_output(host):
|
||||
time.sleep(15)
|
||||
path = host.file('/tmp/filebeat/filebeat')
|
||||
assert path.exists
|
||||
assert path.is_file
|
||||
assert path.contains('@timestamp')
|
Loading…
Add table
Add a link
Reference in a new issue