On Mon, Sep 21, 2009 at 12:19 PM, Chris Blumentritt <cblum...@gmail.com>wrote:
> > > On Mon, Sep 21, 2009 at 11:27 AM, David Schmitt <da...@dasz.at> wrote: > >> >> Chris Blumentritt wrote: >> > >> > >> > On Mon, Sep 21, 2009 at 10:03 AM, David Schmitt <da...@dasz.at >> > <mailto:da...@dasz.at>> wrote: >> > >> > >> > Chris Blumentritt wrote: >> > > node web1{ >> > > $secondary_ip = xxx >> > > >> > > network::ip { $secondary_ip: } >> > > apache::site { blah: ip => $secondary_ip } >> > > } >> > > >> > > >> > > How can I access the $secondary_ip variable from a class? I have >> the >> > > app_server class make the same site on more than one server and I >> > do not >> > > think I can more than once in the node. Besides, defining the >> > same site >> > > more than one time seems bad. >> > >> > >> > The variables propagate through the included classes. That way you >> can >> > use $secodary_ip everywhere. >> > >> > >> > I thought that would be the case but it does not seem to be working. I >> > dropped some notices to print the ip address in the log of the puppet >> > master and it is not printing anything. I had to take it a step further >> > where I set another variable = to the secondary ip address so that I >> > could use the same erb file for multiple projects. So I have it looking >> > like this >> > >> > node "app1" { >> > $secondary_ip = "x.x.x.x" >> > } >> > >> > class my_project::project_env { >> > create_project { $project_fqdn: >> > name => $project_name, >> > project_network_interface => $secondary_ip >> > } >> > } >> > >> > snip from erb: >> > >> > <VirtualHost <%= project_network_interface -%>:80> >> > >> > My apache conf ends up with this: >> > >> > <VirtualHost :80> >> >> >> Looks very good, but you also need to include my_project::project_env >> after defining the secondary_ip in the node. >> > I have a separate class that includes the my_project::project_env for all > of my app servers. I can verify that it is working since the apache conf > file for site is there. I have been banging my head on a wall with this > one. I have been dropping notice functions all over the place to figure out > what is going on. > > In my create_project define I have added the following notices: > > notice("secondary ip address is ${secondary_ip}") > notice("project network interface is ${project_network_interface}") > > and get the following output on the server: > > notice: Scope(S_project[my_project-env]): secondary ip address is x.x.x.x > notice: Scope(S_project[my_project-env]): project network interface is > > I guess I am running into a scope issue or something. I have also tried to > move the assignment of project_network_interface in front of the "call" to > the create_project define. > > Does the behavior I am seeing make sense? I don't know what I can do > different. > Ok, the solution here is to define my ip address variables before I do my includes in the node. This is a bit annoying since I wanted to keep the definition of the variable together with my module that sets up the ip address on the server but at last it is working. Chris > > >> >> Regards, DavidS >> >> >> >> > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---