Files
@ da27c590e954
Branch filter:
Location: majic-ansible-roles/roles/preseed/tests/test_parameters_optional_with_overrides.py - annotation
da27c590e954
2.2 KiB
text/x-python
MAR-30: Implemented tests for role 'preseed':
- Added global flake8 configuration to allow up to 160 characters per line (for
Python linting checks).
- Updated gitignore file to ignore Molecule artefacts.
- Role is tested against 64-bit Debian Jessie and 64-bit Debian Stretch.
- Tests cover variations on optional parameter inclusion, as well as generated
preseed files.
- Added global flake8 configuration to allow up to 160 characters per line (for
Python linting checks).
- Updated gitignore file to ignore Molecule artefacts.
- Role is tested against 64-bit Debian Jessie and 64-bit Debian Stretch.
- Tests cover variations on optional parameter inclusion, as well as generated
preseed files.
da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 da27c590e954 | import os
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
'.molecule/ansible_inventory').get_hosts('parameters-optional-with-overrides')
PRESEED_DIRECTORY = '/tmp/custom_preseed_files_location'
def test_preseed_directory(File, Sudo, Ansible):
"""
Test presence and permissions of preseed directory.
"""
with Sudo():
preseed_directory = File(PRESEED_DIRECTORY)
assert preseed_directory.is_directory
assert preseed_directory.mode == 0o750
def test_preseed_configuration_file_content(File, Sudo, TestinfraBackend):
"""
Tests content of generated preseed configuration file.
"""
with Sudo():
preseed_file = File(os.path.join(PRESEED_DIRECTORY, "%s.cfg" % TestinfraBackend.get_hostname()))
preseed_file_content = preseed_file.content_string
ssh_public_key = "CUSTOMKEY"
assert "d-i debian-installer/language string sr" in preseed_file_content
assert "d-i debian-installer/country string RS" in preseed_file_content
assert "d-i debian-installer/locale string en_UK.UTF-8" in preseed_file_content
assert "d-i keyboard-configuration/xkb-keymap select sv" in preseed_file_content
assert "d-i netcfg/choose_interface select eth1" in preseed_file_content
assert """# Manual network configuration.
d-i netcfg/disable_autoconfig boolean true
d-i netcfg/get_ipaddress string 3.3.3.3
d-i netcfg/get_netmask string 255.255.0.0
d-i netcfg/get_gateway string 2.2.2.2
d-i netcfg/get_nameservers string 1.1.1.1
d-i netcfg/confirm_static boolean true
# Hostname and domain configuration.
d-i netcfg/get_hostname string testing
d-i netcfg/get_domain string example.com""" in preseed_file_content
assert "d-i mirror/http/hostname string ftp.de.debian.org" in preseed_file_content
assert "d-i mirror/http/directory string /" in preseed_file_content
assert "d-i mirror/http/proxy string http://proxy.local" in preseed_file_content
assert "d-i passwd/root-password password myrootpassword" in preseed_file_content
assert "d-i passwd/root-password-again password myrootpassword" in preseed_file_content
assert "d-i time/zone string Europe/Belgrade" in preseed_file_content
assert ssh_public_key in preseed_file_content
|