Re: [Puppet Users] Conditional with variable from facter
The :: refer to scope, in this case it's saying variables at the very top scope of what puppet knows about. This is because you can have: $::operatingsystem $module::class::operatingsystem And it's not sure which one you mean. By adding the :: you're making sure it knows to check the fact and not something you might have set in a specific class. On Wed, Jun 20, 2012 at 4:22 PM, Jakov Sosic jso...@srce.hr wrote: On 06/18/2012 03:25 PM, Jakov Sosic wrote: Hi. I have the following facts available: # facter | grep oper operatingsystem = CentOS operatingsystemrelease = 6.2 Now, if I wish to use conditionals on these facts, I have to do it like this: case $operatingsystem {} case $::operatingsystemrelease {} I'm puzzled as to why can't I just use $operatingsystemrelease, and what do these two semicolons mean? Any ideas?! :) Anyone?!?! -- 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. -- 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.
Re: [Puppet Users] Conditional with variable from facter
With in the class I used something like this to get the facts into my nagios templates: define host($ip = $::fqdn, $short_alias = $::fqdn, $hostgroup = $::product_info, $product_domain = $::product_domain) { case $product_info { /OneProduct/: { $nagios_cfgdir = /usr/local/nagios/etc/objects/OneProduct/hosts @@file { $nagios_cfgdir/${name}.cfg: ignore = .svn, ensure = present, content = template( nagios/OneProduct_host.cfg ), mode = 644, owner = nagios, group = nagios, tag = 'nagios', notify = Service[nagios], } } /YetAnotherProduct/: { $nagios_cfgdir = /usr/local/nagios/etc/objects/YetAnotherProduct/hosts @@file { $nagios_cfgdir/${name}.cfg: ignore = .svn, ensure = present, content = template( nagios/YetAnotherProduct_host.cfg ), mode = 644, owner = nagios, group = nagios, tag = 'nagios', notify = Service[nagios], recurse = true, replace = true, } I hope this helps;) On Wed, Jun 20, 2012 at 1:57 PM, Jeff McCune j...@puppetlabs.com wrote: On Wed, Jun 20, 2012 at 1:22 PM, Jakov Sosic jso...@srce.hr wrote: I'm puzzled as to why can't I just use $operatingsystemrelease, and what do these two semicolons mean? Any ideas?! :) Anyone?!?! http://docs.puppetlabs.com/guides/scope_and_puppet.html -Jeff -- 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. -- David Garvey -- 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.
Re: [Puppet Users] Conditional with variable from facter
I also use some other stuff in my nagios.pp to get puppet facts into mcollective. file { /usr/lib/nagios/.mcollective/etc/facts.yaml: mode= 0644, owner = 104, group = 106, loglevel = debug, content = inline_template(%= scope.to_hash.reject { |k,v| k.to_s =~ /(uptime_seconds|timestamp|free)/ }.to_yaml %) } On Wed, Jun 20, 2012 at 4:30 PM, david.gar...@gmail.com david.gar...@gmail.com wrote: With in the class I used something like this to get the facts into my nagios templates: define host($ip = $::fqdn, $short_alias = $::fqdn, $hostgroup = $::product_info, $product_domain = $::product_domain) { case $product_info { /OneProduct/: { $nagios_cfgdir = /usr/local/nagios/etc/objects/OneProduct/hosts @@file { $nagios_cfgdir/${name}.cfg: ignore = .svn, ensure = present, content = template( nagios/OneProduct_host.cfg ), mode = 644, owner = nagios, group = nagios, tag = 'nagios', notify = Service[nagios], } } /YetAnotherProduct/: { $nagios_cfgdir = /usr/local/nagios/etc/objects/YetAnotherProduct/hosts @@file { $nagios_cfgdir/${name}.cfg: ignore = .svn, ensure = present, content = template( nagios/YetAnotherProduct_host.cfg ), mode = 644, owner = nagios, group = nagios, tag = 'nagios', notify = Service[nagios], recurse = true, replace = true, } I hope this helps;) On Wed, Jun 20, 2012 at 1:57 PM, Jeff McCune j...@puppetlabs.com wrote: On Wed, Jun 20, 2012 at 1:22 PM, Jakov Sosic jso...@srce.hr wrote: I'm puzzled as to why can't I just use $operatingsystemrelease, and what do these two semicolons mean? Any ideas?! :) Anyone?!?! http://docs.puppetlabs.com/guides/scope_and_puppet.html -Jeff -- 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. -- David Garvey -- David Garvey -- 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.
[Puppet Users] Conditional with variable from facter
Hi. I have the following facts available: # facter | grep oper operatingsystem = CentOS operatingsystemrelease = 6.2 Now, if I wish to use conditionals on these facts, I have to do it like this: case $operatingsystem {} case $::operatingsystemrelease {} I'm puzzled as to why can't I just use $operatingsystemrelease, and what do these two semicolons mean? Thank you. -- 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.
Re: [Puppet Users] Conditional with variable from facter
Hi Jakov, the two semicolons locate these variables as being in top-scope/variables outside of any specific module. otherwise it might be $modulename::variable Does that help at all? W On Jun 18, 2012, at 8:25 AM, Jakov Sosic wrote: Hi. I have the following facts available: # facter | grep oper operatingsystem = CentOS operatingsystemrelease = 6.2 Now, if I wish to use conditionals on these facts, I have to do it like this: case $operatingsystem {} case $::operatingsystemrelease {} I'm puzzled as to why can't I just use $operatingsystemrelease, and what do these two semicolons mean? Thank you. -- 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. This message may contain confidential or privileged information. If you are not the intended recipient, please advise us immediately and delete this message. See http://www.datapipe.com/legal/email_disclaimer/ for further information on confidentiality and the risks of non-secure electronic communication. If you cannot access these links, please notify us by reply message and we will send the contents to you. -- 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.
Re: [Puppet Users] Conditional with variable from facter
Hi, On 18.06.2012, at 17:14, Wolf Noble wrote: Hi Jakov, the two semicolons locate these variables as being in top-scope/variables outside of any specific module. please note that these are colons (:) no semicolons(;). otherwise it might be $modulename::variable Does that help at all? W On Jun 18, 2012, at 8:25 AM, Jakov Sosic wrote: Hi. I have the following facts available: # facter | grep oper operatingsystem = CentOS operatingsystemrelease = 6.2 Now, if I wish to use conditionals on these facts, I have to do it like this: case $operatingsystem {} case $::operatingsystemrelease {} I'm puzzled as to why can't I just use $operatingsystemrelease, and what do these two semicolons mean? You could use $::operatingsystem only. But you want to be sure that you also refer to CentOS. I assume you want to net these two case conditionals: case $::operatingsystem { 'CentOS': ( case $::operatingsystemrelease { '5.0': { ... } '6.2': { ... } default: { ... } } 'Debian': { ... } default: { ... } } Also take a look on the documentation: http://docs.puppetlabs.com/guides/language_guide.html#conditionals - Martin -- 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.
Re: [Puppet Users] Conditional with variable from facter
D'oh On Jun 18, 2012, at 11:26 AM, Martin Alfke wrote: Hi, On 18.06.2012, at 17:14, Wolf Noble wrote: Hi Jakov, the two semicolons locate these variables as being in top-scope/variables outside of any specific module. please note that these are colons (:) no semicolons(;). I will not respond to lists before coffee I will not respond to lists before coffee I will not respond to lists before coffee ... This message may contain confidential or privileged information. If you are not the intended recipient, please advise us immediately and delete this message. See http://www.datapipe.com/legal/email_disclaimer/ for further information on confidentiality and the risks of non-secure electronic communication. If you cannot access these links, please notify us by reply message and we will send the contents to you. -- 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.