Index: modules/adblockplus/manifests/mercurial.pp |
=================================================================== |
new file mode 100644 |
--- /dev/null |
+++ b/modules/adblockplus/manifests/mercurial.pp |
@@ -0,0 +1,56 @@ |
+# == Class: adblockplus::mercurial |
+# |
+# Manage Mercurial (https://www.mercurial-scm.org/) resources. |
+# |
+# === Parameters: |
mathias
2017/08/24 16:40:52
Please document parameters $config and $package, t
f.lopez
2017/08/24 17:45:58
Done.
|
+# |
+# === Examples: |
+# |
+# class {'adblockplus::mercurial': |
+# ensure => 'latest', |
mathias
2017/08/24 16:40:52
That is not a valid example.
f.lopez
2017/08/24 17:45:57
Done.
|
+# } |
+# |
+class adblockplus::mercurial ( |
+ $config = {}, |
+ $package = {}, |
+) { |
+ |
+ # https://forge.puppet.com/puppetlabs/stdlib |
+ include stdlib |
+ |
+ # https://forge.puppet.com/puppetlabs/stdlib#ensure_resource |
+ ensure_resource('package', 'mercurial', $package) |
+ |
+ # https://forge.puppet.com/puppetlabs/stdlib#getparam |
+ $package_ensure = getparam(Package['mercurial'], 'ensure') |
+ |
+ # https://docs.puppet.com/puppet/latest/lang_conditional.html#selectors |
+ $ensure = $package_ensure ? { |
+ /^(absent|latest|present|purged|true)$/ => $package_ensure, |
+ default => 'present', |
+ } |
+ |
+ # https://docs.puppet.com/puppet/latest/types/file.html#file-attribute-content |
+ # https://docs.puppet.com/puppet/latest/types/file.html#file-attribute-source |
+ $default_content = $config['source'] ? { |
+ undef => template('adblockplus/mercurial/hgrc.erb'), |
+ default => undef, |
+ } |
+ |
+ # https://forge.puppet.com/puppetlabs/stdlib#merge |
+ ensure_resource('file', 'hgrc', merge({ |
+ ensure => ensure_file_state(Package['mercurial']), |
+ group => 'root', |
+ mode => '0644', |
+ owner => 'root', |
+ path => '/etc/mercurial/hgrc', |
+ content => $default_content, |
+ }, $config)) |
+ |
+ # https://docs.puppet.com/puppet/latest/lang_relationships.html |
+ Package['mercurial'] -> File['hgrc'] |
+ |
+ # https://docs.puppet.com/puppet/latest/function.html#createresources |
+ $extensions = hiera_hash('adblockplus::mercurial::extensions', {}) |
+ create_resources('adblockplus::mercurial::extension', $extensions) |
+} |