salt-master

Salt Master Factory

class saltfactories.daemons.master.SaltMaster(*, config, python_executable=None, system_install=False, cwd=None, environ=None, script_name, base_script_args=NOTHING, slow_stop=True, check_ports=None, factories_manager=None, start_timeout, max_start_attempts=3, extra_cli_arguments_after_first_start_failure=NOTHING, event_listener=None, started_at=None, on_auth_event_callback=None)[source]

Bases: saltfactories.bases.SaltDaemon

Return type

None

classmethod load_config(config_file, config)[source]

Should return the configuration as the daemon would have loaded after parsing the CLI

get_check_events()[source]

Return a list of tuples in the form of (master_id, event_tag) check against to ensure the daemon is running

salt_master_daemon(master_id, **kwargs)[source]

This method will configure a master under a master-of-masters.

Please see the documentation in salt_master_daemon

salt_minion_daemon(minion_id, **kwargs)[source]

Please see the documentation in configure_salt_minion

salt_proxy_minion_daemon(minion_id, **kwargs)[source]

Please see the documentation in salt_proxy_minion_daemon

salt_api_daemon(**kwargs)[source]

Please see the documentation in salt_api_daemon

salt_syndic_daemon(syndic_id, **kwargs)[source]

Please see the documentation in salt_syndic_daemon

salt_cloud_cli(defaults=None, overrides=None, factory_class=<class 'saltfactories.cli.cloud.SaltCloud'>, **factory_class_kwargs)[source]

Return a salt-cloud CLI instance

Args:
defaults(dict):

A dictionary of default configuration to use when configuring the minion

overrides(dict):

A dictionary of configuration overrides to use when configuring the minion

Returns:
SaltCloud:

The salt-cloud CLI script process class instance

salt_cli(factory_class=<class 'saltfactories.cli.salt.Salt'>, **factory_class_kwargs)[source]

Return a salt CLI process for this master instance

salt_cp_cli(factory_class=<class 'saltfactories.cli.cp.SaltCp'>, **factory_class_kwargs)[source]

Return a salt-cp CLI process for this master instance

salt_key_cli(factory_class=<class 'saltfactories.cli.key.SaltKey'>, **factory_class_kwargs)[source]

Return a salt-key CLI process for this master instance

salt_run_cli(factory_class=<class 'saltfactories.cli.run.SaltRun'>, **factory_class_kwargs)[source]

Return a salt-run CLI process for this master instance

salt_spm_cli(factory_class=<class 'saltfactories.cli.spm.Spm'>, **factory_class_kwargs)[source]

Return a spm CLI process for this master instance

salt_ssh_cli(factory_class=<class 'saltfactories.cli.ssh.SaltSsh'>, roster_file=None, target_host=None, client_key=None, ssh_user=None, **factory_class_kwargs)[source]

Return a salt-ssh CLI process for this master instance

Args:
roster_file(str):

The roster file to use

target_host(str):

The target host address to connect to

client_key(str):

The path to the private ssh key to use to connect

ssh_user(str):

The remote username to connect as

salt_client(functions_known_to_return_none=None, factory_class=<class 'saltfactories.client.LocalClient'>)[source]

Return a local salt client object

after_start(callback, *args, **kwargs)

Register a function callback to run after the daemon starts

Parameters
  • callback (Callable) – The function to call back

  • args – The arguments to pass to the callback

  • kwargs – The keyword arguments to pass to the callback

after_terminate(callback, *args, **kwargs)

Register a function callback to run after the daemon terminates

Parameters
  • callback (Callable) – The function to call back

  • args – The arguments to pass to the callback

  • kwargs – The keyword arguments to pass to the callback

before_start(callback, *args, **kwargs)

Register a function callback to run before the daemon starts

Parameters
  • callback (Callable) – The function to call back

  • args – The arguments to pass to the callback

  • kwargs – The keyword arguments to pass to the callback

before_terminate(callback, *args, **kwargs)

Register a function callback to run before the daemon terminates

Parameters
  • callback (Callable) – The function to call back

  • args – The arguments to pass to the callback

  • kwargs – The keyword arguments to pass to the callback

cmdline(*args)

Construct a list of arguments to use when starting the subprocess

Parameters

args (str) – Additional arguments to use when starting the subprocess

classmethod configure(factories_manager, daemon_id, root_dir=None, defaults=None, overrides=None, **configure_kwargs)

Configure the salt daemon

get_base_script_args()

Returns any additional arguments to pass to the CLI script

get_check_ports()

Return a list of ports to check against to ensure the daemon is running

get_display_name()

Returns a human readable name for the factory

get_script_args()

Returns any additional arguments to pass to the CLI script

get_script_path()

Returns the path to the script to run

is_running()

Returns true if the sub-process is alive

property pid

The pid of the running process. None if not running.

run_start_checks(started_at, timeout_at)

Run checks to confirm that the daemon has started

start(*extra_cli_arguments, max_start_attempts=None, start_timeout=None)

Start the daemon

started(*extra_cli_arguments, max_start_attempts=None, start_timeout=None)

Start the daemon and return it’s instance so it can be used as a context manager

stopped(before_stop_callback=None, after_stop_callback=None, before_start_callback=None, after_start_callback=None)
Parameters
  • before_stop_callback (Callable) – A callable to run before stopping the daemon. The callback must accept one argument, the daemon instance.

  • after_stop_callback (Callable) – A callable to run after stopping the daemon. The callback must accept one argument, the daemon instance.

  • before_start_callback (Callable) – A callable to run before starting the daemon. The callback must accept one argument, the daemon instance.

  • after_start_callback (Callable) – A callable to run after starting the daemon. The callback must accept one argument, the daemon instance.

This context manager will stop the factory while the context is in place, it re-starts it once out of context.

For example:

assert factory.is_running() is True

with factory.stopped():
    assert factory.is_running() is False

assert factory.is_running() is True
terminate()

Terminate the started daemon

classmethod write_config(config)

Write the configuration to file