Ask Your Question

change the variable value after copying the file from master to agent

asked 2015-06-18 05:40:37 -0600

Himanshu Dubey gravatar image

updated 2015-06-18 11:38:43 -0600

GregLarkin gravatar image

Hi All, I am just starting with Puppet and stuck at one point [ still reading the online documents :) ] So here is what I am not able to achieve and need help or guidance.

Using below resource, I am able to copy my file from master to agent.

class apache_config ($ip = $ipaddress ,$vname = cloud1)
file    { 'vhost.conf':
        path    => '/etc/httpd/conf/vhosts_conf/apache_Vhost.conf',
        ensure  => file,
        source  => "puppet://$puppetmaster/modules/test_apache_config/apache_Vhost.conf",
        owner  => "apache",
        group  => "apache",
        mode   => "0644",
        notify => Service["httpd"],

Now, below is the content of my file , which I am transferring from Master to Agent.

<VirtualHost $ip:80>
    ServerName  $
    ServerAlias www.$

How or what else to implement in my class so that values can automatically be changes for $ip and $vname . Thanks in advance.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-06-18 15:57:47 -0600

GregLarkin gravatar image

All you need to do is switch from using a static file with the "source" attribute to a .erb template using the "content" attribute in your file resource. Have a look at and you'll see exactly how to do it.

edit flag offensive delete link more


Thanks for the guidance. After I start using erb templates, getting some parsing error. If you can help, would be great. thanks in advance.

Himanshu Dubey gravatar imageHimanshu Dubey ( 2015-06-23 04:35:12 -0600 )edit

Looks like someone else answered your questions - glad you got it working.

GregLarkin gravatar imageGregLarkin ( 2015-06-23 11:22:11 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-06-18 05:40:37 -0600

Seen: 58 times

Last updated: Jun 18 '15