Search code examples
node.jschef-infraubuntu-16.04aws-opsworkscookbook

specific nodejs version, opsworks_ruby, aws, chef 12


Can anyone point me in the write direction for installing a specific nodejs version when running chef 12 on AWS opsworks?

Infrastructure: EC2,t2.micro,ubuntu 16.04 LTS

custom cookbook:

File: recipes/default.rb

node.default['packages-cookbook'] = [
 'libmysqlclient-dev',
 'libmysqlclient20',
 'pkg-config',
 'libswitch-perl',
 'nodejs',
 'yarn'
]

File: Berksfile

source 'https://supermarket.chef.io'
cookbook 'opsworks_ruby', '1.8.0'
cookbook 'packages', '~> 1.0.0'
metadata

File: metadata.rb

chef_version '>= 12.1' if respond_to?(:chef_version)
depends 'opsworks_ruby', '1.8.0'
depends 'packages', '~> 1.0.0'

AWS Custom json

"ruby-ng": {
    "ruby_version": "2.4"
},
"nodejs": {
    "version": "8.9.1"
}

The build is failing due to installed nodejs version of 4.2.6 when the build requires a higher version. Any suggestions would be greatly appreciated!


Solution

  • Via poise-javascript:

    javascript_runtime '8.9.1'
    

    or in a role/wrapper:

    default['poise-javascript']['options']['version'] = '8.9.1'
    

    By default it installs from the static binaries from the NodeJS project so it should support any version.