I am using Molecule to test an Ansible role. I've written unit tests in python, and have been unable to print out variables or log anything to stdout. Here is my code
import os
import testinfra.utils.ansible_runner
import logging
LOG = logging.getLogger("toto")
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
def test_something(host):
print 'Hello World!'
LOG.warn('Hello World!')
assert True
Enable the s
flag for testinfra inside molecule.yml:
---
dependency:
name: galaxy
driver:
name: docker
lint:
name: yamllint
platforms:
- name: instance
image: centos:7
provisioner:
name: ansible
lint:
name: ansible-lint
scenario:
name: default
verifier:
name: testinfra
lint:
name: flake8
options:
s: true