| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # == Type: adblockplus::mercurial::extension | |
| 2 # | |
| 3 # Setup rotation for a particular log file. | |
| 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
Acknowledged.
| |
| 6 # | |
| 7 # === Examples: | |
| 8 # | |
| 9 # adblockplus::mercurial::extension {'example': | |
| 10 # name => 'pager', | |
| 11 # config => { | |
| 12 # content => join([ | |
| 13 # '[extensions]', | |
| 14 # 'pager = ', | |
| 15 # '[pager]', | |
| 16 # 'pager = LESS=FSRX less', | |
| 17 # ], "\n"), | |
| 18 # } | |
| 19 # } | |
| 20 # | |
| 21 # adblockplus::mercurial::extension {'hggit': | |
| 22 # package => { | |
| 23 # 'ensure' => 'latest', | |
| 24 # 'name' => 'hg-git', | |
| 25 # 'provider' => 'pip', | |
| 26 # }, | |
| 27 # } | |
| 28 # | |
| 29 # adblockplus::mercurial::extension {'hgext.git': | |
| 30 # package => { | |
| 31 # 'ensure' => 'absent', | |
| 32 # 'name' => 'mercurial-git', | |
| 33 # }, | |
| 34 # } | |
| 35 # | |
| 36 define adblockplus::mercurial::extension ( | |
| 37 $config = {}, | |
| 38 $package = undef, | |
| 39 ) { | |
| 40 | |
| 41 include adblockplus::mercurial | |
| 42 include stdlib | |
| 43 | |
| 44 # https://docs.puppet.com/puppet/latest/lang_conditional.html#selectors | |
| 45 # https://docs.puppet.com/puppet/latest/types/file.html#file-attribute-content | |
| 46 # https://docs.puppet.com/puppet/latest/types/file.html#file-attribute-source | |
| 47 $default_content = $config['source'] ? { | |
| 48 undef => template('adblockplus/mercurial/hgext.erb'), | |
| 49 default => undef, | |
| 50 } | |
| 51 | |
| 52 # https://forge.puppet.com/puppetlabs/stdlib#ensure_resource | |
| 53 # https://forge.puppet.com/puppetlabs/stdlib#merge | |
| 54 ensure_resource('file', "$name.rc", merge({ | |
| 55 content => $default_content, | |
| 56 ensure => ensure_file_state($adblockplus::mercurial::ensure), | |
| 57 path => "/etc/mercurial/hgrc.d/$name.rc", | |
| 58 }, $config)) | |
| 59 | |
| 60 # https://docs.puppet.com/puppet/latest/lang_relationships.html | |
| 61 File["$name.rc"] <- Package['mercurial'] | |
| 62 | |
| 63 ensure_resource('package', 'python-dev') | |
|
mathias
2017/08/24 16:40:52
?
f.lopez
2017/08/24 17:45:58
This is needed for installing pip packages (for hg
| |
| 64 | |
| 65 # https://docs.puppet.com/puppet/latest/function.html#defined | |
| 66 if defined('$package') { | |
| 67 | |
| 68 ensure_resource('package', $name, merge({ | |
| 69 ensure => $adblockplus::mercurial::ensure, | |
| 70 require => Package['python-dev'], | |
| 71 }, $package)) | |
| 72 | |
| 73 Package[$name] <- Package['mercurial'] | |
| 74 } | |
| 75 } | |
| OLD | NEW |