added some ideas from asteven and a bit more description about the order

in the manpage
This commit is contained in:
Daniel Heule 2014-01-31 17:56:55 +01:00
parent 4ef55ef13f
commit 197fabf40a
3 changed files with 10 additions and 6 deletions

View file

@ -212,14 +212,13 @@ class CdistObject(object):
"""Checks wether this cdist object exists on the file systems."""
return os.path.exists(self.absolute_path)
def create(self):
def create(self, allow_overwrite=False):
"""Create this cdist object on the filesystem.
"""
try:
cdexist_ok = True if os.environ.get('CDIST_ALLOW_OVERRIDE',"false") == 'true' else False
os.makedirs(self.absolute_path, exist_ok=cdexist_ok)
os.makedirs(self.absolute_path, exist_ok=allow_overwrite)
absolute_parameter_path = os.path.join(self.base_path, self.parameter_path)
os.makedirs(absolute_parameter_path, exist_ok=cdexist_ok)
os.makedirs(absolute_parameter_path, exist_ok=allow_overwrite)
except EnvironmentError as error:
raise cdist.Error('Error creating directories for cdist object: %s: %s' % (self, error))

View file

@ -153,6 +153,8 @@ class Emulator(object):
else:
if self.cdist_object.exists:
self.log.debug('Object %s override forced with CDIST_ALLOW_OVERRIDE=true',self.cdist_object.name)
self.cdist_object.create(True)
else
self.cdist_object.create()
self.cdist_object.parameters = self.parameters

View file

@ -163,11 +163,14 @@ require="__package/lighttpd" __package munin --state present
OVERRIDES
---------
In some special cases, you would like to create an allready defined object
In some special cases, you would like to create an already defined object
with different parameters. In normal situations this leads to an error in cdist.
If you whish, you can mark this second definition of an object with
CDIST_ALLOW_OVERRIDE=true to tell cdist, that this object override is
wanted and should be accepted.
ATTENTION: Only use this feature if you are 100% sure in which order
cdist encounter the affected objects, otherwhise this results
into an undefined situation.
--------------------------------------------------------------------------------
# for example in the inial manifest