如何登录分子?

时间:2018-10-18 17:57:53

标签: python ansible molecule

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

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

1 个答案:

答案 0 :(得分:0)

molecule.yml 内为testinfra启用s标志:

---
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