to_resource

Type conversion functions for string representations of resources

Puppet Labs TSE Team

tse

7,415 downloads

7,316 latest version

4.5 quality score

Version information

  • 0.1.2 (latest)
  • 0.1.0
released Dec 18th 2015
This version is compatible with:
  • Puppet Enterprise >=2015.2.0
  • Puppet >=4.2.1

Start using this module

Documentation

tse/to_resource — version 0.1.2 Dec 18th 2015

to_resource

This module provides two functions designed to assist with importing data that represents Puppet resource types from external sources (or Hiera). This can be specifically useful when trying to import application instance declarations, which are required to specify the nodes parameter, which must be an array of Node resource references.

Functions

to_resource

Accepts a string parameter. Transforms it to a resource reference if the string can be represented as a resource.

resolve_resources

Accepts either a String, Array, or Hash parameter. Recursively transforms all transformable String sub-elements into resource type representations.

Examples

Convert a single string to a resource reference:

$res = "Notify[foo]".to_resource

Convert an array of strings to a resource reference:

$res_arr = ["Notify[foo]", "Anchor[bar]"].resolve_resources

Look up a value and transform any valid string-form resource references it contains to Resource type represenations:

$app_instances = lookup("applications").resolve_resources