Puppet fill templates with ip addresses of newly spawned instances

2k Views Asked by At

I'm setting up a simple WSO2 Application Server cluster with one master node and one worker node. This is done via spawning instances in OpenStack cloud via python NovaClient API.

After spawning instances I need to get their ip addresses and use them to fill my template values. But to copy template values, the instances must be up and running.

I did this successfully with xml configuration file with a combination of suspending and resuming instances. The xml file contained all the variable values required to fill the puppet templates.

Now I have to try it without xml configuration and by using puppet configuration files only. My configuration information should be inside puppet files.

I have a module called appserver inside /etc/puppet/modules/

What should be my approach?

Should I keep my cluster configuration inside nodes.pp file itself? If so how do I import the configuration to site.pp?

Or should I keep my config information in params.pp file in /modules/appserver/manifests location?

Please be kind enough to guide through this scenario.

current site.pp file in /etc/puppet/manifests

import 'appserver'
node 'appserver-mgr' {
    include appserver::config_mgr
}

node 'appserver-wkr' {
    include appserver::config_wkr
}

inside /etc/puppet/modules/appserver/manifests/ I have two configuration files config_mgr.pp config_wkr.pp

I have not used init.pp.

Thanks, Suhan

1

There are 1 best solutions below

0
On

Think about template in puppet.

The setting should be in config_mgr.pp or config_wkr.pp to content => template("PATH/some.xml.erb")

in erb file, put <%= @ipaddress %> to get the IP address.

refer: https://docs.puppetlabs.com/guides/templating.html