aws / opsworks-cookbooks

Chef Cookbooks for the AWS OpsWorks Service
Other
1.06k stars 1.23k forks source link

Getting Opsworks to use specific Ruby 2.4 version #426

Open kalpitad opened 5 years ago

kalpitad commented 5 years ago

I have an Opsworks stack with a Rails layer. I need to upgrade Ruby beyond 2.3 because it is reaching end of life. "Ruby 2.3 is now under the state of the security maintenance phase, until the end of March of 2019. After that date, maintenance of Ruby 2.3 will be ended." https://www.ruby-lang.org/en/news/2018/10/17/ruby-2-3-8-released/

Given the state of Ruby 2.3, I don't understand why it is the highest version of Ruby that can be changed to in the Opsworks console, but when I reached out to AWS Developer Support, they told me to do the upgrade manually. So, I ran the following commands: sudo yum install ruby24 -y sudo alternatives --set ruby /usr/bin/ruby2.4

And now, when I run ruby -v, I get the response: ruby 2.4.4p296 (2018-03-28 revision 63013) [x86_64-linux-gnu]

However, I'm having trouble getting Opsworks to recognize and use this version of Ruby.

Looking at the Opsworks ruby cookbook (https://github.com/aws/opsworks-cookbooks/blob/release-chef-11.10/ruby/attributes/ruby.rb) and through trial and error, I figured out that the attributes that I need to pass in during app deployment are:

{
    "opsworks": {
        "ruby_version": "2.4"
    },
    "ruby": {
        "version": "2.4.4",
        "pkgrelease": "1"
    }
}

However, deployment fails because Opsworks can't find the .rpm file in the S3 bucket where it looks. From the deployment logs:

...
[2018-12-11T00:14:52+00:00] WARN: Unsupported Ruby version '2.4'. Unable to set passenger gems_path
...
[2018-12-11T00:15:02+00:00] WARN: Unsupported Ruby version '2.4'. Unable to set passenger gems_path.
...
================================================================================
Error executing action `install` on resource 'opsworks_commons_assets_installer[Install user space OpsWorks ruby package]'
================================================================================
Chef::Exceptions::ResourceNotFound
----------------------------------
Failed to download asset opsworks-ruby for Install user space OpsWorks ruby package with url https://opsworks-instance-assets-us-west-2.s3.amazonaws.com/packages/amazon/2018.03/opsworks-ruby-2.4.4-1.x86_64.rpm.
The asset is probably not available for your operating system (amazon 2018.03).
Please have a look what versions are supported for this operating system at:
http://docs.aws.amazon.com/opsworks/latest/userguide/workinginstances-os-linux.html

Per this page: https://aws.amazon.com/amazon-linux-ami/2018-03-packages/, the ruby24-2.4.4 package should be included. So why can't it be found during the deployment process?

How do I get past this error? As you can see, I'm running Amazon Linux AMI 2018.03.

eschie commented 4 years ago

Did you ever solve this @kalpitad ?