Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: modules/adblockplus/manifests/mercurial.pp

Issue 29526640: #3044 - Introduce class adblockplus::mercurial (Closed)
Patch Set: Created Aug. 24, 2017, 4:02 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # == Class: adblockplus::mercurial
2 #
3 # Manage Mercurial (https://www.mercurial-scm.org/) resources.
4 #
5 # === Parameters:
mathias 2017/08/24 16:40:52 Please document parameters $config and $package, t
f.lopez 2017/08/24 17:45:58 Done.
6 #
7 # === Examples:
8 #
9 # class {'adblockplus::mercurial':
10 # ensure => 'latest',
mathias 2017/08/24 16:40:52 That is not a valid example.
f.lopez 2017/08/24 17:45:57 Done.
11 # }
12 #
13 class adblockplus::mercurial (
14 $config = {},
15 $package = {},
16 ) {
17
18 # https://forge.puppet.com/puppetlabs/stdlib
19 include stdlib
20
21 # https://forge.puppet.com/puppetlabs/stdlib#ensure_resource
22 ensure_resource('package', 'mercurial', $package)
23
24 # https://forge.puppet.com/puppetlabs/stdlib#getparam
25 $package_ensure = getparam(Package['mercurial'], 'ensure')
26
27 # https://docs.puppet.com/puppet/latest/lang_conditional.html#selectors
28 $ensure = $package_ensure ? {
29 /^(absent|latest|present|purged|true)$/ => $package_ensure,
30 default => 'present',
31 }
32
33 # https://docs.puppet.com/puppet/latest/types/file.html#file-attribute-content
34 # https://docs.puppet.com/puppet/latest/types/file.html#file-attribute-source
35 $default_content = $config['source'] ? {
36 undef => template('adblockplus/mercurial/hgrc.erb'),
37 default => undef,
38 }
39
40 # https://forge.puppet.com/puppetlabs/stdlib#merge
41 ensure_resource('file', 'hgrc', merge({
42 ensure => ensure_file_state(Package['mercurial']),
43 group => 'root',
44 mode => '0644',
45 owner => 'root',
46 path => '/etc/mercurial/hgrc',
47 content => $default_content,
48 }, $config))
49
50 # https://docs.puppet.com/puppet/latest/lang_relationships.html
51 Package['mercurial'] -> File['hgrc']
52
53 # https://docs.puppet.com/puppet/latest/function.html#createresources
54 $extensions = hiera_hash('adblockplus::mercurial::extensions', {})
55 create_resources('adblockplus::mercurial::extension', $extensions)
56 }
OLDNEW

Powered by Google App Engine
This is Rietveld