Ask Your Question
0

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

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

Himanshu Dubey gravatar image

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

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  $vname.example.com
    ServerAlias www.$vname.example.com
</VirtualHost>

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
1

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

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 https://docs.puppetlabs.com/guides/templating.html and you'll see exactly how to do it.

edit flag offensive delete link more

Comments

Thanks for the guidance. After I start using erb templates, getting some parsing error. http://ask.puppetlabs.com/question/18034/error-400-on-server-failed-to-parse-template/ If you can help, would be great. thanks in advance.

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

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

GregLarkin gravatar imageGregLarkin ( 2015-06-23 11:22:11 -0500 )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

Stats

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

Seen: 50 times

Last updated: Jun 18 '15