|
|
import os
|
|
|
import pwd
|
|
|
|
|
|
import testinfra.utils.ansible_runner
|
|
|
|
|
@@ -19,7 +20,8 @@ def test_preseed_directory(host):
|
|
|
# uglier. It might be actually better to make the
|
|
|
# preseed_directory a mandatory parameter instead. Same
|
|
|
# goes for the ansible_key role parameter as well.
|
|
|
preseed_directory = host.file(os.path.join('/tmp/molecule/preseed/default/inventory', 'preseed_files'))
|
|
|
preseed_directory_path = "%s/.cache/molecule/preseed/default/inventory/preseed_files" % pwd.getpwuid(os.getuid()).pw_dir
|
|
|
preseed_directory = host.file(preseed_directory_path)
|
|
|
|
|
|
assert preseed_directory.is_directory
|
|
|
assert preseed_directory.mode == 0o750
|
|
@@ -33,7 +35,7 @@ def test_preseed_configuration_files(host):
|
|
|
with host.sudo():
|
|
|
|
|
|
# Preseed directory created at same level as inventory.
|
|
|
preseed_directory_path = os.path.join('/tmp/molecule/preseed/default/inventory', 'preseed_files')
|
|
|
preseed_directory_path = "%s/.cache/molecule/preseed/default/inventory/preseed_files" % pwd.getpwuid(os.getuid()).pw_dir
|
|
|
|
|
|
# Verify that preseed configuration files are created for all hosts.
|
|
|
for testinfra_host in testinfra_hosts:
|
|
@@ -52,7 +54,8 @@ def test_preseed_configuration_file_content(host):
|
|
|
hostname = host.run('hostname').stdout.strip()
|
|
|
|
|
|
with host.sudo():
|
|
|
preseed_file = host.file(os.path.join("/tmp/molecule/preseed/default/inventory", "preseed_files", "%s.cfg" % hostname))
|
|
|
preseed_directory_path = "%s/.cache/molecule/preseed/default/inventory/preseed_files" % pwd.getpwuid(os.getuid()).pw_dir
|
|
|
preseed_file = host.file(os.path.join(preseed_directory_path, "%s.cfg" % hostname))
|
|
|
preseed_file_content = preseed_file.content_string
|
|
|
ssh_public_key = open(os.path.join(os.path.expanduser("~"), ".ssh", "id_rsa.pub")).read().strip()
|
|
|
|