JGonza1
2012-Dec-27 23:12 UTC
[Puppet Users] Trying to use a facter information in manifest.
I am trying to use information that facter gathers on the agent server in the manifest. I am trying to use "domain => dev.com" depending on what domain is I deploy the file. I ran the manifest and it did not give me an error but it did not fdeploy the file. My code is below. In my files directory for this manifest I have these files aliases submit.cf.dev.com submit.cf.test.com MY init.pp file is the one below class sendmailnew { exec { "mail": command => "/usr/bin/yum -y install sendmail", } exec { "restart": command => "/etc/init.d/sendmail restart", } file { "/etc/mail/aliases": ensure => file, source => "puppet:///sendmailnew/aliases", owner => root, group => root, mode => 644; } exec { "mailaliases": command => "/usr/bin/newaliases", } } class submitcf ($domain) { file { submit: path => $domain ? { default => "/etc/mail/submit.cf", }, ensure => file, owner => root, group => root, mode => 644, source => "puppet:///sendmailnew/submit.cf.$domain"; } } -- 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/-/_jEyytVTYGUJ. 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.
Luke Bigum
2012-Dec-28 09:48 UTC
[Puppet Users] Re: Trying to use a facter information in manifest.
On Thursday, December 27, 2012 11:12:36 PM UTC, JGonza1 wrote:> I am trying to use information that facter gathers on the agent server in > the manifest. I am trying to use "domain => dev.com" depending on what > domain is I deploy the file. I ran the manifest and it did not give me an > error but it did not fdeploy the file. My code is below. > In my files directory for this manifest I have these files > aliases > submit.cf.dev.com > submit.cf.test.com > >What you''re trying to do is sensible. The first thing I do with these sorts of problems is work backwards from the Agent - is the Agent trying to manage this resource? The last run should store a list of classes and resources in these files: $ grep submit /var/lib/puppet/state/resources.txt $ grep submitcf /var/lib/puppet/state/classes.txt Or you can run the Agent with --evaltrace and it will print out each resource it tries to manage - check if submit.cf scrolls past: $ puppet agent --test --evaltrace If submit.cf is not there, then the Puppet Master does not think that your node should be managing those resources and the problem is in manifest compilation. Make sure this node''s definition is declaring the correct submitcf classes. If you want to, you can run a catalog compilation in debug mode. It won''t help you with this specific problem but it''s useful to know: $ puppet master --compile <node name> --debug This can be a bit complicated to read as you''ll get a deluge of debug messages while the catalog is being compiled, then a big dump of JSON which is the catalog itself. Lastly, I would rewrite your classes below like this: class sendmailnew { package { "sendmail": ensure => installed, notify => Service["sendmail"], } service { "sendmail": ensure => running, enable => true, has_restart => true, has_status => true, require => [ Package["sendmail"], File["/etc/mail/submit.cf"], ], } file { "/etc/mail/aliases": ensure => file, source => "puppet:///modules/sendmailnew/aliases", owner => root, group => root, mode => 644; notify => Exec["mailaliases"], } exec { "mailaliases": command => "/usr/bin/newaliases", refreshonly => true, notify => Service["sendmail"], } file { "/etc/mail/submit.cf", ensure => file, owner => root, group => root, mode => 644, source => "puppet:///modules/sendmailnew/submit.cf.$domain"; require => Package["sendmail"], notify => Service["sendmail"], } } Have a look at the differences and if you have any questions, please ask. HTH, -Luke MY init.pp file is the one below> class sendmailnew { > exec { "mail": > command => "/usr/bin/yum -y install sendmail", > } > exec { "restart": > command => "/etc/init.d/sendmail restart", > } > file { > "/etc/mail/aliases": > ensure => file, > source => "puppet:///sendmailnew/aliases", > owner => root, > group => root, > mode => 644; > } > exec { "mailaliases": > command => "/usr/bin/newaliases", > } > } > class submitcf ($domain) { > file { submit: > path => $domain ? { > default => "/etc/mail/submit.cf", > }, > ensure => file, > owner => root, > group => root, > mode => 644, > source => "puppet:///sendmailnew/submit.cf.$domain"; > } > } >-- 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/-/LE80H2uHAOQJ. 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.
Keiran Sweet
2012-Dec-28 10:07 UTC
[Puppet Users] Re: Trying to use a facter information in manifest.
Hi There, Luke beat me to the punch, but I''d already typed this up so I figured I''d send it anyway. You are going about some of these tasks the wrong way a little, and you should probably have a read of the following: * Learning Puppet - http://docs.puppetlabs.com/learning/index.html * Pro Puppet - James Turnbull & Jeffrey McCune * The Puppet cookbook - http://puppetcookbook.com/ * Puppet modules fundamentals - http://docs.puppetlabs.com/puppet/2.7/reference/modules_fundamentals.html Using the package -> config -> service approach, your puppet code should be similar to the following in your module. class sendmailnew { package { sendmail : ensure => installed, } file { "/etc/mail/aliases": ensure => file, source => "puppet:///sendmailnew/aliases", owner => root, group => root, mode => 644, notify => Exec[mailaliases], } exec { ''mailaliases'': command => ''/usr/bin/newaliases'', } file { ''/etc/mail/submit.cf'' : ensure => file, owner => root, group => root, mode => 644, source => [ "puppet:///sendmailnew/submit.cf.${::domain}", ''puppet:///sendmailnew/submit.cf'', ], notify => Service[sendmail], } service { sendmail : ensure => running, enable => true, require => [ Package[sendmail] , File[''/etc/mail/submit.cf''] ], } } Once you have setup your module, you need to apply the module''s classes to the node in question. This can be done in your site.pp file similar to the following: node ''servername'' { include sendmailnew } I hope this helps. K On Thursday, December 27, 2012 11:12:36 PM UTC, JGonza1 wrote:> > I am trying to use information that facter gathers on the agent server in > the manifest. I am trying to use "domain => dev.com" depending on what > domain is I deploy the file. I ran the manifest and it did not give me an > error but it did not fdeploy the file. My code is below. > In my files directory for this manifest I have these files > aliases > submit.cf.dev.com > submit.cf.test.com > > MY init.pp file is the one below > class sendmailnew { > exec { "mail": > command => "/usr/bin/yum -y install sendmail", > } > exec { "restart": > command => "/etc/init.d/sendmail restart", > } > file { > "/etc/mail/aliases": > ensure => file, > source => "puppet:///sendmailnew/aliases", > owner => root, > group => root, > mode => 644; > } > exec { "mailaliases": > command => "/usr/bin/newaliases", > } > } > class submitcf ($domain) { > file { submit: > path => $domain ? { > default => "/etc/mail/submit.cf", > }, > ensure => file, > owner => root, > group => root, > mode => 644, > source => "puppet:///sendmailnew/submit.cf.$domain"; > } > } >-- 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/-/l0USlu4noMkJ. 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.