Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I use an older version of the example42 mysql module, which defines the mysql.conf file but not its content. Mmy goal is to just include the mysql module and add a content definition in the node.

class mysql {
    ...
    file { "mysql.conf":
        path => "${mysql::params::configfile}",
        mode => "${mysql::params::configfile_mode}",
        owner => "${mysql::params::configfile_owner}",
        group => "${mysql::params::configfile_group}",
        ensure => present,
        require => Package["mysql"],
        notify => Service["mysql"],
    }
    ...
}


node xyz
{
    include mysql
    File["mysql.conf"] { content => template("mymodule/mysql.conf.erb")}
}

The above code produces a "Only subclasses can override parameters"

What is the correct way to just add a content definition to an existing file definition?

share|improve this question
    
Why not use a parameter passed to the mysql class to provide the path to the template? –  Shane Madden Oct 16 '12 at 2:30
2  
because it is a predefined class, which i don't want to patch all the time i get a newer version of it –  c33s Oct 16 '12 at 7:30

1 Answer 1

up vote 5 down vote accepted

Use a Resource collector, described here. Resource collectors can override resource parameters even if not in a subclass. They are also more versatile, resources can be collected using tags or other parameters, not just the title.

node xyz
{
    include mysql
    File <| title == "mysql.conf" |> { 
        content => template("mymodule/mysql.conf.erb"),
    }
}

Edit: using a subclass

Another option is to declare a subclass and include it in the node definition:

class mysql_custom inherits mysql {
    File["mysql.conf"] { content => template("mymodule/mysql.conf.erb")}
}

node xyz {
    include mysql_custom
}
share|improve this answer
    
any other way without a resource collector? –  c33s Oct 16 '12 at 18:47
    
It is possible to use a subclass. Answer edited. Have you had problems with resource collectors? –  Mikko Oct 17 '12 at 10:06
    
yes, i solved it by using subclasses, found the solution in: packtpub.com/… @ resource collectors: currently i don't get it up and running easily with debian squeeze and postgresql. some ruby probs. –  c33s Oct 18 '12 at 21:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.