Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to provide a "default-example" configuration file to node servers using puppet (my.cnf for example) but I want to allow the server administrator to update it as much as he wants. (Basically, I provide "base" vm to IT researchers and they adapt it by themselves)

I' tried with the function "file" with puppet but it noticed when I try to change it...

Is there a solution?

share|improve this question
up vote 9 down vote accepted

Use the replace parameter for file.

file { '/path/to/file':
  ensure  => present,
  source  => 'puppet:///modules/module_name/file',
  replace => false,

If this is a production environment I would recommend encouraging/requiring the admins to make configuration changes via puppet. If this is not a production environment you could use puppet to do the configuration (like with 'puppet apply') and not continue to run puppet agent after that.

share|improve this answer
Ho... didn't see that option ! works fine ! thank you – DJYod Dec 5 '12 at 9:32

Anton's answer is probably best however this method might be useful as well.

Mysql supports conf directories. I usually have a single line in my.cnf, !includedir /etc/mysql/conf.d/ and then load additional configs to fill in functionality. Mysql will use the last instance of a config variable based on parse order. If you put your defaults in /etc/mysql/conf.d/00_somefile.cnf any additional files should override it. You might create a /etc/mysql/conf.d/local_changes.cnf so it's clear where to put it.

class mysql::config {

  file { 'my.cnf':
    ensure  => present,
    path    => '/etc/mysql/my.cnf
    source  => 'puppet:///modules/mysql/my.cnf',

  file { '/etc/mysql/conf.d':
    ensure  => directory,

  file { 'general_mysql.cnf':
    ensure  => present,
    path    => '/etc/mysql/conf.d/00_general_mysql.cnf',
    content => template('mysql/general_mysql.cnf.erb'),

With the above you can continue to publish changes via your Puppet controlled config file and the researchers can override as needed.

share|improve this answer
Thanks for your solution but I don't know how MySQL would react if we set the engine to innodb via puppet and then the admin wants to configure another engine using a conf file in the /etc/mysql/conf.d – DJYod Dec 5 '12 at 9:36
Both engines would likely be enabled which might be suboptimal though you could try skip-innodb in a later config and see if it would cancel it out. I tend to use this technique of dev machines where the vhosts may change frequently, but I still want to set reasonable defaults for modules that can be overridden per vhost. – kashani Dec 5 '12 at 18:19

Your Answer


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.