OLD | NEW |
(Empty) | |
| 1 # == Class: adblockplus::mercurial |
| 2 # |
| 3 # Manage Mercurial (https://www.mercurial-scm.org/) resources. |
| 4 # |
| 5 # === Parameters: |
| 6 # |
| 7 # [*config*] |
| 8 # Overwrite the default hgrc file options for the Mercurial config. |
| 9 # |
| 10 # [*package*] |
| 11 # Overwrite the default package options, to fine-tune the target version. |
| 12 # |
| 13 # === Examples: |
| 14 # |
| 15 # class {'adblockplus::mercurial': |
| 16 # package => { |
| 17 # ensure => 'latest', |
| 18 # }, |
| 19 # } |
| 20 # |
| 21 class adblockplus::mercurial ( |
| 22 $config = {}, |
| 23 $package = {}, |
| 24 ) { |
| 25 |
| 26 # https://forge.puppet.com/puppetlabs/stdlib |
| 27 include stdlib |
| 28 |
| 29 # https://forge.puppet.com/puppetlabs/stdlib#ensure_resource |
| 30 ensure_resource('package', 'mercurial', $package) |
| 31 |
| 32 # https://forge.puppet.com/puppetlabs/stdlib#getparam |
| 33 $package_ensure = getparam(Package['mercurial'], 'ensure') |
| 34 |
| 35 # https://docs.puppet.com/puppet/latest/lang_conditional.html#selectors |
| 36 $ensure = $package_ensure ? { |
| 37 /^(absent|latest|present|purged|true)$/ => $package_ensure, |
| 38 default => 'present', |
| 39 } |
| 40 |
| 41 # https://docs.puppet.com/puppet/latest/types/file.html#file-attribute-content |
| 42 # https://docs.puppet.com/puppet/latest/types/file.html#file-attribute-source |
| 43 $default_content = $config['source'] ? { |
| 44 undef => template('adblockplus/mercurial/hgrc.erb'), |
| 45 default => undef, |
| 46 } |
| 47 |
| 48 # https://forge.puppet.com/puppetlabs/stdlib#merge |
| 49 ensure_resource('file', 'hgrc', merge({ |
| 50 ensure => ensure_file_state(Package['mercurial']), |
| 51 group => 'root', |
| 52 mode => '0644', |
| 53 owner => 'root', |
| 54 path => '/etc/mercurial/hgrc', |
| 55 content => $default_content, |
| 56 }, $config)) |
| 57 |
| 58 # https://docs.puppet.com/puppet/latest/lang_relationships.html |
| 59 Package['mercurial'] -> File['hgrc'] |
| 60 |
| 61 # https://docs.puppet.com/puppet/latest/function.html#createresources |
| 62 $extensions = hiera_hash('adblockplus::mercurial::extensions', {}) |
| 63 create_resources('adblockplus::mercurial::extension', $extensions) |
| 64 } |
OLD | NEW |