set __cdist_dry_run env var if dry-run

This commit is contained in:
ander 2019-05-16 21:58:47 +02:00 committed by Darko Poljak
commit 69622b0fa5
6 changed files with 32 additions and 6 deletions

View file

@ -97,7 +97,7 @@ class Code(object):
"""
# target_host is tuple (target_host, target_hostname, target_fqdn)
def __init__(self, target_host, local, remote):
def __init__(self, target_host, local, remote, dry_run=False):
self.target_host = target_host
self.local = local
self.remote = remote
@ -113,6 +113,9 @@ class Code(object):
local.log),
}
if dry_run:
self.env['__cdist_dry_run'] = '1'
def _run_gencode(self, cdist_object, which):
cdist_type = cdist_object.cdist_type
script = os.path.join(self.local.type_path,

View file

@ -67,7 +67,7 @@ class Explorer(object):
"""Executes cdist explorers.
"""
def __init__(self, target_host, local, remote, jobs=None):
def __init__(self, target_host, local, remote, jobs=None, dry_run=False):
self.target_host = target_host
self._open_logger()
@ -84,6 +84,10 @@ class Explorer(object):
'__cdist_log_level_name': util.log_level_name_env_var_val(
self.log),
}
if dry_run:
self.env['__cdist_dry_run'] = '1'
self._type_explorers_transferred = []
self.jobs = jobs

View file

@ -96,7 +96,7 @@ class Manifest(object):
"""Executes cdist manifests.
"""
def __init__(self, target_host, local):
def __init__(self, target_host, local, dry_run=False):
self.target_host = target_host
self.local = local
@ -117,6 +117,9 @@ class Manifest(object):
self.log),
}
if dry_run:
self.env['__cdist_dry_run'] = '1'
def _open_logger(self):
self.log = logging.getLogger(self.target_host[0])