forked from ungleich-public/cdist
Merge branch 'dry_run_env_var' into 'master'
set __cdist_dry_run env var if dry-run See merge request ungleich-public/cdist!781
This commit is contained in:
commit
f376eb361f
6 changed files with 32 additions and 6 deletions
|
@ -104,9 +104,12 @@ class Config(object):
|
||||||
self.remove_remote_files_dirs = remove_remote_files_dirs
|
self.remove_remote_files_dirs = remove_remote_files_dirs
|
||||||
|
|
||||||
self.explorer = core.Explorer(self.local.target_host, self.local,
|
self.explorer = core.Explorer(self.local.target_host, self.local,
|
||||||
self.remote, jobs=self.jobs)
|
self.remote, jobs=self.jobs,
|
||||||
self.manifest = core.Manifest(self.local.target_host, self.local)
|
dry_run=self.dry_run)
|
||||||
self.code = core.Code(self.local.target_host, self.local, self.remote)
|
self.manifest = core.Manifest(self.local.target_host, self.local,
|
||||||
|
dry_run=self.dry_run)
|
||||||
|
self.code = core.Code(self.local.target_host, self.local, self.remote,
|
||||||
|
dry_run=self.dry_run)
|
||||||
|
|
||||||
def _init_files_dirs(self):
|
def _init_files_dirs(self):
|
||||||
"""Prepare files and directories for the run"""
|
"""Prepare files and directories for the run"""
|
||||||
|
|
|
@ -97,7 +97,7 @@ class Code(object):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# target_host is tuple (target_host, target_hostname, target_fqdn)
|
# 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.target_host = target_host
|
||||||
self.local = local
|
self.local = local
|
||||||
self.remote = remote
|
self.remote = remote
|
||||||
|
@ -113,6 +113,9 @@ class Code(object):
|
||||||
local.log),
|
local.log),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if dry_run:
|
||||||
|
self.env['__cdist_dry_run'] = '1'
|
||||||
|
|
||||||
def _run_gencode(self, cdist_object, which):
|
def _run_gencode(self, cdist_object, which):
|
||||||
cdist_type = cdist_object.cdist_type
|
cdist_type = cdist_object.cdist_type
|
||||||
script = os.path.join(self.local.type_path,
|
script = os.path.join(self.local.type_path,
|
||||||
|
|
|
@ -67,7 +67,7 @@ class Explorer(object):
|
||||||
"""Executes cdist explorers.
|
"""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.target_host = target_host
|
||||||
|
|
||||||
self._open_logger()
|
self._open_logger()
|
||||||
|
@ -84,6 +84,10 @@ class Explorer(object):
|
||||||
'__cdist_log_level_name': util.log_level_name_env_var_val(
|
'__cdist_log_level_name': util.log_level_name_env_var_val(
|
||||||
self.log),
|
self.log),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if dry_run:
|
||||||
|
self.env['__cdist_dry_run'] = '1'
|
||||||
|
|
||||||
self._type_explorers_transferred = []
|
self._type_explorers_transferred = []
|
||||||
self.jobs = jobs
|
self.jobs = jobs
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ class Manifest(object):
|
||||||
"""Executes cdist manifests.
|
"""Executes cdist manifests.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def __init__(self, target_host, local):
|
def __init__(self, target_host, local, dry_run=False):
|
||||||
self.target_host = target_host
|
self.target_host = target_host
|
||||||
self.local = local
|
self.local = local
|
||||||
|
|
||||||
|
@ -117,6 +117,9 @@ class Manifest(object):
|
||||||
self.log),
|
self.log),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if dry_run:
|
||||||
|
self.env['__cdist_dry_run'] = '1'
|
||||||
|
|
||||||
def _open_logger(self):
|
def _open_logger(self):
|
||||||
self.log = logging.getLogger(self.target_host[0])
|
self.log = logging.getLogger(self.target_host[0])
|
||||||
|
|
||||||
|
|
|
@ -219,6 +219,10 @@ __cdist_log_level, __cdist_log_level_name
|
||||||
| TRACE | 5 |
|
| TRACE | 5 |
|
||||||
+----------------+-----------------+
|
+----------------+-----------------+
|
||||||
|
|
||||||
|
Available for: initial manifest, explorer, type manifest, type explorer,
|
||||||
|
type gencode.
|
||||||
|
__cdist_dry_run
|
||||||
|
Is set only when doing dry run (``-n`` flag).
|
||||||
Available for: initial manifest, explorer, type manifest, type explorer,
|
Available for: initial manifest, explorer, type manifest, type explorer,
|
||||||
type gencode.
|
type gencode.
|
||||||
__explorer
|
__explorer
|
||||||
|
|
|
@ -371,6 +371,15 @@ It is available for initial manifest, explorer, type manifest,
|
||||||
type explorer, type gencode.
|
type explorer, type gencode.
|
||||||
|
|
||||||
|
|
||||||
|
Detecting dry run
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
If ``$__cdist_dry_run`` environment variable is set, then it's dry run.
|
||||||
|
|
||||||
|
It is available for initial manifest, explorer, type manifest,
|
||||||
|
type explorer, type gencode.
|
||||||
|
|
||||||
|
|
||||||
Hints for typewriters
|
Hints for typewriters
|
||||||
----------------------
|
----------------------
|
||||||
It must be assumed that the target is pretty dumb and thus does not have high
|
It must be assumed that the target is pretty dumb and thus does not have high
|
||||||
|
|
Loading…
Reference in a new issue