simple_automation.group.Group

class simple_automation.group.Group(manager, identifier)

Bases: simple_automation.vars.Vars

A group for hosts. Can store variables which will have higher precedence than global variables, but lower than host variables.

Methods

copy

Copies a value from another vars object into this one.

get

Retrieves a variable by the given key.

set

Sets the given variable.

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.