Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 # == Class: nodejs | 1 # == Class: nodejs |
2 # | 2 # |
3 # Install nodejs package from source | 3 # Install nodejs package from NodeSource |
4 # | 4 # |
5 # == Parameters: | 5 # == Parameters: |
6 # | 6 # |
7 # [*package*] | 7 # [*package*] |
8 # Overwrite the default package options, to fine-tune the target version (i.e. | 8 # Overwrite the default package options, to fine-tune the target version (i.e. |
9 # ensure => 'latest') or remove nodejs (ensure => 'absent' or 'purged') | 9 # ensure => 'latest') or remove nodejs (ensure => 'absent' or 'purged') |
10 # | 10 # |
11 # [*key*] | 11 # [*key*] |
12 # Overwrite the default apt::key used (given Class['apt'] is defined). | 12 # Overwrite the default apt::key used (given Class['apt'] is defined). |
13 # | 13 # |
(...skipping 19 matching lines...) Expand all Loading... | |
33 }, | 33 }, |
34 $package = {}, | 34 $package = {}, |
35 $source = { | 35 $source = { |
36 location => 'https://deb.nodesource.com/node_4.x', | 36 location => 'https://deb.nodesource.com/node_4.x', |
37 release => downcase($lsbdistcodename), | 37 release => downcase($lsbdistcodename), |
38 repos => 'main', | 38 repos => 'main', |
39 }, | 39 }, |
40 $packages = {}, | 40 $packages = {}, |
41 ) { | 41 ) { |
42 | 42 |
43 include stdlib | 43 if ensure_state($ensure) { |
44 $ensure = 'present' | |
45 } | |
46 else { | |
47 $ensure = 'absent' | |
48 } | |
44 | 49 |
45 ensure_resource('package', $title, merge({ | 50 ensure_resource('package', $title, merge({ |
46 name => $title, | 51 name => $title, |
47 require => Apt::Source[$title], | |
mathias
2017/07/09 07:26:50
Use arrow-notation to establish relationships, esp
| |
48 ensure => $ensure, | 52 ensure => $ensure, |
49 }, $package)) | 53 }, $package)) |
50 | 54 |
51 # Used as default $ensure parameter for most resources below | 55 # The only package provider recognized implicitly |
52 $ensure = getparam(Package[$title], 'ensure') ? { | 56 ensure_resource('apt::key', $title, merge({ |
53 /^(absent|purged)$/ => 'absent', | 57 ensure => $ensure, |
54 default => 'present', | 58 name => 'nodesource', |
55 } | 59 }, $key)) |
56 | 60 |
57 if ensure_state($ensure) { | 61 ensure_resource('apt::source', $title, merge({ |
62 ensure => $ensure, | |
63 include_src => false, | |
64 name => 'nodesource', | |
65 }, $source)) | |
58 | 66 |
59 # The only package provider recognized implicitly | 67 Apt::Source[$title] <- Apt::Key[$title] |
60 ensure_resource('apt::key', $title, merge({ | 68 Apt::Source[$title] -> Package[$title] |
mathias
2017/07/09 07:26:50
How is the user supposed to remove this one if the
| |
61 ensure => $ensure, | |
62 name => 'nodesource', | |
63 }, $key)) | |
64 | 69 |
65 ensure_resource('apt::source', $title, merge({ | 70 ensure_resources('nodejs::package', $packages, { |
mathias
2017/07/09 07:26:50
How is the user supposed to remove this one if the
| |
66 ensure => $ensure, | 71 ensure => 'present', |
67 include_src => false, | 72 }) |
68 name => 'nodesource', | 73 } |
69 }, $source)) | |
70 | 74 |
71 Apt::Source[$title] <- Apt::Key[$title] | |
72 Apt::Source[$title] -> Package[$title] | |
73 | |
74 create_resources('nodejs::package', $packages) | |
75 | |
76 } | |
77 | |
78 } | |
LEFT | RIGHT |