testinfra

Using Ansible variables in testinfra

泪湿孤枕 提交于 2020-01-03 17:16:57
问题 Using TestInfra with Ansible backend for testing purposes. Everything goes fine except using Ansible itself while running tests test.py import pytest def test_zabbix_agent_package(host): package = host.package("zabbix-agent") assert package.is_installed package_version = host.ansible("debug", "msg={{ zabbix_agent_version }}")["msg"] (...) where zabbix_agent_version is an Ansible variable from group_vars. It can be obtained by running this playbook - hosts: all become: true tasks: - name:

Using Ansible variables in testinfra

梦想的初衷 提交于 2019-12-01 21:04:11
Using TestInfra with Ansible backend for testing purposes. Everything goes fine except using Ansible itself while running tests test.py import pytest def test_zabbix_agent_package(host): package = host.package("zabbix-agent") assert package.is_installed package_version = host.ansible("debug", "msg={{ zabbix_agent_version }}")["msg"] (...) where zabbix_agent_version is an Ansible variable from group_vars. It can be obtained by running this playbook - hosts: all become: true tasks: - name: debug debug: msg={{ zabbix_agent_version }} command executing tests pytest --connection=ansible --ansible