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_csr_on_server(): # given config = CsrAttributesConfiguration() config.read_raw_options(dict(pp_role='appserver')) configurer = CsrAttributesConfigurer(config, Mode.Server) container.initialize() # when commands = configurer.produce_commands() # then assert ' pp_role: appserver' in commands assert ' group => \'puppet\',' in commands
def test_csr_on_agent(): # given config = CsrAttributesConfiguration() config.read_raw_options(dict(pp_role='agent')) configurer = CsrAttributesConfigurer(config, Mode.Agent) container.initialize() # when commands = configurer.produce_commands() # then assert ' pp_role: agent' in commands
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 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_class(cls): container.initialize()
def setup_function(): MockFacter.set_fact(OperatingSystemCodename, OperatingSystemCodename('precise')) container.initialize()
def main(argv=sys.argv): """Entry point for the puppeter application""" container.initialize() parser = CommandLineParser(argv) app = parser.parse() app.run()