1import os
2
3import testinfra.utils.ansible_runner
4
5testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
6    os.environ['MOLECULE_INVENTORY_FILE']
7).get_hosts('all')
8
9
10# EC2 provides unique random hostnames.
11def test_hostname(host):
12    pass
13
14
15def test_etc_molecule_directory(host):
16    f = host.file('/etc/molecule')
17
18    assert f.is_directory
19    assert f.user == 'root'
20    assert f.group == 'root'
21    assert f.mode == 0o755
22
23
24def test_etc_molecule_ansible_hostname_file(host):
25    filename = '/etc/molecule/{}'.format(host.check_output('hostname -s'))
26    f = host.file(filename)
27
28    assert f.is_file
29    assert f.user == 'root'
30    assert f.group == 'root'
31    assert f.mode == 0o644
32