red
2012-Aug-01 21:47 UTC
[Puppet Users] Can an template (erb file) get installed via a package resource?
Hello all, I am new to puppet and I am try to come up with a proof of concept for setting up a DNS server. I think I can just get by with just running puppet directly on my host without setting up a master/agent type configuration. This maybe related to the my problem but I suspect not. Here''s the problem I am having: When I run ... [root@agent1 bind]# puppet apply init.pp ... I get this error ... No such file or directory - /apps/DNS/puppet_template/rpz.localdomain.db.erb at /root/bind/init.pp:38 on node agent1.localdomain The file /apps/DNS/puppet_template/rpz.localdomain.db.erb should get installed from the RPM I created, rie-rpz-named-conf. This RPM is accessible via YUM on the host agent1 ... [root@agent1 bind]# yum list rie-rpz-named-conf ... Available Packages rie-rpz-named-conf.noarch 0.1-1 RIE-repository ... rie-rpz-named-conf.noarch contains the file /apps/DNS/puppet_template/rpz.localdomain.db.erb [root@agent1 rie-rpz-named-conf]# rpm -q --filesbypkg -p rie-rpz-named-conf-0.1-1.noarch.rpm rie-rpz-named-conf /apps/DNS/README rie-rpz-named-conf /apps/DNS/conf/named.conf rie-rpz-named-conf /apps/DNS/etc/rndc.conf rie-rpz-named-conf /apps/DNS/puppet_template/rpz.localdomain.db.erb rie-rpz-named-conf /etc/init.d/named My puppet file, init.pp, looks like this ... [root@agent1 bind]# cat init.pp class rie-bind ( $dns_type, $enable = true, $ensure = running) { case $dns_type { RPZ : { package { ''bind'': ensure => installed, before => Package [''rie-rpz-named-conf''], } package { ''rie-rpz-named-conf'': ensure => installed, before => File [''/apps/DNS/puppet_template/rpz.localdomain.db.erb''], } file { ''/apps/DNS/puppet_template/rpz.localdomain.db.erb'': ensure => file, } file { ''/apps/DNS/named/rpz.localdomain.db'': ensure => file, source => template("/apps/DNS/puppet_template/rpz.localdomain.db.erb"), } service { ''named'': name => $service_name, ensure => $ensure, enable => $enable, } } } } # for testing class { ''rie-bind'' : dns_type => ''RPZ'', } ... so my question is, "Why doesn''t my RPM, rie-rpz-named-conf, get install "BEFORE" the file resource File [''/apps/DNS/puppet_template/rpz.localdomain.db.erb'']? Here is some additional info that maybe useful: [root@agent1 bind]# puppet --version 2.7.12 (Puppet Enterprise 2.5.1) Thank you from an enthusiastic puppet newbie! -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/APquy4sBPOUJ. 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.
Calvin Walton
2012-Aug-01 22:52 UTC
Re: [Puppet Users] Can an template (erb file) get installed via a package resource?
On Wed, 2012-08-01 at 14:47 -0700, red wrote:> Hello all, > > I am new to puppet and I am try to come up with a proof of concept for > setting up a DNS server. > I think I can just get by with just running puppet directly on my > host without setting up a master/agent type configuration. > This maybe related to the my problem but I suspect not. > > Here''s the problem I am having: > > When I run ... > > [root@agent1 bind]# puppet apply init.pp > > ... I get this error ... > > No such file or directory - > /apps/DNS/puppet_template/rpz.localdomain.db.erb at /root/bind/init.pp:38 > on node agent1.localdomain > > The file /apps/DNS/puppet_template/rpz.localdomain.db.erb should get > installed from the RPM I created, rie-rpz-named-conf.The reason that this is failing is indirectly a result of the fact that puppet is designed to run in a master/agent configuration. First, take a look at the graphs at http://docs.puppetlabs.com/learning/agent_master_basic.html#what-do-agents-do-and-what-do-masters-do The "templates" functionality is designed for having a set of templates stored in the puppet directory on the master. As a result, the templates are evaluated in the "Compile" step, which runs on the puppet master - since the agent can''t see them! The RPM for your package isn''t installed until much later; in the Apply step which runs on the puppet agent. Naturally, it never gets there because the "Compile" step failed. Since the erb template files contain a bunch of puppet-specific ruby code in them, it usually doesn''t make sense to have them separate from your puppet ''.pp'' files.> [root@agent1 rie-rpz-named-conf]# rpm -q --filesbypkg -p > rie-rpz-named-conf-0.1-1.noarch.rpm > rie-rpz-named-conf /apps/DNS/README > rie-rpz-named-conf /apps/DNS/conf/named.conf > rie-rpz-named-conf /apps/DNS/etc/rndc.conf > rie-rpz-named-conf /apps/DNS/puppet_template/rpz.localdomain.db.erb > rie-rpz-named-conf /etc/init.d/namedFor this case, it might make sense to not have a package at all, but instead simply have puppet put the files in place directly with ''file'' resources. You can then keep these config files together with the puppet file, in a git repository for example. It would make sense to bundle everything together into a puppet "module", even if you aren''t using a master/agent setup. Read through http://docs.puppetlabs.com/learning/modules1.html#modules to find out how this works. -- Calvin Walton <calvin.walton@kepstin.ca> -- 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.
red
2012-Aug-02 04:43 UTC
Re: [Puppet Users] Can an template (erb file) get installed via a package resource?
Thank you Calvin. I will give that a try. On Wednesday, August 1, 2012 3:52:02 PM UTC-7, Calvin Walton wrote:> > On Wed, 2012-08-01 at 14:47 -0700, red wrote: > > Hello all, > > > > I am new to puppet and I am try to come up with a proof of concept for > > setting up a DNS server. > > I think I can just get by with just running puppet directly on my > > host without setting up a master/agent type configuration. > > This maybe related to the my problem but I suspect not. > > > > Here''s the problem I am having: > > > > When I run ... > > > > [root@agent1 bind]# puppet apply init.pp > > > > ... I get this error ... > > > > No such file or directory - > > /apps/DNS/puppet_template/rpz.localdomain.db.erb at > /root/bind/init.pp:38 > > on node agent1.localdomain > > > > The file /apps/DNS/puppet_template/rpz.localdomain.db.erb should get > > installed from the RPM I created, rie-rpz-named-conf. > > The reason that this is failing is indirectly a result of the fact that > puppet is designed to run in a master/agent configuration. First, take a > look at the graphs at > > http://docs.puppetlabs.com/learning/agent_master_basic.html#what-do-agents-do-and-what-do-masters-do > > The "templates" functionality is designed for having a set of templates > stored in the puppet directory on the master. As a result, the templates > are evaluated in the "Compile" step, which runs on the puppet master - > since the agent can''t see them! > > The RPM for your package isn''t installed until much later; in the Apply > step which runs on the puppet agent. Naturally, it never gets there > because the "Compile" step failed. > > Since the erb template files contain a bunch of puppet-specific ruby > code in them, it usually doesn''t make sense to have them separate from > your puppet ''.pp'' files. > > > [root@agent1 rie-rpz-named-conf]# rpm -q --filesbypkg -p > > rie-rpz-named-conf-0.1-1.noarch.rpm > > rie-rpz-named-conf /apps/DNS/README > > rie-rpz-named-conf /apps/DNS/conf/named.conf > > rie-rpz-named-conf /apps/DNS/etc/rndc.conf > > rie-rpz-named-conf > /apps/DNS/puppet_template/rpz.localdomain.db.erb > > rie-rpz-named-conf /etc/init.d/named > > For this case, it might make sense to not have a package at all, but > instead simply have puppet put the files in place directly with ''file'' > resources. You can then keep these config files together with the puppet > file, in a git repository for example. > > It would make sense to bundle everything together into a puppet > "module", even if you aren''t using a master/agent setup. Read through > http://docs.puppetlabs.com/learning/modules1.html#modules to find out > how this works. > > -- > Calvin Walton > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/8K7vW8cvQ1YJ. 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.