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 # Used as default $ensure parameter for most resources below | 43 if ensure_state($ensure) { |
44 $ensure = ensure_state($ensure) ? { | 44 $ensure = 'present' |
45 false => 'absent', | 45 } |
46 true => 'present', | 46 else { |
| 47 $ensure = 'absent' |
47 } | 48 } |
48 | 49 |
49 ensure_resource('package', $title, merge({ | 50 ensure_resource('package', $title, merge({ |
50 name => $title, | 51 name => $title, |
51 ensure => $ensure, | 52 ensure => $ensure, |
52 }, $package)) | 53 }, $package)) |
53 | 54 |
54 # The only package provider recognized implicitly | 55 # The only package provider recognized implicitly |
55 ensure_resource('apt::key', $title, merge({ | 56 ensure_resource('apt::key', $title, merge({ |
56 ensure => $ensure, | 57 ensure => $ensure, |
57 name => 'nodesource', | 58 name => 'nodesource', |
58 }, $key)) | 59 }, $key)) |
59 | 60 |
60 ensure_resource('apt::source', $title, merge({ | 61 ensure_resource('apt::source', $title, merge({ |
61 ensure => $ensure, | 62 ensure => $ensure, |
62 include_src => false, | 63 include_src => false, |
63 name => 'nodesource', | 64 name => 'nodesource', |
64 }, $source)) | 65 }, $source)) |
65 | 66 |
66 Apt::Source[$title] <- Apt::Key[$title] | 67 Apt::Source[$title] <- Apt::Key[$title] |
67 Apt::Source[$title] -> Package[$title] | 68 Apt::Source[$title] -> Package[$title] |
68 | 69 |
69 create_resources('nodejs::package', $packages) | 70 ensure_resources('nodejs::package', $packages, { |
| 71 ensure => 'present', |
| 72 }) |
70 } | 73 } |
71 | 74 |
LEFT | RIGHT |