; environment will be removed from the list of allowed Puppet environments.
; Environment must start with a lowercase letter, and then there may be lowercase
; letters, digits or underscores.
-;additional_puppet_environments = dev_fbrehm, dev_lutbeie
+;puppet_environments = dev_fbrehm, dev_lutbeie
# vim: filetype=dosini
from .xlate import XLATOR
-__version__ = '1.3.8'
+__version__ = '1.4.0'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
default_tf_backend_scheme = 'https'
default_tf_backend_path_prefix = 'terraform'
+ re_list_split = re.compile(r'\s*[,:\s]+\s*')
+
default_puppetmaster = 'puppetmaster03.pixelpark.com'
default_puppetca = 'puppetca01.pixelpark.com'
self.puppetca = self.default_puppetca
self.pdns_comment_account = self.default_pdns_comment_account
+ self.puppet_envs_add = set()
+ self.puppet_envs_delete = set()
+
self.vsphere = {}
self._disk_size = self.default_disk_size
re_backend_scheme = re.compile(r'^\s*backend[_-]?scheme\s*$', re.IGNORECASE)
re_backend_path_prefix = re.compile(r'^\s*backend[_-]?path[_-]?prefix\s*$', re.IGNORECASE)
+ # re_list_split
+ re_puppet_envs = re.compile(r'^\s*puppet[_-]?env(?:ironment)?s?\s*$', re.IGNORECASE)
+ re_puppet_env = re.compile(r'^([+-])?([a-z](?:[a-z0-9_]*[a-z0-9])?)$', re.IGNORECASE)
+
for (key, value) in config.items(section):
if re_root_pw.search(key) and value.strip():
self.vm_root_password = value
self.tf_backend_scheme = value.strip().lower()
elif re_backend_path_prefix.search(key) and value.strip():
self.tf_backend_path_prefix = value.strip()
+ elif re_puppet_envs.search(key) and value.strip():
+ v = value.strip()
+ env_list = self.re_list_split.split(v)
+ for env in env_list:
+ match = re_puppet_env.match(env)
+ if not match:
+ msg = _("Invalid puppet environment {env!r} found in {k!r}.").format(
+ env=env, k=key)
+ LOG.warn(msg)
+ continue
+ sign = match.group(1)
+ val = match.group(2).lower()
+ if sign == '-':
+ self.puppet_envs_delete.add(val)
+ else:
+ self.puppet_envs_add.add(val)
# =============================================================================