Using Ruby 2.0 on Amazon OpsWorks
OpsWorks now fully supports Ruby 2.0, in Layer settings you can specify the version of Rails, Bundler and Rubygems.
How to start rails console in AWS OpsWorks
Fix
- Use root / su account
- Delete Gemfile.lock
- install rails and bundler gems
- $ bundle install --binstubs
- gem 'sprockets', '~>3.0'in Gemfile
- bundle update sprockets
- $ RAILS_ENV=production bundle exec rails console
Note: * Commit the new / modified files.
Set environment variables with AWS Opsworks
This can now be done directly from the AWS Console, on the application configuration, as per documentation : http://docs.aws.amazon.com/opsworks/latest/userguide/workingapps-creating.html#workingapps-creating-environment
Opsworks : Rails App Layer : specify Ruby minor version
Ah ha, I picked up tips from some old doco I think.
By reading the aws/opsworks code I corrected my custom json to this:
"ruby": {
"version": "2.1.2"
}
and it worked!
Actually, this is only partially a correct answer.
I have one stack that responded to this and downgraded correctly and another stack that would not downgrade my ruby version, it reports this on "update_dependencies" and continues to fail on deploy.
Userspace Ruby version is up-to-date (2.1)
only my version when logged in is 2.1.5.
Many many re-deploys and update dependencies later eventually they all updated.
Change hostname in AWS OpsWorks (Chef)
I figured it out. You're suppose to override the default template in Chef that AWS provides.
Extending AWS OpsWorks Configuration Files Using Custom Templates
So in my cookbook, I made a file called:
opsworks_stack_state_sync/templates/default/hosts.erb
Add the file looks like this:
# This file was generated by OpsWorks
# any manual changes will be removed on the next update.
# Set the hostname with proper format, the rest are aliases.
127.0.0.1 localhost localhost.example.com
127.0.1.1 <%= node[:opsworks][:instance][:hostname] %>.example.com <%= node[:opsworks][:instance][:hostname] %>
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
# OpsWorks Layer State
<% seen = [] -%>
<% node[:opsworks][:layers].each do |layer_name, layer_config| -%>
<% layer_config[:instances].each do |instance_name, instance_config| -%>
<% if !seen.include?(instance_name) && instance_config[:private_ip] -%>
<%= Resolv.getaddress(instance_config[:private_ip]) %> <%= instance_name %>
<% if instance_config[:ip] %>
<%= Resolv.getaddress(instance_config[:ip]) %> <%= instance_name %>-ext
<% end %>
<% seen << instance_name %>
<% end -%>
<% end -%>
<% end -%>
And that will set your hostname to apple-pie.example.com.
Related Topics
How to Use Fiddle to Pass or Return a Struct to Native Code
Sqlite3-Ruby Gem Can't Find SQLite3.H on Ubuntu
Rails Sitemap_Generator Uninitialized Constant
Did I Install Ruby 1.9.3 Correctly on Rhel
"The Ruby Way" (Mixins and Class Reopening) VS. Dependency Injection
Re-Opened Nested Module Anomaly in Ruby
Ruby/Rails - How to Create a Class and Access It from the Controller
Rvm with Jruby 1.7.0 "Unknown Ruby Interpreter"
Using CSS to Style Ruby Objects in Erb
What Are These Numbers in Goto Anything of Sublime Text 2
How to Restart Rails from Within Rails
How to Host a Rails Web Application
How to Remove All Characters in a String Until a Substring Is Matched, in Ruby
Converting Time in Utc to Pacific Time