Skip to content

Commit

Permalink
Remove EOL operating systems, Legacy facts.
Browse files Browse the repository at this point in the history
- Update the `repo_url_suffix` table in the README, dropping EOL
operating systems and adding new ones
- Drop explicit handling of Debian 6 and 7 (EOL)
- Drop explicit handling of Ubuntu 10.04 and 12.04 (EOL)
- Drop explicit handling of EOL Fedora versions
- Drop explicit handling of RHEL5 (EOL)
- Add explicit handling of Debian 9
- Replace most Legacy facts with Modern facts using the new facts hash
syntax. This explicitly drops support for Facter versions less than 3,
which are not supported under Puppet4/5 anyway.
- Drop explicit support for Amazon Linux versions less than 2015.03.
Amazon Linux is rolling distribution, and earlier versions did not have
Facter 3
- Use the Modern system32 fact

Also:
- Remove the old Puppetlabs footer from the README. Reference
CONTRIBUTING.md instead
- Perform minor doc fixes
- Use less granular error handling
  • Loading branch information
juniorsysadmin committed Dec 4, 2017
1 parent 8f39cdc commit 0427379
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 498 deletions.
34 changes: 9 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ When a separate npm package exists (natively or via EPEL) the Node.js developmen
package also needs to be installed as it is a dependency for npm.

Install Node.js and npm using the native packages provided by the distribution:
(Only applicable for Ubuntu 12.04/14.04 and Fedora operating systems):

