From 13a2f677ed20d585cfa1b62e29f070c2fa8367ec Mon Sep 17 00:00:00 2001 From: Etsuji Nakai Date: Sat, 6 Jul 2013 09:33:40 +0900 Subject: [PATCH] Add global option --exclude-servers=EXCLUDE_SERVERS This is a comma separated list of servers to be excluded from installation in case you are running Packstack the second time with the same answer file and don't want Packstack to touch these servers. For example, suppose that you've already installed the following hosts: - Controller node : 10.0.0.99 - Compute nodes : 10.0.0.100 - 10.0.0.110 and you want add one more compute node 10.0.0.111. Then you can reuse the previous answer file with the following modification: - Add 10.0.0.111 to NOVACOMPUTE_HOSTS - Add existing hosts (10.0.0.99 - 10.0.0.110) to EXCLUDE_SERVERS This avoids applying puppet modules to existing hosts again. (In theory, because of idempotentness of puppet manifests, applying the same modules does no harm. But it is a waste of time and has a potential risk of breaking manual configurations which has been done after the packstack installation.) Change-Id: Ib3dcd94a25a286f82cc0fcedebd1824b1d27d864 --- packstack/plugins/prescript_000.py | 11 +++++++++++ packstack/plugins/puppet_950.py | 15 ++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/packstack/plugins/prescript_000.py b/packstack/plugins/prescript_000.py index c7a011711..57b4470a2 100644 --- a/packstack/plugins/prescript_000.py +++ b/packstack/plugins/prescript_000.py @@ -133,6 +133,17 @@ def initConfig(controllerObject): "USE_DEFAULT" : False, "NEED_CONFIRM" : False, "CONDITION" : False }, + {"CMD_OPTION" : "exclude-servers", + "USAGE" : "Comma separated list of servers to be excluded from installation in case you are running Packstack the second time with the same answer file and don't want Packstack to touch these servers. Leave plain if you don't need to exclude any server.", + "PROMPT" : "Enter a comma separated list of server(s) to be excluded. Leave plain if you don't need to exclude any server.", + "OPTION_LIST" : [], + "DEFAULT_VALUE" : '', + "MASK_INPUT" : False, + "LOOSE_VALIDATION": False, + "CONF_NAME" : "EXCLUDE_SERVERS", + "USE_DEFAULT" : False, + "NEED_CONFIRM" : False, + "CONDITION" : False }, ] groupDict = { "GROUP_NAME" : "GLOBAL", "DESCRIPTION" : "Global Options", diff --git a/packstack/plugins/puppet_950.py b/packstack/plugins/puppet_950.py index 9938f80b5..58433cc91 100644 --- a/packstack/plugins/puppet_950.py +++ b/packstack/plugins/puppet_950.py @@ -46,6 +46,15 @@ def initConfig(controllerObject): controller.addGroup(groupDict, paramsList) +def getinstallhostlist(conf): + list = [] + exclude_list = map(str.strip, conf['EXCLUDE_SERVERS'].split(',')) + for host in gethostlist(conf): + if host not in exclude_list: + list.append(host) + return list + + def initSequences(controller): puppetpresteps = [ {'title': 'Clean Up', 'functions':[runCleanup]}, @@ -67,7 +76,7 @@ def runCleanup(config): def installdeps(config): - for hostname in gethostlist(controller.CONF): + for hostname in getinstallhostlist(controller.CONF): server = utils.ScriptRunner(hostname) for package in ("puppet", "openssh-clients", "tar", "nc"): server.append("rpm -q %s || yum install -y %s" % (package, package)) @@ -90,7 +99,7 @@ def copyPuppetModules(config): tar_opts = "" if platform.linux_distribution()[0] == "Fedora": tar_opts += "--exclude create_resources " - for hostname in gethostlist(controller.CONF): + for hostname in getinstallhostlist(controller.CONF): host_dir = controller.temp_map[hostname] puppet_dir = os.path.join(host_dir, basedefs.PUPPET_MANIFEST_RELATIVE) server.append("cd %s/puppet" % basedefs.DIR_PROJECT_DIR) @@ -181,7 +190,7 @@ def applyPuppetManifest(config): waitforpuppet(currently_running) lastmarker = marker - for hostname in gethostlist(controller.CONF): + for hostname in getinstallhostlist(controller.CONF): if "%s_" % hostname not in manifest: continue