Update nodejs, sudo and users cookbooks

This commit is contained in:
Greg Karékinian
2018-04-17 13:18:09 +02:00
parent ff2f424ddb
commit 157ccdc8b7
37 changed files with 862 additions and 523 deletions

View File

@@ -1,9 +1,9 @@
#
# Author:: Marius Ducea (marius@promethost.com)
# Cookbook Name:: nodejs
# Cookbook:: nodejs
# Recipe:: default
#
# Copyright 2010-2012, Promet Solutions
# Copyright:: 2010-2017, Promet Solutions
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -18,6 +18,6 @@
# limitations under the License.
#
include_recipe 'nodejs::install'
include_recipe 'nodejs::npm'
include_recipe 'nodejs::npm_packages'
include_recipe 'nodejs::install' if node['nodejs']['manage_node']
include_recipe 'nodejs::npm' if node['nodejs']['manage_node']
include_recipe 'nodejs::npm_packages' if node['nodejs']['manage_node']

View File

@@ -1,9 +1,9 @@
#
# Author:: Marius Ducea (marius@promethost.com)
# Cookbook Name:: nodejs
# Cookbook:: nodejs
# Recipe:: install
#
# Copyright 2010-2012, Promet Solutions
# Copyright:: 2010-2017, Promet Solutions
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.

View File

@@ -1,23 +1 @@
#
# Author:: Marius Ducea (marius@promethost.com)
# Cookbook Name:: nodejs
# Recipe:: iojs
#
# Copyright 2010-2012, Promet Solutions
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
node.default['nodejs']['engine'] = 'iojs'
include_recipe 'nodejs::install'
Chef::Log.fatal('The nodejs::iojs recipe has been deprecated. If you need iojs installation pin to cookbook version 3.0.1.')

View File

@@ -1,9 +1,9 @@
#
# Author:: Marius Ducea (marius@promethost.com)
# Cookbook Name:: nodejs
# Cookbook:: nodejs
# Recipe:: nodejs
#
# Copyright 2010-2012, Promet Solutions
# Copyright:: 2010-2017, Promet Solutions
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -18,6 +18,4 @@
# limitations under the License.
#
node.default['nodejs']['engine'] = 'node'
include_recipe 'nodejs::install'
Chef::Log.fatal('The nodejs::nodejs recipe is no longer used. Use nodejs::install to install nodejs instead.')

View File

@@ -1,6 +1,6 @@
#
# Author:: Julian Wilde (jules@jules.com.au)
# Cookbook Name:: nodejs
# Cookbook:: nodejs
# Recipe:: install_from_binary
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,29 +18,33 @@
Chef::Recipe.send(:include, NodeJs::Helper)
node.force_override['nodejs']['install_method'] = 'binary' # ~FC019
# Shamelessly borrowed from http://docs.chef.io/dsl_recipe_method_platform.html
# Surely there's a more canonical way to get arch?
arch = if node['kernel']['machine'] =~ /armv6l/
# FIXME: This should really check the version of node we're looking for
# as it seems that they haven't build an `arm-pi` version in a while...
# if it's old, return this, otherwise just return `node['kernel']['machine']`
'arm-pi' # assume a raspberry pi
elsif node['kernel']['machine'] =~ /aarch64/
'arm64'
elsif node['kernel']['machine'] =~ /x86_64/
'x64'
elsif node['kernel']['machine'] =~ /\d86/
'x86'
else
node['kernel']['machine'] =~ /x86_64/ ? 'x64' : 'x86'
node['kernel']['machine']
end
# package_stub is for example: "node-v6.9.1-linux-x64.tar.xz"
version = "v#{node['nodejs']['version']}/"
prefix = node['nodejs']['prefix_url'][node['nodejs']['engine']]
# needed to uncompress the binary
package 'tar' if platform_family?('rhel', 'fedora', 'amazon', 'suse')
if node['nodejs']['engine'] == 'iojs'
filename = "iojs-v#{node['nodejs']['version']}-linux-#{arch}.tar.xz"
archive_name = 'iojs-binary'
binaries = ['bin/iojs', 'bin/node']
else
filename = "node-v#{node['nodejs']['version']}-linux-#{arch}.tar.xz"
archive_name = 'nodejs-binary'
binaries = ['bin/node']
end
# package_stub is for example: "node-v6.9.1-linux-x64.tar.gz"
version = "v#{node['nodejs']['version']}/"
prefix = node['nodejs']['prefix_url']['node']
filename = "node-v#{node['nodejs']['version']}-linux-#{arch}.tar.gz"
archive_name = 'nodejs-binary'
binaries = ['bin/node']
binaries.push('bin/npm') if node['nodejs']['npm']['install_method'] == 'embedded'

