import testinfra.utils.ansible_runner testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( '.molecule/ansible_inventory').get_hosts('client1') def test_connectivity(Command, Sudo): """ Tests connectivity to the web server (ports that should be reachable). """ with Sudo(): for server in ["parameters-mandatory", "parameters-optional"]: # HTTP, HTTPS. for port in [80, 443]: ping = Command('hping3 -S -p %d -c 1 %s' % (port, server)) assert ping.rc == 0