mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add bootstrap delay and systemd check options
This commit is contained in:
parent
6a92bfbd42
commit
2be3f8b5bb
3 changed files with 19 additions and 4 deletions
|
@ -750,6 +750,12 @@ VALID_OPTS = {
|
|||
|
||||
# HTTP request max file content size.
|
||||
'http_max_body': int,
|
||||
|
||||
# Delay in seconds before executing bootstrap (salt cloud)
|
||||
'bootstrap_delay': int,
|
||||
|
||||
# Does this lxc template have systemd installed?
|
||||
'uses_systemd': bool,
|
||||
}
|
||||
|
||||
# default configurations
|
||||
|
@ -1220,6 +1226,8 @@ CLOUD_CONFIG_DEFAULTS = {
|
|||
'log_fmt_console': _DFLT_LOG_FMT_CONSOLE,
|
||||
'log_fmt_logfile': _DFLT_LOG_FMT_LOGFILE,
|
||||
'log_granular_levels': {},
|
||||
'bootstrap_delay': None,
|
||||
'uses_systemd': True,
|
||||
}
|
||||
|
||||
DEFAULT_API_OPTS = {
|
||||
|
|
|
@ -3319,7 +3319,7 @@ def test_bare_started_state(name, path=None):
|
|||
return ret
|
||||
|
||||
|
||||
def wait_started(name, path=None, timeout=300):
|
||||
def wait_started(name, path=None, timeout=300, uses_systemd=True):
|
||||
'''
|
||||
Check that the system has fully inited
|
||||
|
||||
|
@ -3347,7 +3347,7 @@ def wait_started(name, path=None, timeout=300):
|
|||
raise CommandExecutionError(
|
||||
'Container {0} is not running'.format(name))
|
||||
ret = False
|
||||
if running_systemd(name, path=path):
|
||||
if uses_systemd and running_systemd(name, path=path):
|
||||
test_started = test_sd_started_state
|
||||
logger = log.error
|
||||
else:
|
||||
|
@ -3403,7 +3403,8 @@ def bootstrap(name,
|
|||
path=None,
|
||||
bootstrap_delay=None,
|
||||
bootstrap_args=None,
|
||||
bootstrap_shell=None):
|
||||
bootstrap_shell=None,
|
||||
uses_systemd=True):
|
||||
'''
|
||||
Install and configure salt in a container.
|
||||
|
||||
|
@ -3464,7 +3465,7 @@ def bootstrap(name,
|
|||
[approve_key=(True|False)] [install=(True|False)]
|
||||
|
||||
'''
|
||||
wait_started(name, path=path)
|
||||
wait_started(name, path=path, uses_systemd=uses_systemd)
|
||||
if bootstrap_delay is not None:
|
||||
try:
|
||||
time.sleep(bootstrap_delay)
|
||||
|
|
|
@ -312,6 +312,11 @@ def init(names, host=None, saltcloud_mode=False, quiet=False, **kwargs):
|
|||
if saltcloud_mode:
|
||||
kw = copy.deepcopy(kw)
|
||||
kw['name'] = name
|
||||
saved_kwargs = {}
|
||||
if 'bootstrap_delay' in kw:
|
||||
saved_kwargs['bootstrap_delay'] = kw['bootstrap_delay']
|
||||
if 'uses_systemd' in kw:
|
||||
saved_kwargs['uses_systemd'] = kw['uses_systemd']
|
||||
kw = client.cmd(
|
||||
host, 'lxc.cloud_init_interface', args + [kw],
|
||||
expr_form='list', timeout=600).get(host, {})
|
||||
|
@ -320,6 +325,7 @@ def init(names, host=None, saltcloud_mode=False, quiet=False, **kwargs):
|
|||
kw['seed'] = seeds.get(name, seed_arg)
|
||||
if not kw['seed']:
|
||||
kw.pop('seed_cmd', '')
|
||||
kw.update(saved_kwargs)
|
||||
cmds.append(
|
||||
(host,
|
||||
name,
|
||||
|
|
Loading…
Add table
Reference in a new issue