ansible-role-borgbackup/molecule/default/tests/test_default.py
Manu 5c883a734b
Add testing with Molecule/Ansible-lint, undo #9 (#26)
* Add testing with Molecule/Ansible-lint and fix linting errors
* Undo PR #9 for now (sorry)
2020-02-18 00:21:21 +08:00

34 lines
827 B
Python

"""
Validate host properties using Pytest after Ansible is finished. Uses Testinfra
Possible tests:
- https://testinfra.readthedocs.io/en/latest/modules.html#host
"""
import os
# import pytest
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']
).get_hosts('all')
def test_borgmatic_config(host):
f = host.file('/etc/borgmatic/config.yaml')
assert f.exists
assert f.user == 'root'
assert f.group == 'root'
# @pytest.mark.parametrize('file, content', [
# ("/etc/firewalld/zones/public.xml", "<service name=\"http\"/>"),
# ("/var/www/html/index.html", "Managed by Ansible")
# ])
# def test_files(host, file, content):
# file = host.file(file)
# assert file.exists
# assert file.contains(content)