Rundeck Resources¶
Python tool to query resources from different sources and export them into a data structure that Rundeck
can consume.
Installation¶
pip install rundeck-resources
Usage¶
$ rundeck-resources -h
usage: rundeck-resources [-h] [-v] [-l LOGGER] [--no-cache] [-V] config
Generates rundeck resources file from different API sources.
positional arguments:
config Configuration file.
optional arguments:
-h, --help show this help message and exit
-v, --verbose Verbosity level to use.
-l LOGGER, --logger LOGGER
The logger YAML configuration file.
--no-cache Do not use cache.
-V, --version Prints version.
The rundeck-resources
requires an INI configuration file.
You can see the example configuration in the example.ini.
Docker¶
There is a docker image tagged with the version of the released package.
ENV | OPTIONAL | DESCRIPTION |
---|---|---|
ARGS | True |
The command line arguments. |
CONFIG | False |
The path to the configuration file. |
- Usage:
$ docker run -it -v ~/config/:/config \ -v ~/export/:/export \ -e ARGS="-vvv" -e CONFIG="/config/config.ini" \ elazkani/rundeck-resources
- Assumptions:
~/config/
holds theconfig.ini
configuration file.- The configuration is set to export to the
/export/
path. /export
will hold the resources exported file inside the container.~/export/
exists on the host.
Importers¶
rundeck-resources
currently offer the following importers:- Chef:
ChefImporter
- Chef:
Exporters¶
rundeck-resources
currently offers the following exporters:- YAML:
YAMLExporter
- YAML:
Contributors:¶
CLI¶
-
rundeck_resources.cli.
argument_parse
()[source]¶ Method to extract the arguments from the command line.
Return type: ArgumentParser
Returns: The argument parser.
-
rundeck_resources.cli.
export_resources
(interfaces, resources)[source]¶ Method to export the resources using the output interfaces.
Parameters: - interfaces (
list
) – The list of initialized output interfaces. - resources (
dict
) – The resources provided by the input interfaces.
Return type: None
- interfaces (
-
rundeck_resources.cli.
import_resources
(interfaces)[source]¶ Method to get all resources from the input interfaces.
Parameters: interfaces ( list
) – The list of initialized input interfaces.Return type: dict
Returns: The resources returned by the input interfaces.
-
rundeck_resources.cli.
initialize_export_interfaces
(config, plugins)[source]¶ Method to initialize the interfaces with the configuration.
Parameters: - config (
dict
) – The configuration file content. - plugins (
dict
) – The list of loaded plugins.
Return type: list
Returns: The list of loaded plugins initialized.
- config (
-
rundeck_resources.cli.
initialize_import_interfaces
(config, plugins, cache)[source]¶ Method to initialize the interfaces with the configuration.
Parameters: - config (
dict
) – The configuration file content. - plugins (
dict
) – The list of loaded plugins. - cache (
Cache
) – The cache system instance.
Return type: list
Returns: The list of loaded plugins initialized.
- config (
-
rundeck_resources.cli.
load_exporters
(config)[source]¶ Method to load the Exporters plugins configured in the configuration file.
Parameters: config – The configuration file content. Returns: The Exporters plugins, loaded.
Errors¶
-
exception
rundeck_resources.errors.
CacheNotFound
(message=None)[source]¶ Custom CacheNotFound exception. We raise this exception when no plugin cache have been found.
Logger¶
-
rundeck_resources.logger.
setup_logging
(default_path=None, default_level=40, env_key='LOG_CFG')[source]¶ Method that sets the logging system up.
Parameters: - default_path (
Optional
[str
]) – The path to the logger configuration. - default_level (
int
) – The default logging level (DEFAULT: ERROR) - env_key (
str
) – The environment variable specifying the path to the configuration file.
Return type: None
- default_path (
Cache¶
-
class
rundeck_resources.cache.
Cache
(config, no_cache)[source]¶ A cache module the plugins can take advantage of in case the APIs do not return data or the server is down.
-
cache
(plugin, resources)[source]¶ Method to cache plugin data.
Parameters: - plugin (
str
) – The plugin name to cache data for. - resources (
dict
) – The resources data to cache.
Return type: None
- plugin (
-
invalidate
(plugin)[source]¶ Method to invalidate a plugin cache file.
Parameters: plugin ( str
) – The plugin name to invalidate the cache file for.Return type: None
-
load_cache
(config)[source]¶ Method to search for all configured plugins cache files
Parameters: config ( dict
) – the configuration provided by config.read_config.Return type: dict
Returns: The cache configuration that includes paths to all plugin cache files.
-
Common¶
-
rundeck_resources.common.
check_file
(path)[source]¶ Method to normalize the path of a file and check if the file exists and is a file.
Parameters: path ( str
) – The file path to check.Return type: str
Returns: The absolute path of a file. Raises: FileNotFoundError
Config¶
Interfaces¶
Plugins¶
-
rundeck_resources.plugins.
get_plugins
(resource_types)[source]¶ Method to get the plugins defined in the entry_point.
Parameters: resource_types ( str
) – The resource type to get (Input, Output).Return type: dict
Returns: The entry points by name.
-
rundeck_resources.plugins.
load_plugins
(config, resource_types)[source]¶ Method to load plugins defined in the entry_point by resource_type.
Parameters: - config (
dict
) – The configuration file content. - resource_types (
str
) – The resource type to load (Input, Output).
Return type: dict
Returns: The plugins loaded.
- config (
Chef Importer¶
-
class
rundeck_resources.chef_importer.
ChefImporter
(title, config, cache)[source]¶ A Chef node information importer
-
static
call_chef
(config)[source]¶ Method to query the chef server.
Parameters: config ( dict
) – The chef configuration.Return type: dict
Returns: The chef nodes information.
-
static
expand_paths
(config)[source]¶ Method to expand file paths for the user certificate and the chef ssl certificate.
Parameters: config ( dict
) – The chef configuration.Return type: dict
Returns: The chef configuration with expanded paths.
-
static
expand_ssl_cert_path
(ssl_cert_path)[source]¶ Method to return expanded and checked ssl_cert_path.
Parameters: user_cert_path – The chef server SSL certificate path. Return type: str
Returns: The check expanded chef server SSL certificate path.
-
static
expand_user_cert_path
(user_cert_path)[source]¶ Method to return expanded and checked user_cert_path.
Parameters: user_cert_path ( str
) – The user certificate path.Return type: str
Returns: The check expanded user certificate path.
-
static
YAML Exporter¶
-
class
rundeck_resources.yaml_exporter.
YAMLExporter
(title, config={})[source]¶ The YAML rundeck exporter class