0

我正在使用 Molecule 来测试 Ansible 角色。我已经在 python 中编写了单元测试,并且无法打印出变量或将任何内容记录到标准输出。这是我的代码

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
4

1 回答 1

3

在分子.yml 中启用stestinfra 的标志:

---
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
于 2018-11-20T11:23:03.913 回答