simple_automation.host.Host

class simple_automation.host.Host(manager, identifier, ssh_host)

Bases: simple_automation.vars.Vars

A Host represents a machine that can be reached via ssh, and which should be managed by simple_automation. It can store variables which override gloabl and group variables, which may be used to customize the execution routine.

Methods

add_group

Adds this host to the given group, if it isn’t already in that group.

copy

Copies a value from another vars object into this one.

get

Retrieves a variable by the given key.

set

Sets the given variable.

set_ssh_opts

Sets additional ssh parameters for this host’s connection.

set_ssh_port

Sets the ssh port for the host’s connection.

add_group(group)

Adds this host to the given group, if it isn’t already in that group.

copy(key, other_vars)

Copies a value from another vars object into this one. Same as calling self.set(key, other_vars.get(key))

Parameters
  • key (str) – The key that should be copied.

  • other_vars (Vars) – The source variable storage where the key is copied from.

get(key, default=None)

Retrieves a variable by the given key. If no such key exists, it returns the given default value or throws a KeyError if no default is set.

Parameters
  • key (str) – The key that should be read.

  • default (Any, optional) – If not None, this will be returned in case the key is unset. By default None.

Returns

The stored object.

Return type

Any

set(key, value)

Sets the given variable.

Parameters
  • key (str) – The key that should be read.

  • value (Any, optional) – The value to be stored. Must be json (de-)serializable.

set_ssh_opts(opts)

Sets additional ssh parameters for this host’s connection.

Parameters

opts (list[string]) – Additional parameters to ssh

set_ssh_port(port)

Sets the ssh port for the host’s connection.

Parameters

port (int) – The port number to connect to