HowTo install custom nodejs version (14.2.0) on AWS Opsworks Chef 11/12 stack

279 Views Asked by At

I have a nodejs express app that makes use of some ES6 features, so it needs nodejs way above 0.12.18. But the AWS Opsworks Chef 11 stack only offers NodeJs up to 0.12.18.

I tried using my own custom cookbook/recipe and created 'opsworks_nodejs/attributes/customize.rb':

normal[:opsworks_nodejs][:version] = '14.2.0'
normal[:opsworks_nodejs][:prefix_url][:node] = 'https://rpm.nodesource.com/pub_14.x/el/7/x86_64/'
normal[:opsworks_nodejs][:rpm] = "nodejs-14.2.0-1nodesource.x86_64.rpm"
normal[:opsworks_nodejs][:rpm_url] = "https://rpm.nodesource.com/pub_14.x/el/7/x86_64/nodejs-14.2.0-1nodesource.x86_64.rpm"

But the setup fails and the logs show me that it tried to download a file that does not exist. It ignores my changes (except for the version part):

https://opsworks-instance-assets-eu-west-1.s3.amazonaws.com/packages/amazon/2018.03/opsworks-nodejs-14.2.0-1.x86_64.rpm

I wonder if there is a way to use the Chef 11 stack just like it is and only change the nodejs version to 14.2.0, as i am used to all the other recipes in use there, especially the deploy mechanism. All i want to differ is the node.js version.

If not, am i right in assuming that i have to use a Chef 12 stack that doesn't have those recipes pre-set? What would be the easiest way to just get nodejs 14.2.0 installed and still be able to use the convenient "Deploy"-feature the Chef 11 stack offers?

1

There are 1 best solutions below

1
seshadri_c On

FWIW, adding this as an answer. There is a recommendation to use "at least" v14.10.9.

The minimum supported version of chef-client on nodes associated with an AWS OpsWorks for Chef Automate server is 13.x. We recommend running at least 14.10.9, or the most current, stable chef-client version.

If you can have Chef client v14+ available, then you should be able to use the nodejs cookbook from Chef supermarket. Using Berkshelf (Berksfile) we should be then able to pull this as a dependency.

source 'https://supermarket.chef.io'

cookbook 'nodejs'

The sequence usually is:

Add dependency for community cookbook in metadata.rb:

name 'my_cookbook'
version '0.1.0'

depends 'nodejs', '~> 7.3.0'

Update / set the required attributes in attributes/default.rb or may be customize.rb:

default['nodejs']['install_method'] = 'binary'

default['nodejs']['version'] = '14.2.0'
default['nodejs']['binary']['checksum'] = '3307d8b95014e78b43f85242a03fe3b28edfb90cc15e1d26393dcbbc51d05c8e'

Then in a recipes/default.rb:

include_recipe 'nodejs'