OLD | NEW |
(Empty) | |
| 1 # == Class: nodejs |
| 2 # |
| 3 # Install nodejs package from NodeSource |
| 4 # |
| 5 # == Parameters: |
| 6 # |
| 7 # [*package*] |
| 8 # Overwrite the default package options, to fine-tune the target version (i.e. |
| 9 # ensure => 'latest') or remove nodejs (ensure => 'absent' or 'purged') |
| 10 # |
| 11 # [*key*] |
| 12 # Overwrite the default apt::key used (given Class['apt'] is defined). |
| 13 # |
| 14 # [*source*] |
| 15 # Overwrite the default apt::source used (given Class['apt'] is defined). |
| 16 # |
| 17 # [*packages*] |
| 18 # Adds adittional packages with npm. |
| 19 # |
| 20 # === Examples: |
| 21 # |
| 22 # class {'nodejs': |
| 23 # package => { |
| 24 # ensure => 'latest', |
| 25 # }, |
| 26 # } |
| 27 # |
| 28 # |
| 29 class nodejs ( |
| 30 $key = { |
| 31 key => '68576280', |
| 32 key_content => template("nodejs/nodesource.gpg.key.erb"), |
| 33 }, |
| 34 $package = {}, |
| 35 $source = { |
| 36 location => 'https://deb.nodesource.com/node_4.x', |
| 37 release => downcase($lsbdistcodename), |
| 38 repos => 'main', |
| 39 }, |
| 40 $packages = {}, |
| 41 ) { |
| 42 |
| 43 if ensure_state($ensure) { |
| 44 $ensure = 'present' |
| 45 } |
| 46 else { |
| 47 $ensure = 'absent' |
| 48 } |
| 49 |
| 50 ensure_resource('package', $title, merge({ |
| 51 name => $title, |
| 52 ensure => $ensure, |
| 53 }, $package)) |
| 54 |
| 55 # The only package provider recognized implicitly |
| 56 ensure_resource('apt::key', $title, merge({ |
| 57 ensure => $ensure, |
| 58 name => 'nodesource', |
| 59 }, $key)) |
| 60 |
| 61 ensure_resource('apt::source', $title, merge({ |
| 62 ensure => $ensure, |
| 63 include_src => false, |
| 64 name => 'nodesource', |
| 65 }, $source)) |
| 66 |
| 67 Apt::Source[$title] <- Apt::Key[$title] |
| 68 Apt::Source[$title] -> Package[$title] |
| 69 |
| 70 ensure_resources('nodejs::package', $packages, { |
| 71 ensure => 'present', |
| 72 }) |
| 73 } |
| 74 |
OLD | NEW |