```puppet
class { '::nodejs':
Expand Down Expand Up @@ -470,13 +469,11 @@ the NodeSource URL structure - NodeSource might remove old versions (such as
0.10 and 0.12) or add new ones (such as 8.x) at any time.

The following are ``repo_url_suffix`` values that reflect NodeSource versions
that were available on 2017-11-14:
that were available on 2017-11-29:

* Debian 7 (Wheezy) ```0.10``` ```0.12``` ```4.x``` ```5.x``` ```6.x```
* Debian 8 (Jessie) ```0.10``` ```0.12``` ```4.x``` ```5.x``` ```6.x``` ```7.x``` ```8.x``` ```9.x```
* Debian 9 (Stretch) ```4.x``` ```6.x``` ```7.x``` ```8.x``` ```9.x```
* Debian (Sid) ```0.10``` ```0.12``` ```4.x``` ```5.x``` ```6.x``` ```7.x``` ```8.x``` ```9.x```
* Ubuntu 12.04 (Precise) ```0.10``` ```0.12``` ```4.x``` ```5.x``` ```6.x```
* Ubuntu 14.04 (Trusty) ```0.10``` ```0.12``` ```4.x``` ```5.x``` ```6.x``` ```7.x``` ```8.x``` ```9.x```
* Ubuntu 16.04 (Xenial) ```0.10``` ```0.12``` ```4.x``` ```5.x``` ```6.x``` ```7.x``` ```8.x``` ```9.x```
* Ubuntu 16.10 (Yakkety) ```0.12``` ```4.x``` ```6.x``` ```7.x``` ```8.x```
Expand All @@ -487,6 +484,7 @@ that were available on 2017-11-14:
* Amazon Linux - See RHEL/CentOS 7
* Fedora 25 ```4.x``` ```6.x``` ```7.x``` ```8.x``` ```9.x```
* Fedora 26 ```6.x``` ```8.x``` ```9.x```
* Fedora 27 ```8.x``` ```9.x```

#### `use_flags`

Expand All @@ -497,34 +495,30 @@ The USE flags to use for the Node.js package on Gentoo systems. Defaults to

This module has received limited testing on:

* CentOS/RHEL 5/6/7
* Debian 7
* Ubuntu 10.04/12.04/14.04
* CentOS/RHEL 6/7
* Debian 8
* Ubuntu 14.04

The following platforms should also work, but have not been tested:

* Amazon Linux
* Archlinux
* Darwin
* Debian 8
* Debian 9
* Fedora
* FreeBSD
* Gentoo
* OpenBSD
* OpenSuse/SLES
* Windows

This module is not supported on Debian Squeeze.

### Module dependencies

This modules uses `puppetlabs-apt` for the management of the NodeSource
repository. If using an operating system of the Debian-based family, you will
need to ensure that `puppetlabs-apt` version 2.x or above is installed.

If using CentoOS/RHEL 5, you will need to ensure that the `stahnma-epel`
module is installed.

If using CentoOS/RHEL 5/6/7 and you wish to install Node.js from EPEL rather
If using CentOS/RHEL 6/7 and you wish to install Node.js from EPEL rather
than from the NodeSource repository, you will need to ensure `stahnma-epel` is
installed and is applied before this module.

Expand All @@ -539,14 +533,4 @@ wish to use this functionality, Git needs to be installed and be in the

## Development

Puppet Labs modules on the Puppet Forge are open projects, and community
contributions are essential for keeping them great. We can’t access the huge
number of platforms and myriad of hardware, software, and deployment
configurations that Puppet is intended to serve.

We want to keep it as easy as possible to contribute changes so that our
modules work in your environment. There are a few guidelines that we need
contributors to follow so that we can have a chance of keeping on top of
things.

Read the complete module [contribution guide](https://docs.puppetlabs.com/forge/contributing.html)
See [CONTRIBUTING](CONTRIBUTING.md)
4 changes: 2 additions & 2 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
}

# npm is a Gentoo USE flag
if $::operatingsystem == 'Gentoo' {
if $facts['os']['name'] == 'Gentoo' {
package_use { $nodejs::nodejs_package_name:
ensure => present,
target => 'nodejs-flags',
Expand Down Expand Up @@ -41,7 +41,7 @@
}

# Replicates the nodejs-legacy package functionality
if ($::osfamily == 'Debian' and $nodejs::legacy_debian_symlinks) {
if ($facts['os']['family'] == 'Debian' and $nodejs::legacy_debian_symlinks) {
file { '/usr/bin/node':
ensure => 'link',
target => '/usr/bin/nodejs',
Expand Down
4 changes: 2 additions & 2 deletions manifests/npm.pp
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
$package_string = "${package}@${ensure}"
}

$grep_command = $::osfamily ? {
$grep_command = $facts['os']['family'] ? {
'Windows' => "${cmd_exe_path} /c findstr /l",
default => 'grep',
}

$dirsep = $::osfamily ? {
$dirsep = $facts['os']['family'] ? {
'Windows' => "\\",
default => '/'
}
Expand Down
98 changes: 10 additions & 88 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,14 @@
$repo_url_suffix = '0.10'
$use_flags = ['npm', 'snapshot']

# The full path to cmd.exe is required on Windows. The system32 fact is only
# available from Facter 2.3
$cmd_exe_path = $::osfamily ? {
'Windows' => 'C:\Windows\system32\cmd.exe',
$cmd_exe_path = $facts['os']['family'] ? {
'Windows' => "${facts['os']['windows']['system32']}\\cmd.exe",
default => undef,
}

case $::osfamily {
case $facts['os']['family'] {
'Debian': {
if $::operatingsystemrelease =~ /^6\.(\d+)/ {
fail("The ${module_name} module is not supported on Debian Squeeze.")
}
elsif $::operatingsystemrelease =~ /^[78]\.(\d+)/ {
if $facts['os']['release']['major'] =~ /^[89]$/ {
$legacy_debian_symlinks = false
$manage_package_repo = true
$nodejs_debug_package_name = 'nodejs-dbg'
Expand All @@ -37,43 +32,7 @@
$npm_path = '/usr/bin/npm'
$repo_class = '::nodejs::repo::nodesource'
}
elsif $::operatingsystemrelease =~ /^10.04$/ {
$legacy_debian_symlinks = false
$manage_package_repo = true
$nodejs_debug_package_name = 'nodejs-dbg'
$nodejs_dev_package_name = undef
$nodejs_dev_package_ensure = 'absent'
$nodejs_package_name = 'nodejs'
$npm_package_ensure = 'absent'
$npm_package_name = false
$npm_path = '/usr/bin/npm'
$repo_class = '::nodejs::repo::nodesource'
}
elsif $::operatingsystemrelease =~ /^12.04$/ {
$legacy_debian_symlinks = false
$manage_package_repo = true
$nodejs_debug_package_name = 'nodejs-dbg'
$nodejs_dev_package_name = 'nodejs-dev'
$nodejs_dev_package_ensure = 'absent'
$nodejs_package_name = 'nodejs'
$npm_package_ensure = 'absent'
$npm_package_name = 'npm'
$npm_path = '/usr/bin/npm'
$repo_class = '::nodejs::repo::nodesource'
}
elsif $::operatingsystemrelease =~ /^14.04$/ {
$legacy_debian_symlinks = false
$manage_package_repo = true
$nodejs_debug_package_name = 'nodejs-dbg'
$nodejs_dev_package_name = 'nodejs-dev'
$nodejs_dev_package_ensure = 'absent'
$nodejs_package_name = 'nodejs'
$npm_package_ensure = 'absent'
$npm_package_name = 'npm'
$npm_path = '/usr/bin/npm'
$repo_class = '::nodejs::repo::nodesource'
}
elsif $::operatingsystemrelease =~ /^16.04$/ {
elsif $facts['os']['release']['full'] =~ /^1[46]\.04$/ {
$legacy_debian_symlinks = false
$manage_package_repo = true
$nodejs_debug_package_name = 'nodejs-dbg'
Expand All @@ -86,7 +45,7 @@
$repo_class = '::nodejs::repo::nodesource'
}
else {
warning("The ${module_name} module might not work on ${::operatingsystem} ${::operatingsystemrelease}. Sensible defaults will be attempted.")
warning("The ${module_name} module might not work on ${facts['os']['name']} ${facts['os']['release']['full']}. Sensible defaults will be attempted.")
$legacy_debian_symlinks = false
$manage_package_repo = true
$nodejs_debug_package_name = 'nodejs-dbg'
Expand All @@ -102,7 +61,7 @@
'RedHat': {
$legacy_debian_symlinks = false

if $::operatingsystemrelease =~ /^[5-7]\.(\d+)/ {
if $facts['os']['release']['major'] =~ /^[67]$/ {
$manage_package_repo = true
$nodejs_debug_package_name = 'nodejs-debuginfo'
$nodejs_dev_package_name = 'nodejs-devel'
Expand All @@ -113,7 +72,7 @@
$npm_path = '/usr/bin/npm'
$repo_class = '::nodejs::repo::nodesource'
}
elsif ($::operatingsystem == 'Fedora') and (versioncmp($::operatingsystemrelease, '18') > 0) {
elsif $facts['os']['name'] == 'Fedora' {
$manage_package_repo = true
$nodejs_debug_package_name = 'nodejs-debuginfo'
$nodejs_dev_package_name = 'nodejs-devel'
Expand All @@ -124,7 +83,7 @@
$npm_path = '/usr/bin/npm'
$repo_class = '::nodejs::repo::nodesource'
}
elsif ($::operatingsystem == 'Amazon') {
elsif ($facts['os']['name'] == 'Amazon') {
$manage_package_repo = true
$nodejs_debug_package_name = 'nodejs-debuginfo'
$nodejs_dev_package_name = 'nodejs-devel'
Expand Down Expand Up @@ -213,7 +172,6 @@
$repo_class = undef
Package { provider => 'chocolatey' }
}
# Gentoo was added as its own $::osfamily in Facter 1.7.0
'Gentoo': {
$legacy_debian_symlinks = false
$manage_package_repo = false
Expand All @@ -226,44 +184,8 @@
$npm_path = '/usr/bin/npm'
$repo_class = undef
}
'Linux': {
# Before Facter 1.7.0 Gentoo did not have its own $::osfamily
case $::operatingsystem {
'Gentoo': {
$legacy_debian_symlinks = false
$manage_package_repo = false
$nodejs_debug_package_name = undef
$nodejs_dev_package_name = undef
$nodejs_dev_package_ensure = 'absent'
$nodejs_package_name = 'net-libs/nodejs'
$npm_package_ensure = 'absent'
$npm_package_name = false
$npm_path = '/usr/bin/npm'
$repo_class = undef
}
'Amazon': {
# this is here only for historical reasons:
# old facter and Amazon Linux versions will run into this code path
$legacy_debian_symlinks = false
$manage_package_repo = true
$nodejs_debug_package_name = 'nodejs-debuginfo'
$nodejs_dev_package_name = 'nodejs-devel'
$nodejs_dev_package_ensure = 'absent'
$nodejs_package_name = 'nodejs'
$npm_package_ensure = 'absent'
$npm_package_name = 'npm'
$npm_path = '/usr/bin/npm'
$repo_class = '::nodejs::repo::nodesource'
}

default: {
fail("The ${module_name} module is not supported on an ${::operatingsystem} distribution.")
}
}
}

default: {
fail("The ${module_name} module is not supported on a ${::osfamily} based system.")
fail("The ${module_name} module is not supported on a ${facts['os']['name']} distribution.")
}
}
}
69 changes: 10 additions & 59 deletions manifests/repo/nodesource.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,21 @@
$proxy_username = $nodejs::repo_proxy_username
$url_suffix = $nodejs::repo_url_suffix

case $::osfamily {
case $facts['os']['family'] {
'RedHat': {
if $::operatingsystemrelease =~ /^5\.(\d+)/ {
include ::epel
$dist_version = '5'
$name_string = 'Enterprise Linux 5'
}

elsif $::operatingsystemrelease =~ /^6\.(\d+)/ {
$dist_version = '6'
$name_string = 'Enterprise Linux 6'
}

elsif $::operatingsystemrelease =~ /^7\.(\d+)/ {
$dist_version = '7'
$name_string = 'Enterprise Linux 7'
if $facts['os']['release']['major'] =~ /^[67]$/ {
$dist_version = $facts['os']['release']['major']
$name_string = "Enterprise Linux ${dist_version}"
}

# Fedora
elsif $::operatingsystem == 'Fedora' {
$dist_version = $::operatingsystemrelease
$name_string = "Fedora Core ${::operatingsystemrelease}"
elsif $facts['os']['name'] == 'Fedora' {
$dist_version = $facts['os']['release']['full']
$name_string = "Fedora Core ${facts['os']['release']['full']}"
}

# newer Amazon Linux releases
elsif ($::operatingsystem == 'Amazon') {
elsif ($facts['os']['name'] == 'Amazon') {
$dist_version = '7'
$name_string = 'Enterprise Linux 7'
}
Expand All @@ -43,7 +32,7 @@
fail("Could not determine NodeSource repository URL for operatingsystem: ${::operatingsystem} operatingsystemrelease: ${::operatingsystemrelease}.")
}

$dist_type = $::operatingsystem ? {
$dist_type = $facts['os']['name'] ? {
'Fedora' => 'fc',
default => 'el',
}
Expand All @@ -59,52 +48,14 @@
class { '::nodejs::repo::nodesource::yum': }
contain '::nodejs::repo::nodesource::yum'

if $::operatingsystemrelease =~ /^5\.(\d+)/ {
# On EL 5, EPEL needs to be applied first
Class['::epel'] -> Class['::nodejs::repo::nodesource::yum']
}

}
'Linux': {
if $::operatingsystem == 'Amazon' {

# Recent Amazon Linux instances
if $::operatingsystemrelease =~ /^201[4-9]\./ {
$dist_type = 'el'
$dist_version = '7'
$name_string = 'Enterprise Linux 7'
}
else {
$dist_type = 'el'
$dist_version = '6'
$name_string = 'Enterprise Linux 6'
}

# nodesource repo
$descr = "Node.js Packages for ${name_string} - \$basearch"
$baseurl = "https://rpm.nodesource.com/pub_${url_suffix}/${dist_type}/${dist_version}/\$basearch"

# nodesource-source repo
$source_descr = "Node.js for ${name_string} - \$basearch - Source"
$source_baseurl = "https://rpm.nodesource.com/pub_${url_suffix}/${dist_type}/${dist_version}/SRPMS"

class { '::nodejs::repo::nodesource::yum': }
contain '::nodejs::repo::nodesource::yum'
}

else {
if ($ensure == 'present') {
fail("Unsupported managed NodeSource repository for operatingsystem: ${::operatingsystem}.")
}
}
}
'Debian': {
class { '::nodejs::repo::nodesource::apt': }
contain '::nodejs::repo::nodesource::apt'
}
default: {
if ($ensure == 'present') {
fail("Unsupported managed NodeSource repository for osfamily: ${::osfamily}, operatingsystem: ${::operatingsystem}.")
fail("Unsupported managed NodeSource repository for osfamily: ${facts['os']['family']}, operatingsystem: ${facts['os']['name']}.")
}
}
}
Expand Down
Loading

0 comments on commit 0427379

Please sign in to comment.