Interpolate Variable in Resource

asked 2014-09-15 13:36:06 -0500

Derongan gravatar image

updated 2014-09-17 11:40:00 -0500

I have a class that has a resource. This resource generates a variable. The parent class must pass in a string containing this variable, but has no access to the variable. Is there any way to pass the string in as a string, and then have the resource perform the string interpolation?

Relevant code:

class my_program
{
    some_resource
    { "Name":
        install_options=>[ "config_file=${install_options}/file.ini"],
        files_to_grab => ['setup','file.ini'],
    }
}

define special_package(install_options)
{
    $working_directory = create_temporary()    #create_temporary creates a directory in
                                               #the temp folder and returns its name.

    #Code here would grab the needed files and drops them in working directory

    package { $title:
        ensure => installed,
        source => "${working_directory}/setup",
        install_options => $install_options,  #In this specific case, install_options needs 
    }                                         #to reference the temporary directory. However
                                              #it is interpolated in the scope of my_program
                                              #and resolves to "config_file=/file.ini"
                                              #instead of "config_file=<TEMPDIR>/file.ini"
}
edit retag flag offensive close merge delete

Comments

1

Paste some code or no one can help you.

lavaman gravatar imagelavaman ( 2014-09-15 14:15:45 -0500 )edit

Added an example.

Derongan gravatar imageDerongan ( 2014-09-15 15:41:31 -0500 )edit

This example code is confusing, try making it a case of what you're actually trying to accomplish. However with what you have posted, I'm nearly certain the answer is no.

ramindk gravatar imageramindk ( 2014-09-16 15:38:28 -0500 )edit

I added more below the code. Hopefully I explained myself better there.

Derongan gravatar imageDerongan ( 2014-09-16 16:19:06 -0500 )edit

What are you trying achive? Don't really know what's the use case but you can use facter to get parameter from configuration file. I reckon you are doing something really top secret because this question is more a riddle ;)

3h4x gravatar image3h4x ( 2014-09-17 05:00:18 -0500 )edit