added some ideas from asteven and a bit more description about the order
in the manpage
This commit is contained in:
parent
4ef55ef13f
commit
197fabf40a
3 changed files with 10 additions and 6 deletions
|
@ -212,14 +212,13 @@ class CdistObject(object):
|
||||||
"""Checks wether this cdist object exists on the file systems."""
|
"""Checks wether this cdist object exists on the file systems."""
|
||||||
return os.path.exists(self.absolute_path)
|
return os.path.exists(self.absolute_path)
|
||||||
|
|
||||||
def create(self):
|
def create(self, allow_overwrite=False):
|
||||||
"""Create this cdist object on the filesystem.
|
"""Create this cdist object on the filesystem.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
cdexist_ok = True if os.environ.get('CDIST_ALLOW_OVERRIDE',"false") == 'true' else False
|
os.makedirs(self.absolute_path, exist_ok=allow_overwrite)
|
||||||
os.makedirs(self.absolute_path, exist_ok=cdexist_ok)
|
|
||||||
absolute_parameter_path = os.path.join(self.base_path, self.parameter_path)
|
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:
|
except EnvironmentError as error:
|
||||||
raise cdist.Error('Error creating directories for cdist object: %s: %s' % (self, error))
|
raise cdist.Error('Error creating directories for cdist object: %s: %s' % (self, error))
|
||||||
|
|
||||||
|
|
|
@ -153,6 +153,8 @@ class Emulator(object):
|
||||||
else:
|
else:
|
||||||
if self.cdist_object.exists:
|
if self.cdist_object.exists:
|
||||||
self.log.debug('Object %s override forced with CDIST_ALLOW_OVERRIDE=true',self.cdist_object.name)
|
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.create()
|
||||||
self.cdist_object.parameters = self.parameters
|
self.cdist_object.parameters = self.parameters
|
||||||
|
|
||||||
|
|
|
@ -163,11 +163,14 @@ require="__package/lighttpd" __package munin --state present
|
||||||
|
|
||||||
OVERRIDES
|
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.
|
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
|
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
|
CDIST_ALLOW_OVERRIDE=true to tell cdist, that this object override is
|
||||||
wanted and should be accepted.
|
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
|
# for example in the inial manifest
|
||||||
|
|
Loading…
Reference in a new issue