From 4bea9beec872304f0ec7e974368e2deb4207daf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Suszy=C5=84ski=20Krzysztof?= Date: Thu, 13 Jul 2017 17:50:10 +0200 Subject: [PATCH] Installation of puppet using PC repositories on Debian --- MANIFEST.in | 2 +- .../installer/pc/debian/puppetserver.sh | 9 --- data/templates/installer/pc4x/debian/repo.sh | 13 ---- puppeter/domain/gateway/answers.py | 4 ++ puppeter/domain/model/configurer.py | 72 ++++++++++++++++++- puppeter/domain/model/installer.py | 3 +- .../gateway/installer/debian/__init__.py | 12 ++-- .../gateway/installer/debian/after4x.py | 16 +++++ .../gateway/installer/debian/apt-update.sh | 10 +++ .../gateway/installer/debian/base.py | 41 +++++++++++ .../gateway/installer/debian/pc3x-repo.sh | 11 +++ .../gateway/installer/debian/pc3x.py | 23 ++++-- .../gateway/installer/debian/pc4x-repo.sh | 11 +++ .../gateway/installer/debian/pc4x.py | 17 +++-- .../gateway/installer/debian/pc5x-repo.sh | 11 +++ .../gateway/installer/debian/pc5x.py | 18 +++-- .../gateway/installer/debian/puppet3xagent.sh | 6 ++ .../gateway/installer}/debian/puppetagent.sh | 4 +- .../gateway/installer/debian/puppetmaster.sh | 2 + .../gateway/installer/debian/puppetserver.sh | 2 + .../gateway/installer/debian/wget.sh | 6 ++ .../gateway/installer/redhat/pc4x-repo.sh | 0 .../gateway/installer}/redhat/puppetagent.sh | 0 .../gateway/installer}/redhat/puppetserver.sh | 0 puppeter/presentation/app.py | 2 +- setup.py | 2 +- tests/domain/test_facter.py | 10 +-- .../persistence/gateway/installer/__init__.py | 0 .../gateway/installer/debian/__init__.py | 0 .../gateway/installer/debian/test_pc3x.py | 16 +++++ 30 files changed, 266 insertions(+), 57 deletions(-) delete mode 100644 data/templates/installer/pc/debian/puppetserver.sh delete mode 100644 data/templates/installer/pc4x/debian/repo.sh create mode 100644 puppeter/persistence/gateway/installer/debian/after4x.py create mode 100644 puppeter/persistence/gateway/installer/debian/apt-update.sh create mode 100644 puppeter/persistence/gateway/installer/debian/base.py create mode 100644 puppeter/persistence/gateway/installer/debian/pc3x-repo.sh create mode 100644 puppeter/persistence/gateway/installer/debian/pc4x-repo.sh create mode 100644 puppeter/persistence/gateway/installer/debian/pc5x-repo.sh create mode 100644 puppeter/persistence/gateway/installer/debian/puppet3xagent.sh rename {data/templates/installer/pc => puppeter/persistence/gateway/installer}/debian/puppetagent.sh (86%) create mode 100644 puppeter/persistence/gateway/installer/debian/puppetmaster.sh create mode 100644 puppeter/persistence/gateway/installer/debian/puppetserver.sh create mode 100644 puppeter/persistence/gateway/installer/debian/wget.sh rename data/templates/installer/pc4x/redhat/repo.sh => puppeter/persistence/gateway/installer/redhat/pc4x-repo.sh (100%) rename {data/templates/installer/pc => puppeter/persistence/gateway/installer}/redhat/puppetagent.sh (100%) rename {data/templates/installer/pc => puppeter/persistence/gateway/installer}/redhat/puppetserver.sh (100%) create mode 100644 tests/persistence/gateway/installer/__init__.py create mode 100644 tests/persistence/gateway/installer/debian/__init__.py create mode 100644 tests/persistence/gateway/installer/debian/test_pc3x.py diff --git a/MANIFEST.in b/MANIFEST.in index 94e4d73..8520d05 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -3,4 +3,4 @@ include LICENSE # Include the data files recursive-include puppeter *.py -recursive-include data *.sh +recursive-include puppeter *.sh diff --git a/data/templates/installer/pc/debian/puppetserver.sh b/data/templates/installer/pc/debian/puppetserver.sh deleted file mode 100644 index c635c1f..0000000 --- a/data/templates/installer/pc/debian/puppetserver.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -set -x -set +e - -if ! dpkg -l 'puppetserver' | grep -q ii; then - set -e - sudo apt-get install -y puppetserver -fi diff --git a/data/templates/installer/pc4x/debian/repo.sh b/data/templates/installer/pc4x/debian/repo.sh deleted file mode 100644 index 982c846..0000000 --- a/data/templates/installer/pc4x/debian/repo.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -set -x -set +e - -if ! dpkg -l 'puppetlabs-release-pc1' | grep -q ii; then - set -e - cd /tmp - wget "https://apt.puppetlabs.com/puppetlabs-release-pc1-@{codename}.deb" - sudo dpkg -i "puppetlabs-release-pc1-@{codename}.deb" - rm "puppetlabs-release-pc1-@{codename}.deb" - sudo apt-get update -fi diff --git a/puppeter/domain/gateway/answers.py b/puppeter/domain/gateway/answers.py index bad4d59..f9f8a8d 100644 --- a/puppeter/domain/gateway/answers.py +++ b/puppeter/domain/gateway/answers.py @@ -1,12 +1,16 @@ from six import with_metaclass from abc import ABCMeta, abstractmethod +from puppeter.domain.model.answers import Answers # NOQA + class AnswersGateway(with_metaclass(ABCMeta, object)): @abstractmethod def read_answers_from_file(self, file): + # type: (file) -> Answers pass @abstractmethod def write_answers_to_file(self, answers, file): + # type: (Answers, file) -> None pass diff --git a/puppeter/domain/model/configurer.py b/puppeter/domain/model/configurer.py index 47592a3..5c34ce7 100644 --- a/puppeter/domain/model/configurer.py +++ b/puppeter/domain/model/configurer.py @@ -1,5 +1,10 @@ from abc import ABCMeta, abstractmethod -from six import with_metaclass +from collections import OrderedDict +from string import Template + +import pkg_resources +import re +from six import with_metaclass, iteritems class Configurer(with_metaclass(ABCMeta, object)): @@ -7,3 +12,68 @@ class Configurer(with_metaclass(ABCMeta, object)): def produce_commands(self): # type: () -> [str] raise NotImplementedError() + + def _collector(self): + # type: () -> self.CommandsCollector + return self.CommandsCollector(self) + + class BashTemplate(Template): + delimiter = '@' + flags = re.MULTILINE + + class CommandsCollector: + + SHEBANG_REGEX = re.compile('^#!(.*)\n', re.MULTILINE) + + def __init__(self, configurer): + self.__parts = OrderedDict() + self.__configurer = configurer # type: Configurer + + def collect_from_template(self, description, template, mapping): + # type: (str, str, dict) -> Configurer.CommandsCollector + script = self.__template(template) \ + .substitute(mapping) + self.__parts[description] = script + return self + + def collect_from_file(self, description, path): + # type: (str, str) -> Configurer.CommandsCollector + script = self.__resource_string(path) + self.__parts[description] = script + return self + + def lines(self): + # type: () -> str + lines = ['#!/usr/bin/env bash -ex', ''] + i = 1 + for (description, script) in iteritems(self.__parts): + lines.append('# Part %d: %s' % (i, description)) + lines += self.__strip_shebang(script).split("\n") + i += 1 + return lines + + def __template(self, path): + # type: (str) -> Configurer.BashTemplate + return Configurer.BashTemplate(self.__resource_string(path)) + + def __resource_string(self, path): + # noinspection PyTypeChecker + return self.__load_resource(pkg_resources.resource_string, self.__configurer, path)\ + .decode("utf-8") + + @staticmethod + def __load_resource(loader, obj, path): + mod = Configurer.CommandsCollector.__moduleof(obj) + return loader(mod, path) + + @staticmethod + def __moduleof(cls): + try: + cls = cls.original_cls() + except AttributeError: + cls = cls.__class__ + return cls.__module__ + + @staticmethod + def __strip_shebang(script): + return re.sub(Configurer.CommandsCollector.SHEBANG_REGEX, "", script) diff --git a/puppeter/domain/model/installer.py b/puppeter/domain/model/installer.py index 8ed86f5..24fde52 100644 --- a/puppeter/domain/model/installer.py +++ b/puppeter/domain/model/installer.py @@ -10,7 +10,7 @@ class Mode(Enum): class Installer: def __init__(self): - self.__mode = Mode.Agent + self.__mode = Mode.Agent # type: Mode def raw_options(self): # noinspection PyUnresolvedReferences @@ -27,6 +27,7 @@ def read_raw_options(self, options): pass def mode(self): + # type: () -> Mode return self.__mode diff --git a/puppeter/persistence/gateway/installer/debian/__init__.py b/puppeter/persistence/gateway/installer/debian/__init__.py index 19e49d6..94b574d 100644 --- a/puppeter/persistence/gateway/installer/debian/__init__.py +++ b/puppeter/persistence/gateway/installer/debian/__init__.py @@ -2,9 +2,9 @@ from puppeter.container import Named from puppeter.domain.model.configurer import Configurer from puppeter.domain.gateway.installer import InstallerGateway -from puppeter.persistence.gateway.installer.debian.pc3x import PC3xConfigurer -from puppeter.persistence.gateway.installer.debian.pc4x import PC4xConfigurer -from puppeter.persistence.gateway.installer.debian.pc5x import PC5xConfigurer +from puppeter.persistence.gateway.installer.debian.pc3x import DebianPC3xConfigurer +from puppeter.persistence.gateway.installer.debian.pc4x import DebianPC4xConfigurer +from puppeter.persistence.gateway.installer.debian.pc5x import DebianPC5xConfigurer @Named('debian') @@ -19,6 +19,6 @@ def _provide_configurer(self, installer): container.bind(InstallerGateway, DebianInstallerGateway) -container.bind(Configurer, PC3xConfigurer) -container.bind(Configurer, PC4xConfigurer) -container.bind(Configurer, PC5xConfigurer) +container.bind(Configurer, DebianPC3xConfigurer) +container.bind(Configurer, DebianPC4xConfigurer) +container.bind(Configurer, DebianPC5xConfigurer) diff --git a/puppeter/persistence/gateway/installer/debian/after4x.py b/puppeter/persistence/gateway/installer/debian/after4x.py new file mode 100644 index 0000000..cbdfb57 --- /dev/null +++ b/puppeter/persistence/gateway/installer/debian/after4x.py @@ -0,0 +1,16 @@ +from abc import ABCMeta + +from six import with_metaclass + +from puppeter.persistence.gateway.installer.debian.base import BaseDebianConfigurer + + +class AfterPuppet4xConfigurer(with_metaclass(ABCMeta, BaseDebianConfigurer)): + def __init__(self, installer): + super(AfterPuppet4xConfigurer, self).__init__(installer) + + def _collect_agent(self, collector): + collector.collect_from_file('Puppet Agent setup', 'puppetagent.sh') + + def _collect_server(self, collector): + collector.collect_from_file('Puppet Server setup', 'puppetserver.sh') diff --git a/puppeter/persistence/gateway/installer/debian/apt-update.sh b/puppeter/persistence/gateway/installer/debian/apt-update.sh new file mode 100644 index 0000000..5c4d78a --- /dev/null +++ b/puppeter/persistence/gateway/installer/debian/apt-update.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +function getLastAptGetUpdate() { + local aptDate="$(stat -c %Y '/var/cache/apt')" + local nowDate="$(date +'%s')" + + echo $((nowDate - aptDate)) +} +if [[ "$(getLastAptGetUpdate)" -gt '@{interval}' ]]; then + apt-get update -m +fi diff --git a/puppeter/persistence/gateway/installer/debian/base.py b/puppeter/persistence/gateway/installer/debian/base.py new file mode 100644 index 0000000..f305c5d --- /dev/null +++ b/puppeter/persistence/gateway/installer/debian/base.py @@ -0,0 +1,41 @@ +from abc import ABCMeta, abstractmethod + +from six import with_metaclass + +from puppeter.domain.model import Installer # NOQA +from puppeter.domain.model.configurer import Configurer +from puppeter.domain.model.installer import Mode + + +class BaseDebianConfigurer(with_metaclass(ABCMeta, Configurer)): + UPDATE_INTERVAL = 24 * 60 * 60 + + def __init__(self, installer): + self._installer = installer # type: Installer + + def produce_commands(self): + collector = self._collector() + collector.collect_from_template('apt system update', + 'apt-update.sh', + dict(interval=self.UPDATE_INTERVAL)) + collector.collect_from_file('wget downloader', 'wget.sh') + self._collect_repo(collector) + self._collect_agent(collector) + if self._installer.mode() == Mode.Server: + self._collect_server(collector) + return collector.lines() + + @abstractmethod + def _collect_repo(self, collector): + # type: (Configurer.CommandsCollector) -> None + raise NotImplementedError() + + @abstractmethod + def _collect_agent(self, collector): + # type: (Configurer.CommandsCollector) -> None + raise NotImplementedError() + + @abstractmethod + def _collect_server(self, collector): + # type: (Configurer.CommandsCollector) -> None + raise NotImplementedError() diff --git a/puppeter/persistence/gateway/installer/debian/pc3x-repo.sh b/puppeter/persistence/gateway/installer/debian/pc3x-repo.sh new file mode 100644 index 0000000..faa91cf --- /dev/null +++ b/puppeter/persistence/gateway/installer/debian/pc3x-repo.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +set +e +if ! dpkg -l 'puppetlabs-release' | grep -q ii; then + set -e + cd /tmp + wget 'https://apt.puppetlabs.com/puppetlabs-release-@{codename}.deb' + sudo dpkg -i 'puppetlabs-release-@{codename}.deb' + rm 'puppetlabs-release-@{codename}.deb' + cd - + sudo apt-get update +fi diff --git a/puppeter/persistence/gateway/installer/debian/pc3x.py b/puppeter/persistence/gateway/installer/debian/pc3x.py index 9b20331..d577b0d 100644 --- a/puppeter/persistence/gateway/installer/debian/pc3x.py +++ b/puppeter/persistence/gateway/installer/debian/pc3x.py @@ -1,11 +1,24 @@ from puppeter.container import Named -from puppeter.domain.model.configurer import Configurer +from puppeter.domain.facter import Facter +from puppeter.domain.model.osfacts import OperatingSystemCodename +from puppeter.persistence.gateway.installer.debian.base import BaseDebianConfigurer @Named('pc3x-debian') -class PC3xConfigurer(Configurer): +class DebianPC3xConfigurer(BaseDebianConfigurer): def __init__(self, installer): - self.installer = installer + BaseDebianConfigurer.__init__(self, installer) - def produce_commands(self): - raise NotImplementedError('Not yet implemented!') + def _collect_repo(self, collector): + codename = Facter.get(OperatingSystemCodename) + collector.collect_from_template( + 'Puppet Package Repository setup (Puppet OSS 3.x)', + 'pc3x-repo.sh', + dict(codename=codename) + ) + + def _collect_agent(self, collector): + collector.collect_from_file('Puppet agent setup', 'puppet3xagent.sh') + + def _collect_server(self, collector): + collector.collect_from_file('PuppetMaster setup', 'puppetmaster.sh') diff --git a/puppeter/persistence/gateway/installer/debian/pc4x-repo.sh b/puppeter/persistence/gateway/installer/debian/pc4x-repo.sh new file mode 100644 index 0000000..f382aec --- /dev/null +++ b/puppeter/persistence/gateway/installer/debian/pc4x-repo.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +set +e +if ! dpkg -l 'puppetlabs-release-pc1' | grep -q ii; then + set -e + cd /tmp + wget 'https://apt.puppetlabs.com/puppetlabs-release-pc1-@{codename}.deb' + sudo dpkg -i 'puppetlabs-release-pc1-@{codename}.deb' + rm 'puppetlabs-release-pc1-@{codename}.deb' + cd - + sudo apt-get update +fi diff --git a/puppeter/persistence/gateway/installer/debian/pc4x.py b/puppeter/persistence/gateway/installer/debian/pc4x.py index fe63785..9ec7c25 100644 --- a/puppeter/persistence/gateway/installer/debian/pc4x.py +++ b/puppeter/persistence/gateway/installer/debian/pc4x.py @@ -1,16 +1,19 @@ from puppeter.container import Named from puppeter.domain.facter import Facter from puppeter.domain.model.osfacts import OperatingSystemCodename -from puppeter.domain.model.configurer import Configurer +from puppeter.persistence.gateway.installer.debian.after4x import AfterPuppet4xConfigurer @Named('pc4x-debian') -class PC4xConfigurer(Configurer): +class DebianPC4xConfigurer(AfterPuppet4xConfigurer): + def __init__(self, installer): - self.__installer = installer + AfterPuppet4xConfigurer.__init__(self, installer) - def produce_commands(self): + def _collect_repo(self, collector): codename = Facter.get(OperatingSystemCodename) - cmds = [] - cmds.append("") - raise NotImplementedError('Not yet implemented! %s' % codename) + collector.collect_from_template( + 'Puppet Labs Collection Repository (PC1) setup (Puppet OSS 4.x)', + 'pc4x-repo.sh', + dict(codename=codename) + ) diff --git a/puppeter/persistence/gateway/installer/debian/pc5x-repo.sh b/puppeter/persistence/gateway/installer/debian/pc5x-repo.sh new file mode 100644 index 0000000..0c8da29 --- /dev/null +++ b/puppeter/persistence/gateway/installer/debian/pc5x-repo.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +set +e +if ! dpkg -l 'puppet5-release' | grep -q ii; then + set -e + cd /tmp + wget 'https://apt.puppetlabs.com/puppet5-release-@{codename}.deb' + sudo dpkg -i 'puppet5-release-@{codename}.deb' + rm 'puppet5-release-@{codename}.deb' + cd - + sudo apt-get update +fi diff --git a/puppeter/persistence/gateway/installer/debian/pc5x.py b/puppeter/persistence/gateway/installer/debian/pc5x.py index a73572d..f32c98a 100644 --- a/puppeter/persistence/gateway/installer/debian/pc5x.py +++ b/puppeter/persistence/gateway/installer/debian/pc5x.py @@ -1,11 +1,19 @@ from puppeter.container import Named -from puppeter.domain.model.configurer import Configurer +from puppeter.domain.facter import Facter +from puppeter.domain.model.osfacts import OperatingSystemCodename +from puppeter.persistence.gateway.installer.debian.after4x import AfterPuppet4xConfigurer @Named('pc5x-debian') -class PC5xConfigurer(Configurer): +class DebianPC5xConfigurer(AfterPuppet4xConfigurer): + def __init__(self, installer): - self.installer = installer + AfterPuppet4xConfigurer.__init__(self, installer) - def produce_commands(self): - raise NotImplementedError('Not yet implemented!') + def _collect_repo(self, collector): + codename = Facter.get(OperatingSystemCodename) + collector.collect_from_template( + 'Puppet Platform Repository setup (Puppet OSS 5.x)', + 'pc5x-repo.sh', + dict(codename=codename) + ) diff --git a/puppeter/persistence/gateway/installer/debian/puppet3xagent.sh b/puppeter/persistence/gateway/installer/debian/puppet3xagent.sh new file mode 100644 index 0000000..babffb7 --- /dev/null +++ b/puppeter/persistence/gateway/installer/debian/puppet3xagent.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set +e +if ! dpkg -l 'puppet' | grep -q ii; then + set -e + sudo apt-get install -y puppet +fi diff --git a/data/templates/installer/pc/debian/puppetagent.sh b/puppeter/persistence/gateway/installer/debian/puppetagent.sh similarity index 86% rename from data/templates/installer/pc/debian/puppetagent.sh rename to puppeter/persistence/gateway/installer/debian/puppetagent.sh index 486662a..5c4fdaa 100644 --- a/data/templates/installer/pc/debian/puppetagent.sh +++ b/puppeter/persistence/gateway/installer/debian/puppetagent.sh @@ -1,9 +1,7 @@ #!/usr/bin/env bash - -set -x set +e - if ! dpkg -l 'puppet-agent' | grep -q ii; then set -e sudo apt-get install -y puppet-agent + exec env bash -l fi diff --git a/puppeter/persistence/gateway/installer/debian/puppetmaster.sh b/puppeter/persistence/gateway/installer/debian/puppetmaster.sh new file mode 100644 index 0000000..0b4f47a --- /dev/null +++ b/puppeter/persistence/gateway/installer/debian/puppetmaster.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +puppet resource package puppetmaster ensure=installed diff --git a/puppeter/persistence/gateway/installer/debian/puppetserver.sh b/puppeter/persistence/gateway/installer/debian/puppetserver.sh new file mode 100644 index 0000000..f4dccef --- /dev/null +++ b/puppeter/persistence/gateway/installer/debian/puppetserver.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +puppet resource package puppetserver ensure=installed diff --git a/puppeter/persistence/gateway/installer/debian/wget.sh b/puppeter/persistence/gateway/installer/debian/wget.sh new file mode 100644 index 0000000..9eaa106 --- /dev/null +++ b/puppeter/persistence/gateway/installer/debian/wget.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set +e +if ! dpkg -l 'wget' | grep -q ii; then + set -e + sudo apt-get install -y wget +fi diff --git a/data/templates/installer/pc4x/redhat/repo.sh b/puppeter/persistence/gateway/installer/redhat/pc4x-repo.sh similarity index 100% rename from data/templates/installer/pc4x/redhat/repo.sh rename to puppeter/persistence/gateway/installer/redhat/pc4x-repo.sh diff --git a/data/templates/installer/pc/redhat/puppetagent.sh b/puppeter/persistence/gateway/installer/redhat/puppetagent.sh similarity index 100% rename from data/templates/installer/pc/redhat/puppetagent.sh rename to puppeter/persistence/gateway/installer/redhat/puppetagent.sh diff --git a/data/templates/installer/pc/redhat/puppetserver.sh b/puppeter/persistence/gateway/installer/redhat/puppetserver.sh similarity index 100% rename from data/templates/installer/pc/redhat/puppetserver.sh rename to puppeter/persistence/gateway/installer/redhat/puppetserver.sh diff --git a/puppeter/presentation/app.py b/puppeter/presentation/app.py index 781d485..d4bc455 100644 --- a/puppeter/presentation/app.py +++ b/puppeter/presentation/app.py @@ -25,7 +25,7 @@ def run(self): @staticmethod def __stderr_handler(): handler = StreamHandler(stream=sys.stderr) - fmt = '%(levelname)s: %(message)s' + fmt = '# %(levelname)s: %(message)s' handler.setFormatter(ColoredFormatter(fmt=fmt)) handler.setLevel(logging.NOTSET) return handler diff --git a/setup.py b/setup.py index 16ca9cd..f05ef57 100644 --- a/setup.py +++ b/setup.py @@ -112,7 +112,7 @@ def find_version(*file_paths): # installed, specify them here. If using Python 2.6 or less, then these # have to be included in MANIFEST.in as well. package_data={ - # 'sample': ['package_data.dat'], + 'puppeter': ['*.sh'], }, # Although 'package_data' is the preferred approach, in some case you may diff --git a/tests/domain/test_facter.py b/tests/domain/test_facter.py index db570f7..f714235 100644 --- a/tests/domain/test_facter.py +++ b/tests/domain/test_facter.py @@ -10,13 +10,15 @@ def test_facter_get_unknown(): def test_invalid_resolver(): + # noinspection PyUnresolvedReferences,PyProtectedMember + resolvers = Facter._Facter__resolvers + before_count = len(resolvers) try: - before_count = len(Facter._Facter__resolvers) Facter.set(TEST_KEY, lambda: None) value = Facter.get(TEST_KEY) assert value is None - assert len(Facter._Facter__resolvers) == before_count + 1 + assert len(resolvers) == before_count + 1 finally: - Facter._Facter__resolvers.pop(TEST_KEY) - assert len(Facter._Facter__resolvers) == before_count + resolvers.pop(TEST_KEY) + assert len(resolvers) == before_count diff --git a/tests/persistence/gateway/installer/__init__.py b/tests/persistence/gateway/installer/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/persistence/gateway/installer/debian/__init__.py b/tests/persistence/gateway/installer/debian/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/persistence/gateway/installer/debian/test_pc3x.py b/tests/persistence/gateway/installer/debian/test_pc3x.py new file mode 100644 index 0000000..90360bc --- /dev/null +++ b/tests/persistence/gateway/installer/debian/test_pc3x.py @@ -0,0 +1,16 @@ +from puppeter.domain.model import Collection3xInstaller +from puppeter.persistence.gateway.installer.debian import DebianPC3xConfigurer + + +def test_pc3x(): + # given + installer = Collection3xInstaller() + installer.read_raw_options({'mode': 'Server'}) + configurer = DebianPC3xConfigurer(installer=installer) + + # when + commands = configurer.produce_commands() + + # then + assert '# Part 1: apt system update' in commands + assert 'puppet resource package puppetmaster ensure=installed' in commands