validations_common.library.validations_read_ini module

Ansible module to read a value from an INI file. Usage: validations_read_ini: path=/path/to/file.ini section=default key=something

This will read the path/to/file.ini file and read the Hello! value under:

[default] something = Hello!

You can register the result and use it later with {{ my_ini.value }}

class validations_common.library.validations_read_ini.ReturnValue(value)[source]

Bases: enum.Enum

An enumeration.

INVALID_FORMAT = 1
KEY_NOT_FOUND = 2
OK = 0
validations_common.library.validations_read_ini.check_file(path)[source]

Check if the requested file exists. :param path: path to configuration file :dtype path: string

Returns

True if file exists, false otherwise

Return type

bool

validations_common.library.validations_read_ini.get_result(path, section, key, default=None)[source]

Get value based on a section and a key.

Parameters
  • path – path to configuration file

  • section – name of the config file section

  • key – key for which we want to know the value

  • default – default value to use if the key does not exist

Dtype path

string

Dtype section

string

Dtype key

string

Dtype default

object

Returns

tuple of numeric return code, message and value of the requested key

Return type

tuple

validations_common.library.validations_read_ini.main()[source]