View File

@@ -1,11 +1,11 @@
#
# Author:: Nathan L Smith (nlloyds@gmail.com)
# Author:: Marius Ducea (marius@promethost.com)
# Cookbook Name:: nodejs
# Cookbook:: nodejs
# Recipe:: package
#
# Copyright 2012, Cramer Development, Inc.
# Copyright 2013, Opscale
# Copyright:: 2012-2017, Cramer Development, Inc.
# Copyright:: 2013-2017, Opscale
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,8 +20,6 @@
# limitations under the License.
#
node.force_override['nodejs']['install_method'] = 'package' # ~FC019
include_recipe 'nodejs::repo' if node['nodejs']['install_repo']
unless node['nodejs']['packages']

View File

@@ -1,9 +1,9 @@
#
# Author:: Marius Ducea (marius@promethost.com)
# Cookbook Name:: nodejs
# Cookbook:: nodejs
# Recipe:: source
#
# Copyright 2010-2012, Promet Solutions
# Copyright:: 2010-2017, Promet Solutions
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,29 +20,19 @@
Chef::Recipe.send(:include, NodeJs::Helper)
node.force_override['nodejs']['install_method'] = 'source' # ~FC019
include_recipe 'build-essential'
case node['platform_family']
when 'rhel', 'fedora'
package 'openssl-devel'
package 'xz'
when 'rhel', 'fedora', 'amazon'
package %w(openssl-devel tar)
when 'debian'
package 'libssl-dev'
package 'xz-utils'
end
version = "v#{node['nodejs']['version']}/"
prefix = node['nodejs']['prefix_url'][node['nodejs']['engine']]
if node['nodejs']['engine'] == 'iojs'
filename = "iojs-v#{node['nodejs']['version']}.tar.xz"
archive_name = 'iojs-source'
else
filename = "node-v#{node['nodejs']['version']}.tar.xz"
archive_name = 'nodejs-source'
end
prefix = node['nodejs']['prefix_url']['node']
filename = "node-v#{node['nodejs']['version']}.tar.gz"
archive_name = 'nodejs-source'
nodejs_src_url = node['nodejs']['source']['url'] || ::URI.join(prefix, version, filename).to_s

View File

@@ -1,9 +1,9 @@
#
# Author:: Marius Ducea (marius@promethost.com)
# Cookbook Name:: nodejs
# Cookbook:: nodejs
# Recipe:: npm
#
# Copyright 2010-2012, Promet Solutions
# Copyright:: 2010-2017, Promet Solutions
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.

View File

@@ -1,9 +1,9 @@
#
# Author:: Marius Ducea (marius@promethost.com)
# Cookbook Name:: nodejs
# Cookbook:: nodejs
# Recipe:: npm
#
# Copyright 2010-2012, Promet Solutions
# Copyright:: 2010-2017, Promet Solutions
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,9 +20,7 @@
Chef::Recipe.send(:include, NodeJs::Helper)
node.force_override['nodejs']['npm']['install_method'] = 'source' # ~FC019
include_recipe 'nodejs::install'
include_recipe 'nodejs::nodejs_from_source'
dist = npm_dist

View File

@@ -1,10 +1,11 @@
node['nodejs']['npm_packages'].each do |pkg|
f = nodejs_npm pkg['name'] do
pkg_action = pkg.key?('action') ? pkg['action'] : :install
f = npm_package "nodejs_npm-#{pkg['name']}-#{pkg_action}" do
action :nothing
package pkg['name']
end
pkg.each do |key, value|
f.send(key, value) unless key == 'name' || key == 'action'
end
action = pkg.key?('action') ? pkg['action'] : :install
f.action(action)
f.action(pkg_action)
end if node['nodejs'].key?('npm_packages')

View File

@@ -1,6 +1,8 @@
case node['platform_family']
when 'debian'
include_recipe 'apt'
package 'nodejs-apt-transport-https' do
package_name 'apt-transport-https'
end
apt_repository 'node.js' do
uri node['nodejs']['repo']
@@ -9,6 +11,10 @@ when 'debian'
keyserver node['nodejs']['keyserver']
key node['nodejs']['key']
end
when 'rhel'
include_recipe 'yum-epel'
when 'rhel', 'amazon'
yum_repository 'node.js' do
description 'nodesource.com nodejs repository'
baseurl node['nodejs']['repo']
gpgkey node['nodejs']['key']
end
end