Chris Blumentritt
2009-Sep-17 19:19 UTC
[Puppet Users] cannot parse template when fact does not exist
I receive the following error when trying to do the puppet below: Failed to parse template s_apache_site/site.conf.erb: Could not find value for ''ipaddress_eth0_0'' As far as I can tell the ipaddress_eth0_0 fact has to exist on the client before it will parse. I was hoping that I could get the new ip address in place thus creating the fact so that when the apache site is created the information would be available. Maybe all facts are compiled at the when puppetd is run and there is no way to add facts during the run of puppetd? The way I see around this is to first add the ip address with out calling the apache::site definition and once the ip address gets on there run puppet with apache::site definition. There has got to be better way, any suggestions The reason I am doing this is I will have an arbitrary number of servers load balancing a site and since I can keep track of what interface a site is going to use I can use that to build my apache file. -------------- node definition snippet: ip_address::new{ "eth0:0": iface => "eth0:0", ip => "192.168.0.84", netmask => "255.255.255.0", gateway => "192.168.0.1", iface_type => "static", before => Apache2::Site["test.example.com"] } app_server class snippet: $ipalias = "ipaddress_eth0_0" apache2::site { "test.example.com": name => "test.example.com.conf", ensure => "present", require => Apache2::Config["base"], require => Ip_address::New["eth0:0"], content => template("s_apache_site/site.conf.erb"), notify => Exec["reload-apache2"] } erb snippet: <VirtualHost <%= eval(ipalias) -%>:80> ----------- Chris --~--~---------~--~----~------------~-------~--~----~ 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
David Schmitt
2009-Sep-18 07:54 UTC
[Puppet Users] Re: cannot parse template when fact does not exist
Chris Blumentritt wrote:> I receive the following error when trying to do the puppet below: > Failed to parse template s_apache_site/site.conf.erb: Could not find > value for ''ipaddress_eth0_0'' > > As far as I can tell the ipaddress_eth0_0 fact has to exist on the > client before it will parse. I was hoping that I could get the new ip > address in place thus creating the fact so that when the apache site is > created the information would be available. Maybe all facts are > compiled at the when puppetd is run and there is no way to add facts > during the run of puppetd?puppet sends all facts to the server at the beginning of each run to receive an updated configuration. The configuration is compiled (functions run, templates expanded) on the server before passing it on to the client. The latter only receives a list of resources which it dutifully applies. Therefore it is impossible to "create" facts on the fly: the client doesn''t have enough information to re-compile its manifests. This is one of the few cases (enabling providers is another major one) where you have to defer some resources until the next run, where you have the facts available.> The way I see around this is to first add the ip address with out > calling the apache::site definition and once the ip address gets on > there run puppet with apache::site definition. There has got to be > better way, any suggestionsIf you really want to avoid the second run, you can refactor your manifest so you are not using a fact in you template, but directly the configuration information: node web1{ $secondary_ip = xxx network::ip { $secondary_ip: } apache::site { blah: ip => $secondary_ip } } 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
Chris Blumentritt
2009-Sep-21 14:54 UTC
[Puppet Users] Re: cannot parse template when fact does not exist
On Fri, Sep 18, 2009 at 2:54 AM, David Schmitt <david@dasz.at> wrote:> > Chris Blumentritt wrote: > > I receive the following error when trying to do the puppet below: > > Failed to parse template s_apache_site/site.conf.erb: Could not find > > value for ''ipaddress_eth0_0'' > > > > As far as I can tell the ipaddress_eth0_0 fact has to exist on the > > client before it will parse. I was hoping that I could get the new ip > > address in place thus creating the fact so that when the apache site is > > created the information would be available. Maybe all facts are > > compiled at the when puppetd is run and there is no way to add facts > > during the run of puppetd? > > puppet sends all facts to the server at the beginning of each run to > receive an updated configuration. The configuration is compiled > (functions run, templates expanded) on the server before passing it on > to the client. The latter only receives a list of resources which it > dutifully applies. > > Therefore it is impossible to "create" facts on the fly: the client > doesn''t have enough information to re-compile its manifests. > > This is one of the few cases (enabling providers is another major one) > where you have to defer some resources until the next run, where you > have the facts available. > > > The way I see around this is to first add the ip address with out > > calling the apache::site definition and once the ip address gets on > > there run puppet with apache::site definition. There has got to be > > better way, any suggestions > > If you really want to avoid the second run, you can refactor your > manifest so you are not using a fact in you template, but directly the > configuration information: > > > 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.> > > 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
David Schmitt
2009-Sep-21 15:03 UTC
[Puppet Users] Re: cannot parse template when fact does not exist
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. 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
Chris Blumentritt
2009-Sep-21 15:26 UTC
[Puppet Users] Re: cannot parse template when fact does not exist
On Mon, Sep 21, 2009 at 10:03 AM, David Schmitt <david@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>> > > 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
David Schmitt
2009-Sep-21 16:26 UTC
[Puppet Users] Re: cannot parse template when fact does not exist
Chris Blumentritt wrote:> > > On Mon, Sep 21, 2009 at 10:03 AM, David Schmitt <david@dasz.at > <mailto:david@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. 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
David Schmitt
2009-Sep-21 16:27 UTC
[Puppet Users] Re: cannot parse template when fact does not exist
Chris Blumentritt wrote:> > > On Mon, Sep 21, 2009 at 10:03 AM, David Schmitt <david@dasz.at > <mailto:david@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. 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
Chris Blumentritt
2009-Sep-21 17:19 UTC
[Puppet Users] Re: cannot parse template when fact does not exist
On Mon, Sep 21, 2009 at 11:27 AM, David Schmitt <david@dasz.at> wrote:> > Chris Blumentritt wrote: > > > > > > On Mon, Sep 21, 2009 at 10:03 AM, David Schmitt <david@dasz.at > > <mailto:david@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. 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
David Bishop
2009-Sep-21 17:38 UTC
[Puppet Users] Re: cannot parse template when fact does not exist
On Mon, Sep 21, 2009 at 12:19:39PM -0500, Chris Blumentritt wrote:> 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. > ChrisI''m having a very similar problem. I have a couple custom facts, set in a ''custom'' module (as per the latest wiki docs), that I use in a couple different modules (more coming). However, it doesn''t seem to download the ''custom'' module (thus inserting the facts) before the modules that depend on it. Commenting out the two templates, letting puppet run, then uncommenting them works, but is obviously not the solution. Without uncommenting them, compiling the template fails, so compiling the catalog fails, so the custom module is never pushed and I''m caught in a catch-22... In short, how do you declare one module dependent on another, to the extent that the first needs to be "run" first? David
David Bishop
2009-Sep-21 18:58 UTC
[Puppet Users] Re: cannot parse template when fact does not exist
Never mind. Figured out those clients didn''t have the proper ''pluginsync'' lines in puppet.conf. David Bishop On Sep 21, 2009, at 1:38 PM, David Bishop <david@gnuconsulting.com> wrote:> On Mon, Sep 21, 2009 at 12:19:39PM -0500, Chris Blumentritt wrote: >> 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 ap >> ache conf >> file for site is there. �I have been banging my head on a wall w >> ith this >> one. �I have been dropping notice functions all over the place t >> o 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 i >> s x.x.x.x >> notice: Scope(S_project[my_project-env]):�project network interf >> ace is >> I guess I am running into a scope issue or something. �I have al >> so 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 c >> an do >> different. >> Chris > > I''m having a very similar problem. I have a couple custom facts, set > in a ''custom'' module (as per the latest wiki docs), that I use in a > couple different modules (more coming). However, it doesn''t seem to > download the ''custom'' module (thus inserting the facts) before the > modules that depend on it. Commenting out the two templates, letting > puppet run, then uncommenting them works, but is obviously not the > solution. Without uncommenting them, compiling the template fails, so > compiling the catalog fails, so the custom module is never pushed and > I''m caught in a catch-22... > > In short, how do you declare one module dependent on another, to the > extent that the first needs to be "run" first? > > David--~--~---------~--~----~------------~-------~--~----~ 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
Chris Blumentritt
2009-Sep-21 19:53 UTC
[Puppet Users] Re: cannot parse template when fact does not exist
On Mon, Sep 21, 2009 at 12:19 PM, Chris Blumentritt <cblument@gmail.com>wrote:> > > On Mon, Sep 21, 2009 at 11:27 AM, David Schmitt <david@dasz.at> wrote: > >> >> Chris Blumentritt wrote: >> > >> > >> > On Mon, Sep 21, 2009 at 10:03 AM, David Schmitt <david@dasz.at >> > <mailto:david@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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---