multitemplate

Puppet function for selecting from multiple template sources

deanwilson

deanwilson

64,416 downloads

47,881 latest version

4.6 quality score

Version information

  • 1.0.2 (latest)
  • 1.0.1
  • 1.0.0
released Nov 27th 2015
This version is compatible with:
  • RedHat, Ubuntu, Debian, Fedora, CentOS

Start using this module

Tags: function

Documentation

deanwilson/multitemplate — version 1.0.2 Nov 27th 2015

Puppet Multiple Template Source Function

The multitemplate Puppet function allows you to list multiple template sources and use the first one that exists.

class ssh::config {

  file { "/etc/ssh/sshd_config" :
    ensure  => present,
    mode    => '0600',
    content => multitemplate( "ssh/${::fqdn}",
                              "ssh/${::domain}",
                              'ssh/default_sshdconfig'
                            ),
  }

}

While it's currently possible to invoke template with multiple sources specified it does not behave as most people expect. Instead of selecting the first existing match it concatenates the templates together when used as below:

class ssh::config {

  file { "/etc/ssh/sshd_config" :
    ensure  => present,
    content => template( "ssh/${::fqdn}",
                         "ssh/${::domain}",
                         'ssh/default_sshdconfig'
                       ),
  }

}

This Puppet function was originally written by R.I.Pienaar and raised as Allow multiple sources for a template and only use the first template if it exists in the Puppet Issue tracker.

I've added all the usual module boilerplate scaffolding with permission.

Note: I will be more than happy to take this module down when the functionality is in core Puppet.

License

Apache 2.0 - Dean Wilson