ruby on rails - Error Trying to use Rubber to deploy on EC2 -
i'm following railscast #347 (http://railscasts.com/episodes/347-rubber-and-amazon-ec2) deploying app on amazon ec2. following steps, when try execute command cap rubber:create_staging
error showed me /users/juampi/.rvm/gems/ruby-2.2.1/gems/rubber-3.2.0/lib/rubber/cloud/aws/base.rb:75:in
before_create_instance': undefined method instance_alias' #<rubber::configuration::instanceitem:0x007f9fce9704f8> (nomethoderror)
here entire output
cap rubber:create_staging triggering load callbacks * 2016-01-16 18:24:12 executing `rubber:init' * 2016-01-16 18:24:13 executing `rubber:create_staging' hostname use staging instance [production]: roles use staging instance [apache,app,collectd,common,db:primary=true,elasticsearch,examples,graphite_server,graphite_web,graylog_elasticsearch,graylog_mongodb,graylog_server,graylog_web,haproxy,mongodb,monit,passenger,postgresql,postgresql_master,web,web_tools]: * 2016-01-16 18:24:15 executing `rubber:create' /users/juampi/.rvm/gems/ruby-2.2.1/gems/rubber-3.2.0/lib/rubber/cloud/aws/base.rb:75:in `before_create_instance': undefined method `instance_alias' #<rubber::configuration::instanceitem:0x007f9fce9704f8> (nomethoderror) /users/juampi/.rvm/gems/ruby-2.2.1/gems/rubber-3.2.0/lib/rubber/thread_safe_proxy.rb:13:in `method_missing' /users/juampi/.rvm/gems/ruby-2.2.1/gems/rubber-3.2.0/lib/rubber/recipes/rubber/instances.rb:281:in `block in create_instance' /users/juampi/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize' /users/juampi/.rvm/gems/ruby-2.2.1/gems/rubber-3.2.0/lib/rubber/recipes/rubber/instances.rb:280:in `create_instance' /users/juampi/.rvm/gems/ruby-2.2.1/gems/rubber-3.2.0/lib/rubber/recipes/rubber/instances.rb:230:in `block (2 levels) in create_instances'
this gemfile
source 'https://rubygems.org' # bundle edge rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.1.4' # use sqlite3 database active record group :development, :test gem 'sqlite3' end group :production gem 'pg' end gem 'pg_search' #gem 'pg', group: :production #gem 'sqlite3' # use scss stylesheets gem 'sass-rails', '~> 4.0.3' # use uglifier compressor javascript assets gem 'uglifier', '>= 1.3.0' # use coffeescript .js.coffee assets , views gem 'coffee-rails', '~> 4.0.0' # see https://github.com/sstephenson/execjs#readme more supported runtimes # gem 'therubyracer', platforms: :ruby gem 'acts_as_shopping_cart', '~> 0.2.1' # use jquery javascript library gem 'jquery-rails' # turbolinks makes following links in web application faster. read more: https://github.com/rails/turbolinks #gem 'turbolinks' gem 'owlcarousel-rails' # build json apis ease. read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.0' # bundle exec rake doc:rails generates api under doc/api. gem 'sdoc', '~> 0.4.0', group: :doc gem 'hirb' gem 'carrierwave' #gem 'bootstrap-sass', '~> 3.3.0' gem 'devise' gem 'rolify' gem 'cancan' gem 'will_paginate' gem 'will_paginate-bootstrap' #gem "twitter-bootstrap-rails" gem 'therubyracer', :platform => :ruby gem 'materialize-sass' gem 'rails_12factor', group: :production gem 'puma' gem 'cloudinary' gem 'mercadopago' group :development gem 'capistrano', '~> 2.12' end #gem 'capistrano', '~> 2.12' #gem 'libv8', '3.11.8.0' # use activemodel has_secure_password # gem 'bcrypt', '~> 3.1.7' # use unicorn app server # gem 'unicorn' # use capistrano deployment # gem 'capistrano-rails', group: :development # use debugger # gem 'debugger', group: [:development, :test] # windows not include zoneinfo files, bundle tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin] gem 'rubber', '~> 3.1' gem 'open4' gem 'gelf' gem 'graylog2_exceptions', :git => 'git://github.com/wr0ngway/graylog2_exceptions.git' gem 'graylog2-resque'
and rubber.yml
# required: name of application app_name: iaw2015 # required: system user run app servers app_user: app # required: notification emails (e.g. monit) sent address # admin_email: "root@#{full_host}" # optional: if not set, won't able access web_tools # server (graphite, graylog, monit status, haproxy status, etc) # web_tools_user: admin # web_tools_password: sekret # required: timezone server should in timezone: us/eastern # required: domain instances should associated # domain: foo.com # optional: see rubber-dns.yml dns configuration # lets rubber update dynamic dns service instance alias # , ip when created. allows setting arbitrary # dns records (cname, mx, round robin dns, etc) # optional: additional rubber file pull config if exists. file # pushed remote host @ rubber.root/config/rubber/rubber-secret.yml # # rubber_secret: "#{file.expand_path('~') + '/.ec2' + (rubber.env == 'production' ? '' : '_dev') + '/rubber-secret.yml' rescue 'rubber-secret.yml'}" # optional: encryption key used obfuscate contents of rubber-secret.yml "rubber util:obfuscation" # not better when stored in here, use ruby snippet in here fetch key server or # # rubber_secret_key: "xxxyyy==" # required known cloud providers settings needed configure them # there's 1 working cloud provider right - amazon web services # implement another, clone lib/rubber/cloud/aws.rb or make fog provider # work in generic fashion # cloud_providers: aws: # required aws region want use. # # options include # ap-northeast-1 # asia pacific (tokyo) region # ap-southeast-1 # asia pacific (singapore) region # ap-southeast-2 # asia pacific (sydney) region # eu-west-1 # eu (ireland) region # sa-east-1 # south america (sao paulo) region # us-east-1 # east (northern virginia) region # us-west-1 # west (northern california) region # us-west-2 # west (oregon) region # region: us-east-1 # required amazon keys , account id (digits only, no dashes) used access aws api # access_key: #myaccesskey secret_access_key: #mysecretaccesskey account: #myaccount # required: name of amazon keypair , location of private key # # note: reason capistrano requires have both public , # private key in same folder, public key should have # extension ".pub". easiest way hand on create # public key private key: ssh-keygen -y -f gsg-keypair > gsg-keypair.pub # key_name: gsg-keypair key_file: "#{dir[(file.expand_path('~') rescue '/root') + '/.ec2/*' + cloud_providers.aws.key_name].first}" # optional: needed bundling running instance using rubber:bundle # # pk_file: "#{dir[(file.expand_path('~') rescue '/root') + '/.ec2/pk-*'].first}" # cert_file: "#{dir[(file.expand_path('~') rescue '/root') + '/.ec2/cert-*'].first}" # image_bucket: "#{app_name}-images" # optional: needed backing database s3 # backup_bucket: "#{app_name}-backups" # optional: define vpc deploy to. alias can thought of # unique rubber-specific id. if vpc_alias , vpc_addr absent, rubber # instead assume we're deploying ec2 classic # vpc_alias: "#{app_name}_#{rubber.env == 'production' ? 'production' : 'development'}" # vpc_cidr: 10.0.0.0/16 # vpcs typically have 2 subnets - 1 instances need # direct internet connection (load balancers, etc.), , 1 instances # don't (database servers, app servers, etc.). @ least, # we'll need public subnet. rubber detect instance's private_nic # configuration, , auto-create subnet if appropriate. instances on # public subnet need following configuration. # important note aws vpc subnets availability zone-specific, # meaning want specify availability zone # instance. have specify different subnet_cidr each # availability zone, since subnets cannot overlap. # private_nic: # subnet_cidr: '10.0.0.0/24' # gateway: public # private subnet, need configure nat_gateway instance in # public subnet machines can still reach outside world # things software updates. after configuring nat gateway, can # set separate private subnet. need set :gateway # capistrano configuration value full hostname of nat gateway in # order communicate instances on private subnets. instances # on private subnet need following configuration # private_nic: # subnet_cidr: '10.0.1.0/24' # gateway: "#{rubber_instances.for_role('nat_gateway').first.instance_id}" # required: ami , instance type creating instances # ubuntu images @ http://old.alestic.com/ work # ubuntu 14.04.1 trusty instance-store 64-bit: ami-92f569fa # # m1.small or m1.large or m1.xlarge image_type: t2.micro image_id: ami-60b6c60a # optional: provide fog-specific options directly. should used if need special setting # rubber not directly expose. since these settings passed directly through fog, can't make # guarantee how work (if fog renames attribute, e.g., config break). please see fog # source code option names. # fog_options: # ebs i/o optimized instance # ebs-optimized instances deliver dedicated throughput between amazon ec2 , amazon ebs, options # between 500 mbps , 1000 mbps depending on instance type used. # read more , make sure image_type supports ebs_optimized function at: http://aws.amazon.com/ec2/instance-types/ # ebs_optimized: false # optional: ec2 spot instance request support. # # enables creation of spot instance requests. rubber wait synchronously until request fulfilled, # @ point begin initializing instance, unless spot_instance_request_timeout set. # spot_instance: true # # maximum price pay spot instance. # spot_price: "0.085" # # if spot instance request can't fulfilled in 3 minutes, fallback on-demand instance creation. if not set, # default infinite. # spot_instance_request_timeout: 180 digital_ocean: # required: digital ocean region want use. # # options include # new york 1 # amsterdam 1 # san francisco 1 # new york 2 # amsterdam 2 # singapore 1 # # these change often. check https://www.digitalocean.com/droplets/new date options. # default new york 2 since region supports private networking region: new york 2 # required: image name , type creating instances. image_id: 14.04 x64 image_type: 512mb # optionally enable private networking instances. # supported in new york 2. private_networking: true # use alternate cloud provider supported fog. doesn't work # yet due differences in providers within fog, gives starting # point contributing new provider rubber. see rubber/lib/rubber/cloud(.rb) fog: credentials: provider: rackspace rackspace_api_key: 'xxx' rackspace_username: 'yyy' image_type: 123 image_id: 123 # required cloud provider use # cloud_provider: aws # optional: store instance data. # # allowed forms are: # filesystem: "file:#{rubber.root}/config/rubber/instance-#{rubber.env}.yml" # cloud storage (s3): "storage:#{cloud_providers.aws.backup_bucket}/rubberinstances_#{app_name}/instance-#{rubber.env}.yml" # cloud table (simpledb): "table:rubberinstances_#{app_name}_#{rubber.env}" # # if need port between forms, load rails console then: # rubber.instances.save(location) # location 1 of allowed forms variable # # instance_storage: "file:#{rubber.root}/config/rubber/instance-#{rubber.env}.yml" # optional: store backup of instance data # # useful when using remote store in case end # wiping single copy of instance data. when using file # store, instance file typically under version control # project code, provides safety. # # instance_storage_backup: "storage:#{cloud_providers.aws.backup_bucket}/rubberinstances_#{app_name}/instance-#{rubber.env}-#{time.now.strftime('%y%m%d-%h%m%s')}.yml" # optional: default ports security groups web_port: 80 web_ssl_port: 443 web_tools_port: 8080 web_tools_ssl_port: 8443 # optional: define security groups # each security group name associated sequence of maps # keys parameters ec2 authorizesecuritygroupingress api # source_security_group_name, source_security_group_owner_id # ip_protocol, from_port, to_port, cidr_ip # if want use source_group outside of project, add "external_group: true" # prevent group_isolation mangling name, e.g. give access graphite # server other projects # # security_groups: # graphite_server: # description: graphite_server security group allow projects send graphite data # rules: # - source_group_name: yourappname_production_collectd # source_group_account: 123456 # external_group: true # protocol: tcp # from_port: "#{graphite_server_port}" # to_port: "#{graphite_server_port}" # security_groups: default: description: default security group rules: - source_group_name: default source_group_account: "#{cloud_providers.aws.account}" - protocol: tcp from_port: 22 to_port: 22 source_ips: [0.0.0.0/0] web: description: "to open port #{web_port}/#{web_ssl_port} http server on web role" rules: - protocol: tcp from_port: "#{web_port}" to_port: "#{web_port}" source_ips: [0.0.0.0/0] - protocol: tcp from_port: "#{web_ssl_port}" to_port: "#{web_ssl_port}" source_ips: [0.0.0.0/0] web_tools: description: "to open port #{web_tools_port}/#{web_tools_ssl_port} internal/tools http server" rules: - protocol: tcp from_port: "#{web_tools_port}" to_port: "#{web_tools_port}" source_ips: [0.0.0.0/0] - protocol: tcp from_port: "#{web_tools_ssl_port}" to_port: "#{web_tools_ssl_port}" source_ips: [0.0.0.0/0] # optional: default security groups create instances assigned_security_groups: [default] roles: web: assigned_security_groups: [web] web_tools: assigned_security_groups: [web_tools] # optional: automatically create security groups each host , role # ec2 classic doesn't allow 1 change groups instance belongs after # creation, it's have empty ones predefined. ec2 vpc, however, # allow changing security groups after instance creation , allows far fewer # security groups per instance, shouldn't enable setting if using vpc. auto_security_groups: false # optional: automatically isolate security groups each appname/environment # mangling names appname_env_groupname # makes safer have staging , production coexist on same ec2 # account, or multiple apps. nb: due security group limits per instance # in ec2 vpcs, option should enabled if you're using ec2 classic. isolate_security_groups: false # optional: prompts 1 sync security group rules when ones in amazon # differ in rubber prompt_for_security_group_sync: true # optional: list of cidr address blocks represent private networks cluster. # set open wide access hosts in network. consequently, setting cidr block # other private, unroutable block massive security hole. private_networks: [10.0.0.0/8] # optional: packages install on instances # can install specific version of package using sub-array of pkg, version # example, packages: [[rake, 0.7.1], irb] packages: [postfix, build-essential, git-core, libxslt-dev, ntp] # optional: package manager mirror use installation of primary packages (i.e., not explicitly # sourced different repository). if not specified, whatever mirror configured server image # used. # # note ubuntu has special url can used auto-select mirror based upon geoip. use # it, specify 'mirror://mirrors.ubuntu.com/mirrors.txt' value. # package_manager_mirror: 'mirror://mirrors.ubuntu.com/mirrors.txt' # optional: command used identify particular os version. used configurations # in rubber templates parameterized os version (e.g., package lists). if not specified, ubuntu # assumed. os_version_cmd: 'lsb_release -sr' # optional: gem sources setup rubygems # gemsources: ["https://rubygems.org"] # optional: gems install on instances # can install specific version of gem using sub-array of gem, version # example, gem: [[rails, 4.2.1], bundler] gems: [bundler, [rubber, "#{rubber.version}"]] # optional: string prepended shell command strings cause multi # statement shell commands fail fast. may need comment out # on platforms, works me on linux/osx bash shell # stop_on_error_cmd: "function error_exit { exit 99; }; trap error_exit err" # optional: default set of roles use when creating staging instance # "cap rubber:create_staging". default uses known roles, # excluding slave roles, not desired staging, can # specify different set here # # staging_roles: "web,app,db:primary=true" # auto detect staging roles staging_roles: "#{known_roles.reject {|r| r =~ /slave/ || r =~ /^db$/ }.join(',')}" # optional: lets 1 assign amazon elastic ips (static ips) instances # should typically set on role/host level rather # globally , unless want instances have # static ip # # use_static_ip: true # optional: specifies instance created in given availability zone # availability zones sepcified amazon isolated # each other hardware failures in 1 zone shouldn't # affect instances in another. such, specify these # instances need redundant reduce chance of # downtime. should typically set on role/host level # rather globally. use cap rubber:describe_zones see list # of zones # availability_zone: us-east-1a # optional: if want use elastic block store (ebs) persistent # volumes, add them host specific overrides , created # , assigned instance. on initial creation, volume # attached _and_ formatted, if host disappears , recreate # it, volume remounted thereby preserving data # # hosts: # my_host: # availability_zone: us-east-1a # volumes: # - size: 100 # size of vol in gbs # zone: us-east-1a # zone create volume in, needs match host's zone # device: /dev/sdh # os device attach volume # mount: /mnt/mysql # directory mount volume # filesystem: ext4 # filesystem create on volume # # # optional: provide fog-specific options directly. should used if need special setting # # rubber not directly expose. since these settings passed directly through fog, can't make # # guarantee how work (if fog renames attribute, e.g., config break). please see fog # # source code option names. # fog_options: # type: gp2 # type of volume, standard (ebs magnetic), io1 (provisioned iops - ssd), or gp2 (general purpose - ssd). # iops: 500 # number of i/o operations per second (iops) volume supports. # # required when volume type io1; not used non-provisioned iops volumes. # - size: 10 # zone: us-east-1a # device: /dev/sdi # mount: /mnt/logs # filesystem: ext4 # fog_options: # type: io1 # iops: 500 # # # volumes without mount/filesystem can used in raid arrays # # - size: 50 # zone: us-east-1a # device: /dev/sdx # fog_options: # type: gp2 # iops: 500 # - size: 50 # zone: us-east-1a # device: /dev/sdy # fog_options: # type: gp2 # iops: 500 # # # use ephemeral volumes raid array # local_volumes: # - partition_device: /dev/sdb # zero: false # zeros out disk improved performance # - partition_device: /dev/sdc # zero: false # zeros out disk improved performance # # # raid array, you'll need add mdadm packages. likewise, # # xfsprogs needed xfs filesystem support # # # packages: [xfsprogs, mdadm] # raid_volumes: # - device: /dev/md0 # os device to create raid array on # mount: /mnt/fast # directory mount array # mount_opts: 'nobootwait' # recent ubuntu versions require flag or ssh not start on reboot # filesystem: xfs # filesystem create on array # filesystem_opts: -f # filesystem opts in mkfs # raid_level: 0 # raid level use array # # if you're using ubuntu 11.x or later (natty, oneiric, precise, etc) # # want specify source devices in /dev/xvd format # # see https://bugs.launchpad.net/ubuntu/+source/linux/+bug/684875 # # more information. # # note: make change raid source_devices, not generic # # volume commands above. # source_devices: [/dev/sdx, /dev/sdy] # source ebs devices creating raid array (ubuntu lucid or older) # source_devices: [/dev/xvdx, /dev/xvdy] # source ebs devices creating raid array (ubuntu natty or newer) # # # lvm volumes, you'll need add lvm2 packages. likewise, # # xfsprogs needed xfs filesystem support # packages: [xfsprogs, lvm2] # lvm_volume_groups: # - name: vg # volume group name # physical_volumes: [/dev/sdx, /dev/sdy] # devices used lvm group (you can use one, can't stripe then) # extent_size: 32 # size of volume extent in mb # volumes: # - name: lv # name of logical volume # size: 999.9 # size of volume in gb (slightly less sum of physical volumes because lvm reserves space) # stripes: 2 # count of stripes volume # filesystem: xfs # filesystem create on logical volume # filesystem_opts: -f # filesystem opts in mkfs # mount: /mnt/large_work_dir # directory mount lvm volume # optional: can define own variables here use when # transforming config files, , available in config # templates <%%= rubber_env.var_name %> # # var_name: var_value # variables can overridden on role, environment and/or host level creating # sub level config under roles, environments , hosts. precedence host, environment, role # e.g. install mysql on db role, , awstats on web01: # optional: role specific overrides # roles: # somerole: # packages: [] # somerole2: # myconfig: someval # optional: environment specific overrides # environments: # staging: # myconfig: otherval # production: # myconfig: val # optional: host specific overrides # hosts: # somehost: # packages: []
Comments
Post a Comment