def test_osrelease_major_oninvalid(self): MockFacter.set_fact(OperatingSystemRelease, OperatingSystemRelease('alpha')) rel = Facter.get(OperatingSystemRelease) major = rel.major() assert major is not None assert major is 'alpha'
def test_fqdn_on_docker(): # given gateway = FqdnSetterGatewayImpl() config = FqdnConfiguration(fqdn='appserver.acme.internal') MockFacter.set_fact(Docker, Docker.YES) container.initialize() # when with pytest.raises(NotImplementedError) as excinfo: gateway.process_fully_qualified_domain_name(config) # then assert "Can't set FQDN when running inside Docker!" in str(excinfo.value)
def setup_function(): container.initialize() MockFacter.set_fact(OperatingSystemRelease, OperatingSystemRelease('14.04')) MockFacter.set_fact(OperatingSystemCodename, OperatingSystemCodename('trusty')) MockFacter.set_fact(OperatingSystem, OperatingSystem.Ubuntu) MockFacter.set_fact(OsFamily, OsFamily.Debian)
def test_system_redhat(): # given MockFacter.set_fact(OperatingSystem, OperatingSystem.RedHat) MockFacter.set_fact(OperatingSystemRelease, OperatingSystemRelease('7.3.11')) installer = SystemInstaller() installer.read_raw_options({'mode': 'Server'}) configurer = RedHatSystemConfigurer(installer=installer) # when commands = configurer.produce_commands() commands = list(map(lambda cmd: cmd.strip(), commands)) # then assert 'yum install -y wget' not in commands assert "rpm -Uvh 'https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm'" in commands assert 'yum install -y puppet' in commands assert 'puppet resource package puppetmaster ensure=installed' in commands
def test_pc4x_oraclelinux5(): # given MockFacter.set_fact(OperatingSystem, OperatingSystem.OracleLinux) MockFacter.set_fact(OperatingSystemRelease, OperatingSystemRelease('5.11')) installer = Collection4xInstaller() installer.read_raw_options({'mode': 'Server'}) configurer = RedHatPC4xConfigurer(installer=installer) # when commands = configurer.produce_commands() commands = list(map(lambda cmd: cmd.strip(), commands)) # then assert 'yum install -y wget' in commands assert "wget 'https://yum.puppetlabs.com/puppetlabs-release-pc1-el-5.noarch.rpm'" in commands assert 'yum install -y puppet-agent' in commands assert 'puppet resource package puppetserver ensure=installed' in commands
def test_pc3x_fedora_25(): # given MockFacter.set_fact(OperatingSystem, OperatingSystem.Fedora) MockFacter.set_fact(OperatingSystemRelease, OperatingSystemRelease('25.1')) installer = Collection3xInstaller() installer.read_raw_options({'mode': 'Agent'}) configurer = RedHatPC3xConfigurer(installer=installer) # when commands = configurer.produce_commands() commands = list(map(lambda cmd: cmd.strip(), commands)) # then assert 'yum install -y wget' not in commands assert "rpm -Uvh 'https://yum.puppetlabs.com/puppetlabs-release-fedora-25.noarch.rpm'" in commands assert 'yum install -y puppet' in commands assert 'puppet resource package puppetmaster ensure=installed' not in commands
def test_pc5x(): # given MockFacter.set_fact(OperatingSystem, OperatingSystem.RedHat) MockFacter.set_fact(OperatingSystemRelease, OperatingSystemRelease('7.3.11')) installer = Collection5xInstaller() installer.read_raw_options({'mode': 'Server'}) configurer = RedHatPC5xConfigurer(installer=installer) # when commands = configurer.produce_commands() commands = list(map(lambda cmd: cmd.strip(), commands)) # then assert 'yum install -y wget' not in commands assert "rpm -Uvh 'https://yum.puppetlabs.com/puppet5/puppet5-release-el-7.noarch.rpm'" in commands assert 'yum install -y puppet-agent' in commands assert 'puppet resource package puppetserver ensure=installed' in commands
def test_fqdn_on_debian(): # given gateway = FqdnSetterGatewayImpl() config = FqdnConfiguration(fqdn='appserver.acme.internal') MockFacter.set_fact(Docker, Docker.NO) MockFacter.set_fact(OsFamily, OsFamily.Debian) container.initialize() # when configurers = gateway.process_fully_qualified_domain_name(config) # then assert len(configurers) == 1 # when configurer = configurers[0] commands = configurer.produce_commands() # then assert u" puppet resource host 'appserver.acme.internal' " \ "ensure=present host_aliases='appserver' ip=127.0.0.1 " \ "comment='FQDN'" in commands assert " hostname 'appserver'" in commands assert u" content => 'appserver'" in commands
def setup_function(): MockFacter.set_fact(OsFamily, OsFamily.RedHat) container.initialize()
def setup_function(): MockFacter.set_fact(OperatingSystemCodename, OperatingSystemCodename('precise')) container.initialize()