Module class parameter override question

210 views
Skip to first unread message

Ugo Bellavance

unread,
Dec 7, 2012, 11:49:19 AM12/7/12
to puppet...@googlegroups.com
Hi,

I am experimenting with foreman's apache module and there is this class here:

class apache::service {
  $http_service = $::operatingsystem ? {
    /(Debian|Ubuntu)/ => 'apache2',
    default           => 'httpd',
  }

  service { $http_service:
    ensure     => running,
    enable     => true,
    hasstatus  => true,
    hasrestart => true,
    alias      => 'httpd',
    subscribe  => Package['httpd']
  }

  exec { 'reload-apache':
    command     => "/etc/init.d/${http_service} reload",
    onlyif      => '/usr/sbin/apachectl -t',
    require     => Service['httpd'],
    refreshonly => true,
  }

}

I want to apply this class to a specific host, but I want to override the enable parameter so that it is false.

I tried this:

node 'server1' {
  class { 'apache::service':
      enable  => false,}
}

But I always get this error:

Could not retrieve catalog from remote server: Error 400 on SERVER: Invalid parameter enable at /etc/puppet/manifests/nodes/nodes.pp:40

Any help would be appreciated.

Thanks,

Ugo

Ugo Bellavance

unread,
Dec 7, 2012, 2:37:20 PM12/7/12
to puppet...@googlegroups.com
I realize that maybe these modules have been built to be used only with foreman.  Is that a decent assumption?  And if so, is there a simple apache module somewhere?  I only want to do the basics, check packages, service, and create vhosts.  I may be better writing my own... 

llowder

unread,
Dec 7, 2012, 2:42:12 PM12/7/12
to puppet...@googlegroups.com


On Friday, December 7, 2012 1:37:20 PM UTC-6, Ugo Bellavance wrote:
I realize that maybe these modules have been built to be used only with foreman.  Is that a decent assumption?  And if so, is there a simple apache module somewhere?  I only want to do the basics, check packages, service, and create vhosts.  I may be better writing my own... 

Yes, the foreman* modules are designed to be used as a set to install foreman.

As for what to use, take a look at the puppet module forge, puppetlabs has a module for apache.

I generally look at the forge, give modules a read, then either hack it or write my own.
 

Ohad Levy

unread,
Dec 7, 2012, 2:56:30 PM12/7/12
to Puppet Users
On Fri, Dec 7, 2012 at 9:37 PM, Ugo Bellavance <ug...@lubik.ca> wrote:
I realize that maybe these modules have been built to be used only with foreman.  Is that a decent assumption?  And if so, is there a simple apache module somewhere?  I only want to do the basics, check packages, service, and create vhosts.  I may be better writing my own... 


Ideally we would like to share & reuse the modules as much as possible, they are not aimed to work just for the installer ( a lot of people use them for a lot of different usage cases).

specifically, you tried to override a class that has no param class attached to it.

saying  that, we are going a process of parameteriziing all of our classes, so if you would like to send  a patch / pull request we would gladly accept.

Ohad
--
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/-/bLajZTaZ-McJ.

To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Ugo Bellavance

unread,
Dec 7, 2012, 8:31:49 PM12/7/12
to puppet...@googlegroups.com


On Friday, December 7, 2012 2:56:30 PM UTC-5, ohad wrote:



On Fri, Dec 7, 2012 at 9:37 PM, Ugo Bellavance <ug...@lubik.ca> wrote:
I realize that maybe these modules have been built to be used only with foreman.  Is that a decent assumption?  And if so, is there a simple apache module somewhere?  I only want to do the basics, check packages, service, and create vhosts.  I may be better writing my own... 


Ideally we would like to share & reuse the modules as much as possible, they are not aimed to work just for the installer ( a lot of people use them for a lot of different usage cases).

specifically, you tried to override a class that has no param class attached to it.


Hmmm, I kind of understand the concept, but wouldn't know how to fix the module as of now.
 
saying  that, we are going a process of parameteriziing all of our classes, so if you would like to send  a patch / pull request we would gladly accept.


Ok, I'll do my best.  One of our devs spent a few hours today to puppet-lint the module, generate the doc and make it standard compliant.  I currently get errors on the metadata.json files, but when I get something stable I'll send it to you (I'm not familiar with git, pull requests or even patches).

Thanks,

Ugo 

Ugo Bellavance

unread,
Dec 11, 2012, 9:15:09 PM12/11/12
to puppet...@googlegroups.com



On Tue, Dec 11, 2012 at 3:47 PM, Jason Cochard <jason....@gmail.com> wrote:
This class does not accept any parameters, thus why it is failing.  You could easily modify it though to do so:

class apache::service ( $enable = "true",) 
{

...snip...

 service { $http_service:
    ensure     => running,
    enable     => $enable,
    hasstatus  => true,
    hasrestart => true,
    alias      => 'httpd',
    subscribe  => Package['httpd']
  }
...snip...

Then call it like this on the node:
node 'server1' {
  class {  "apache::service": enable  => "false" }
}


Wow, with just that, I'll be able to do that with all my modules that need to accept parameters.
 

Side note, when there is only one parameter, the best practice is to put it all on one line.  

Ok, I wonder if puppet-lint would have caught that.

Thanks a lot,

Ugo

Reply all
Reply to author
Forward
0 new messages