Skip to content

Instantly share code, notes, and snippets.

@vittorio-nardone
Created February 11, 2020 12:11
Show Gist options
  • Save vittorio-nardone/433d4aceab727dc387f84e7cdd3e7eb4 to your computer and use it in GitHub Desktop.
Save vittorio-nardone/433d4aceab727dc387f84e7cdd3e7eb4 to your computer and use it in GitHub Desktop.
Molecule test for service Apache2
import os
import pytest
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']
).get_hosts('all')
@pytest.mark.parametrize('pkg', [
'apache2'
])
def test_pkg(host, pkg):
package = host.package(pkg)
assert package.is_installed
@pytest.mark.parametrize('svc', [
'apache2'
])
def test_svc(host, svc):
service = host.service(svc)
assert service.is_running
assert service.is_enabled
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment