Forge Home

multitemplate

Puppet function for selecting from multiple template sources

deanwilson

deanwilson

69,960 downloads

52,499 latest version

4.6 quality score

Version information

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

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this declaration to your Puppetfile:

mod 'deanwilson-multitemplate', '1.0.2'
Learn more about managing modules with a Puppetfile

Add this module to a Bolt project:

bolt module add deanwilson-multitemplate
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install deanwilson-multitemplate --version 1.0.2

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download
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