How to extend a file definition from an existing module in the node?

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?


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
}