issue with vagrant aws-provider - amazon-web-services

I am trying to spin up EC2 with a vagrant AWS provider . I have following Vagrantfile
# Require the AWS provider plugin
require 'vagrant-aws'
# Create and configure the AWS instance(s)
Vagrant.configure('2') do |config|
# Use dummy AWS box
config.vm.box = 'aws-dummy'
# Specify AWS provider configuration
config.vm.provider 'aws' do |aws, override|
# Read AWS authentication information from environment variables
aws.access_key_id = ENV['AWS_ACCESS_KEY_ID']
aws.secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
# Specify SSH keypair to use
aws.keypair_name = 'AWS_KEY_PAIR'
# Specify region, AMI ID, and security group(s)
aws.region = 'us-east-1'
aws.ami = 'ami-0149b2da6ceec4bb0'
aws.security_groups = ['ENDHOSTS-SG']
# Specify username and private key path
override.ssh.username = 'ubuntu'
override.ssh.private_key_path = '~/.ssh/key_pair_zhajili_AWS.pem'
end
end
But unfortunately, I am receiving the following error
\King Julien$ vagrant up --provider=aws
There are errors in the configuration of this machine. Please fix
the following errors and try again:
\King Julien$ vagrant up --provider=aws
Traceback (most recent call last):
25: from /opt/vagrant/embedded/gems/2.3.3/gems/vagrant-2.3.3/bin/vagrant:248:in `<main>'
24: from /opt/vagrant/embedded/gems/2.3.3/gems/vagrant-2.3.3/lib/vagrant/environment.rb:301:in `cli'
23: from /opt/vagrant/embedded/gems/2.3.3/gems/vagrant-2.3.3/lib/vagrant/cli.rb:67:in `execute'
22: from /opt/vagrant/embedded/gems/2.3.3/gems/vagrant-2.3.3/plugins/commands/up/command.rb:87:in `execute'
21: from /opt/vagrant/embedded/gems/2.3.3/gems/vagrant-2.3.3/lib/vagrant/plugin/v2/command.rb:186:in `with_target_vms'
20: from /opt/vagrant/embedded/gems/2.3.3/gems/vagrant-2.3.3/lib/vagrant/plugin/v2/command.rb:186:in `each'
19: from /opt/vagrant/embedded/gems/2.3.3/gems/vagrant-2.3.3/lib/vagrant/plugin/v2/command.rb:204:in `block in with_target_vms'
18: from /opt/vagrant/embedded/gems/2.3.3/gems/vagrant-2.3.3/lib/vagrant/plugin/v2/command.rb:180:in `block in with_target_vms'
17: from /opt/vagrant/embedded/gems/2.3.3/gems/vagrant-2.3.3/lib/vagrant/environment.rb:740:in `machine'
16: from /opt/vagrant/embedded/gems/2.3.3/gems/vagrant-2.3.3/lib/vagrant/vagrantfile.rb:83:in `machine'
15: from /opt/vagrant/embedded/gems/2.3.3/gems/vagrant-2.3.3/lib/vagrant/vagrantfile.rb:83:in `new'
14: from /opt/vagrant/embedded/gems/2.3.3/gems/vagrant-2.3.3/lib/vagrant/machine.rb:156:in `initialize'
13: from /opt/vagrant/embedded/gems/2.3.3/gems/vagrant-2.3.3/lib/vagrant/machine.rb:543:in `state'
12: from /Users/zhajili/.vagrant.d/gems/2.7.6/gems/vagrant-aws-0.7.2/lib/vagrant-aws/provider.rb:32:in `state'
11: from /opt/vagrant/embedded/gems/2.3.3/gems/vagrant-2.3.3/lib/vagrant/machine.rb:203:in `action'
10: from /opt/vagrant/embedded/gems/2.3.3/gems/vagrant-2.3.3/lib/vagrant/machine.rb:199:in `block in action'
9: from /opt/vagrant/embedded/gems/2.3.3/gems/vagrant-2.3.3/lib/vagrant/machine.rb:217:in `block in action'
8: from /opt/vagrant/embedded/gems/2.3.3/gems/vagrant-2.3.3/lib/vagrant/machine.rb:248:in `action_raw'
7: from /opt/vagrant/embedded/gems/2.3.3/gems/vagrant-2.3.3/lib/vagrant/action/runner.rb:101:in `run'
6: from /opt/vagrant/embedded/gems/2.3.3/gems/vagrant-2.3.3/lib/vagrant/util/busy.rb:19:in `busy'
5: from /opt/vagrant/embedded/gems/2.3.3/gems/vagrant-2.3.3/lib/vagrant/action/runner.rb:101:in `block in run'
4: from /opt/vagrant/embedded/gems/2.3.3/gems/vagrant-2.3.3/lib/vagrant/action/builder.rb:180:in `call'
3: from /opt/vagrant/embedded/gems/2.3.3/gems/vagrant-2.3.3/lib/vagrant/action/warden.rb:48:in `call'
2: from /opt/vagrant/embedded/gems/2.3.3/gems/vagrant-2.3.3/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
1: from /opt/vagrant/embedded/gems/2.3.3/gems/vagrant-2.3.3/lib/vagrant/action/warden.rb:48:in `call'
/Users/zhajili/.vagrant.d/gems/2.7.6/gems/vagrant-aws-0.7.2/lib/vagrant-aws/action/connect_aws.rb:41:in `call': undefined method `except' for #<Hash:0x00007f7fa0a1a258> (NoMethodError)
I found the following discussion, but the workaround did not work for me .
https://github.com/mitchellh/vagrant-aws/issues/566
I have the following installed software
Vagrant 2.3.3
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-darwin22]

Related

Error with vagrant up for aws

Triying to run vagrant up --provider=aws I get the following error.
/opt/vagrant/embedded/gems/2.1.0/gems/vagrant-2.1.0/lib/vagrant/machine.rb:164:in `action': undefined method `fire_triggers' for nil:NilClass (NoMethodError)
from /home/martin/.vagrant.d/gems/2.4.4/gems/vagrant-aws-0.7.2/lib/vagrant-aws/provider.rb:32:in `state'
from /opt/vagrant/embedded/gems/2.1.0/gems/vagrant-2.1.0/lib/vagrant/machine.rb:521:in `state'
from /opt/vagrant/embedded/gems/2.1.0/gems/vagrant-2.1.0/lib/vagrant/machine.rb:145:in `initialize'
from /opt/vagrant/embedded/gems/2.1.0/gems/vagrant-2.1.0/lib/vagrant/vagrantfile.rb:79:in `new'
from /opt/vagrant/embedded/gems/2.1.0/gems/vagrant-2.1.0/lib/vagrant/vagrantfile.rb:79:in `machine'
from /opt/vagrant/embedded/gems/2.1.0/gems/vagrant-2.1.0/lib/vagrant/environment.rb:700:in `machine'
from /opt/vagrant/embedded/gems/2.1.0/gems/vagrant-2.1.0/lib/vagrant/plugin/v2/command.rb:180:in `block in with_target_vms'
from /opt/vagrant/embedded/gems/2.1.0/gems/vagrant-2.1.0/lib/vagrant/plugin/v2/command.rb:204:in `block in with_target_vms'
from /opt/vagrant/embedded/gems/2.1.0/gems/vagrant-2.1.0/lib/vagrant/plugin/v2/command.rb:186:in `each'
from /opt/vagrant/embedded/gems/2.1.0/gems/vagrant-2.1.0/lib/vagrant/plugin/v2/command.rb:186:in `with_target_vms'
from /opt/vagrant/embedded/gems/2.1.0/gems/vagrant-2.1.0/plugins/commands/up/command.rb:87:in `execute'
from /opt/vagrant/embedded/gems/2.1.0/gems/vagrant-2.1.0/lib/vagrant/cli.rb:54:in `execute'
from /opt/vagrant/embedded/gems/2.1.0/gems/vagrant-2.1.0/lib/vagrant/environment.rb:275:in `cli'
from /opt/vagrant/embedded/gems/2.1.0/gems/vagrant-2.1.0/bin/vagrant:156:in `<main>'
My vagrant file is:
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'vagrant-aws'
Vagrant.configure("2") do |config|
config.vm.box = "aws-dummy"
config.vm.provider :aws do |aws, override|
aws.access_key_id = "my_key_id"
aws.secret_access_key = "my_access_key"
aws.keypair_name = "my_keypair_name"
aws.ami = "ami-916f59f4"
override.ssh.username = "ubuntu"
override.ssh.private_key_path = "/home/my_user/.ssh/id_rsa"
end
end
I'm running vagrant version 2.1.0, I also installed vagrant-aws(0.7.2) plugin.
The question is what i'm doing wrong?
Thanks.
Well, as suggested by PrasadK it seems to be a bug, not the particular one you suggested, but there is a bug in version 2.1.0.
I manually upgrade varian to 2.1.1 and the problem is fixed.

Permission denied # rb_sysopen - /home/david/geofly/config/initializers/sorcery.rb (Errno::EACCES)

I am trying to install omniauth for sorcery. When I run:
rails g sorcery:install external --migrations
gsub config/initializers/sorcery.rb
Traceback (most recent call last):
24: from bin/rails:4:in <main>'
23: from bin/rails:4:inrequire'
22: from /home/david/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/railties-4.2.10/lib/rails/commands.rb:17:in <top (required)>'
21: from /home/david/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:39:inrun_command!'
20: from /home/david/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:50:in generate'
19: from /home/david/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:130:ingenerate_or_destroy'
18: from /home/david/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:123:in require_command!'
17: from /home/david/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:inrequire'
16: from /home/david/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:240:in load_dependency'
15: from /home/david/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:inblock in require'
14: from /home/david/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in require'
13: from /home/david/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/railties-4.2.10/lib/rails/commands/generate.rb:13:in'
12: from /home/david/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/railties-4.2.10/lib/rails/generators.rb:157:in invoke'
11: from /home/david/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/base.rb:466:instart'
10: from /home/david/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/group.rb:232:in dispatch'
9: from /home/david/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/invocation.rb:133:ininvoke_all'
8: from /home/david/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/invocation.rb:133:in map'
7: from /home/david/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/invocation.rb:133:ineach'
6: from /home/david/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/invocation.rb:133:in block in invoke_all'
5: from /home/david/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:ininvoke_command'
4: from /home/david/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/command.rb:27:in run'
3: from /home/david/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sorcery-0.8.6/lib/generators/sorcery/install_generator.rb:31:inconfigure_initializer_file'
2: from /home/david/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/actions/file_manipulation.rb:265:in gsub_file'
1: from /home/david/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/actions/file_manipulation.rb:265:inopen'
/home/david/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/actions/file_manipulation.rb:265:in `initialize': Permission denied # rb_sysopen - /home/david/geofly/config/initializers/sorcery.rb (Errno::EACCES)
I rolled back all migrations and deleted files in db/migrate.
Started fresh with sorcery install guide on wiki.
When migrating, I tried to overwrite files, which resulted in (Errno::EACCES), so I simply manualually deleted these files.
i ran rake db:drop, rake: db:create rake db:migrate.
The production database failed to drop, so I dropped it from termianl with mysql. So far the migrations are working and I successfully migrated SorceryExternal.

Chef: had an error: Net::HTTPServerException: 400 "Bad Request"

I am trying to download file from AWS s3 bucket using chef (aws cookbook available in chef supermarket). I keep receiving following error message.
Net::HTTPServerException
------------------------
remote_file[/etc/chef/encrypted_data_bag_secret] (/var/chef/cache/cookbooks/aws/providers/s3_file.rb line 36) had an error: Net::HTTPServerException: 400 "Bad Request"
For authentication purpose I am using IAM role. I can download same file using aws s3 command line. This means there is no problem with role itself.
Detail log is given below.
Net::HTTPServerException
------------------------
remote_file[/etc/chef/encrypted_data_bag_secret] (/var/chef/cache/cookbooks/aws/providers/s3_file.rb line 36) had an error: Net::HTTPServerException: 400 "Bad Request"
Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/appservers/recipes/appconfig.rb
3: aws_s3_file "/etc/chef/encrypted_data_bag_secret" do
4: bucket "app-chefconfig"
5: remote_path "encrypted_data_bag_secret"
6: end
Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/appservers/recipes/appconfig.rb:3:in `from_file'
aws_s3_file("/etc/chef/encrypted_data_bag_secret") do
action :create
retries 0
retry_delay 2
default_guard_interpreter :default
path "/etc/chef/encrypted_data_bag_secret"
declared_type :aws_s3_file
cookbook_name "appservers"
recipe_name "appconfig"
bucket "app-chefconfig"
remote_path "encrypted_data_bag_secret"
use_etag true
use_last_modified true
atomic_update true
end
Running handlers:
[2015-10-30T05:04:28+00:00] ERROR: Running exception handlers
Running handlers complete
[2015-10-30T05:04:28+00:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 02 seconds
[2015-10-30T05:04:28+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2015-10-30T05:04:28+00:00] ERROR: aws_s3_file[/etc/chef/encrypted_data_bag_secret] (appservers::sosconfig line 3) had an error: Net::HTTPServerException: remote_file[/etc/chef/encrypted_data_bag_secret] (/var/chef/cache/cookbooks/aws/providers/s3_file.rb line 36) had an error: Net::HTTPServerException: 400 "Bad Request"
[2015-10-30T05:04:28+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Stacktrace output:
Generated at 2015-10-30 05:04:28 +0000
Net::HTTPServerException: aws_s3_file[/etc/chef/encrypted_data_bag_secret] (appservers::appconfig line 3) had an error: Net::HTTPServerException: remo
te_file[/etc/chef/encrypted_data_bag_secret] (/var/chef/cache/cookbooks/aws/providers/s3_file.rb line 36) had an error: Net::HTTPServerException: 400
"Bad Request"
/opt/chef/embedded/lib/ruby/2.1.0/net/http/response.rb:119:in `error!'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/http.rb:179:in `streaming_request'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/provider/remote_file/http.rb:60:in `fetch'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/provider/remote_file/content.rb:71:in `grab_file_from_uri'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/provider/remote_file/content.rb:56:in `try_multiple_sources'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/provider/remote_file/content.rb:41:in `file_for_provider'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/file_content_management/content_base.rb:40:in `tempfile'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/provider/file.rb:462:in `tempfile'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/provider/file.rb:339:in `do_generate_content'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/provider/file.rb:150:in `action_create'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/provider.rb:144:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/resource.rb:585:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/runner.rb:49:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/runner.rb:81:in `block (2 levels) in converge'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/runner.rb:81:in `each'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/runner.rb:81:in `block in converge'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/resource_collection/resource_list.rb:83:in `block in execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/resource_collection/stepable_iterator.rb:116:in `call'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/resource_collection/resource_list.rb:81:in `execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/runner.rb:80:in `converge'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/provider.rb:363:in `action_create'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/provider.rb:144:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/resource.rb:585:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/runner.rb:49:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/runner.rb:81:in `block (2 levels) in converge'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/runner.rb:81:in `each'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/runner.rb:81:in `block in converge'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/client.rb:648:in `catch'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/client.rb:648:in `converge'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/client.rb:687:in `converge_and_save'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/client.rb:269:in `run'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/application.rb:270:in `block in fork_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/application.rb:258:in `fork'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/application.rb:258:in `fork_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/application.rb:224:in `block in run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/local_mode.rb:44:in `with_server_connectivity'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/application.rb:212:in `run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/application/client.rb:408:in `block in interval_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/application/client.rb:398:in `loop'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/application/client.rb:398:in `interval_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/application/client.rb:388:in `run_application'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/application.rb:60:in `run'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/bin/chef-client:26:in `<top (required)>'
/usr/bin/chef-client:54:in `load'
/usr/bin/chef-client:54:in `<main>'
Possibly there are some bugs in aws_s3_file. I wrote following recipe to solve this issue.
include_recipe 'aws'
require 'aws-sdk'
client = Aws::S3::Client.new(region: 'us-east-1')
bucket = client.get_object(bucket:'app-chefconfig', key: 'encrypted_data_bag_secret')
# Read content to variable
file_content = bucket.body.read
# Log output (optional)
Chef::Log.info(file_content)
# Write content to file
file '/etc/chef/encrypted_data_bag_secret' do
owner 'root'
group 'root'
mode '0755'
content file_content
action :create
end

Install jenkins slave on Windows (AWS) gives java heap allocation error

I am using the jenkins cookbook to set up a windows slave on AWS. Locally (vagrant on virtualbox), it converges correctly, but when provisioning a new machine on aws using chef-provisioning and the fog driver, I run into the following error:
================================================================================
Error executing action `create` on resource 'jenkins_windows_slave[build-slave]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of "java" -jar "C:\chef\cache/jenkins-cli.jar" -s http://10.0.0.5:8080 groovy C:/Users/ADMINI~1/AppData/Local/Temp/groovy20150312-536-1d2hoy4 ----
STDOUT: Error occurred during initialization of VM
Unable to allocate 61440KB bitmaps for parallel garbage collection for the requested 1966080KB heap.
STDERR: Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
---- End output of "java" -jar "C:\chef\cache/jenkins-cli.jar" -s http://10.0.0.5:8080 groovyC:/Users/ADMINI~1/AppData/Local/Temp/groovy20150312-536-1d2hoy4 ----
Ran "java" -jar "C:\chef\cache/jenkins-cli.jar" -s http://10.0.0.5:8080 groovy C:/Users/ADMINI~1/AppData/Local/Temp/groovy20150312-536-1d2hoy4 returned 1
Resource Declaration:
---------------------
# In C:/chef/cache/cookbooks/xyz_jenkins/recipes/slave_windows.rb
53: jenkins_windows_slave node['jenkins']['node']['name'] do
54: remote_fs node['jenkins']['node']['remote_fs'] # jenkins workspace items stored here
55: group node['jenkins']['node']['group'] # Group with access to remote_fs
56: user node['jenkins']['node']['user'] # user the service runs under (and remote_fs owner)
57: password node['jenkins']['node']['password'] # for user running the service
58: labels node['jenkins']['node']['labels'] # labels on Jenkins master
59: action :create
60: end
Compiled Resource:
------------------
# Declared in C:/chef/cache/cookbooks/xyz_jenkins/recipes/slave_windows.rb:53:in `from_file'
jenkins_windows_slave("build-slave") do
action [:create]
retries 0
retry_delay 2
default_guard_interpreter :default
declared_type :jenkins_windows_slave
cookbook_name "xyz_jenkins"
recipe_name "slave_windows"
remote_fs "C:\\jenkins"
group "Everyone"
user "jenkins"
password "apasswordhere"
labels ["builder", "windows"]
slave_name "build-slave"
end
chef-provisioning's stack trace:
U:/.chefdk/gem/ruby/2.0.0/gems/chef-provisioning-0.19/lib/chef/provisioning/transport/winrm.rb:144:in `error!'
U:/.chefdk/gem/ruby/2.0.0/gems/chef-provisioning-0.19/lib/chef/provisioning/machine/basic_machine.rb:31:in `block in execute'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/mixin/why_run.rb:52:in `call'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/mixin/why_run.rb:52:in `add_action'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/provider.rb:180:in `converge_by'
U:/.chefdk/gem/ruby/2.0.0/gems/chef-provisioning-0.19/lib/chef/provisioning/chef_provider_action_handler.rb:54:in `perform_action'
U:/.chefdk/gem/ruby/2.0.0/gems/chef-provisioning-0.19/lib/chef/provisioning/machine/basic_machine.rb:29:in `execute'
U:/.chefdk/gem/ruby/2.0.0/gems/chef-provisioning-0.19/lib/chef/provisioning/convergence_strategy/install_msi.rb:49:in`block (2 levels) in converge'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/run_context.rb:268:in `open_stream'
U:/.chefdk/gem/ruby/2.0.0/gems/chef-provisioning-0.19/lib/chef/provisioning/chef_provider_action_handler.rb:59:in `open_stream'
U:/.chefdk/gem/ruby/2.0.0/gems/chef-provisioning-0.19/lib/chef/provisioning/convergence_strategy/install_msi.rb:46:in`block in converge'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/run_context.rb:268:in `open_stream'
U:/.chefdk/gem/ruby/2.0.0/gems/chef-provisioning-0.19/lib/chef/provisioning/chef_provider_action_handler.rb:59:in `open_stream'
U:/.chefdk/gem/ruby/2.0.0/gems/chef-provisioning-0.19/lib/chef/provisioning/convergence_strategy/install_msi.rb:45:in`converge'
U:/.chefdk/gem/ruby/2.0.0/gems/chef-provisioning-0.19/lib/chef/provisioning/machine/basic_machine.rb:21:in `converge'
U:/.chefdk/gem/ruby/2.0.0/gems/chef-provisioning-0.19/lib/chef/provider/machine.rb:62:in `block in <class:Machine>'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/provider/lwrp_base.rb:60:in `instance_eval'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/provider/lwrp_base.rb:60:in `recipe_eval_with_update_check'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/provider/lwrp_base.rb:45:in `block in action'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/provider.rb:145:in `run_action'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/resource.rb:582:in `run_action'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/runner.rb:49:in `run_action'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/runner.rb:81:in `block (2 levels) in converge'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/runner.rb:81:in `each'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/runner.rb:81:in `block in converge'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/resource_collection/resource_list.rb:83:in `block in execute_each_resource'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:116:in `call'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/resource_collection/resource_list.rb:81:in `execute_each_resource'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/runner.rb:80:in `converge'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/client.rb:315:in `converge'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/client.rb:400:in `block in run'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/client.rb:399:in `catch'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/client.rb:399:in `run'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/application.rb:243:in `run_with_graceful_exit_option'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/application.rb:220:in `block in run_chef_client'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/local_mode.rb:38:in `with_server_connectivity'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/application.rb:201:in `run_chef_client'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/application/client.rb:355:in `block in interval_run_chef_client'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/application/client.rb:345:in `loop'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/application/client.rb:345:in `interval_run_chef_client'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/application/client.rb:335:in `run_application'
C:/opscode/chefdk/embedded/apps/chef/lib/chef/application.rb:58:in `run'
C:/opscode/chefdk/embedded/apps/chef/bin/chef-client:26:in `<top (required)>'
C:/opscode/chefdk/bin/chef-client:52:in `load'
C:/opscode/chefdk/bin/chef-client:52:in `<main>'
chef run stack trace
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/mixlib-shellout-2.0.1-x86-mingw32/lib/mixlib/shellout.rb:278:in `invalid!'
C:/opscode/chef/embedded/lib/ruby/gems/2.0.0/gems/mixlib-shellout-2.0.1-x86-mingw32/lib/mixlib/shellout.rb:265:in `error!'
C:/chef/cache/cookbooks/jenkins/libraries/_executor.rb:82:in `execute!'
C:/chef/cache/cookbooks/jenkins/libraries/_executor.rb:127:in `groovy!'
C:/chef/cache/cookbooks/jenkins/libraries/slave.rb:315:in `current_slave'
C:/chef/cache/cookbooks/jenkins/libraries/slave.rb:129:in `load_current_resource'
C:/chef/cache/cookbooks/jenkins/libraries/slave_jnlp.rb:52:in `load_current_resource'
C:/chef/cache/cookbooks/jenkins/libraries/slave_windows.rb:62:in `load_current_resource'
C:/opscode/chef/embedded/apps/chef/lib/chef/provider.rb:128:in `run_action'
C:/opscode/chef/embedded/apps/chef/lib/chef/resource.rb:561:in `run_action'
C:/opscode/chef/embedded/apps/chef/lib/chef/runner.rb:49:in `run_action'
C:/opscode/chef/embedded/apps/chef/lib/chef/runner.rb:81:in `block (2 levels) in converge'
C:/opscode/chef/embedded/apps/chef/lib/chef/runner.rb:81:in `each'
C:/opscode/chef/embedded/apps/chef/lib/chef/runner.rb:81:in `block in converge'
C:/opscode/chef/embedded/apps/chef/lib/chef/resource_collection/resource_list.rb:83:in `block in execute_each_resource'
C:/opscode/chef/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:116:in `call'
C:/opscode/chef/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block'
C:/opscode/chef/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
C:/opscode/chef/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
C:/opscode/chef/embedded/apps/chef/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
C:/opscode/chef/embedded/apps/chef/lib/chef/resource_collection/resource_list.rb:81:in `execute_each_resource'
C:/opscode/chef/embedded/apps/chef/lib/chef/runner.rb:80:in `converge'
C:/opscode/chef/embedded/apps/chef/lib/chef/client.rb:331:in `block in converge'
C:/opscode/chef/embedded/apps/chef/lib/chef/client.rb:326:in `catch'
C:/opscode/chef/embedded/apps/chef/lib/chef/client.rb:326:in `converge'
C:/opscode/chef/embedded/apps/chef/lib/chef/client.rb:345:in `converge_and_save'
C:/opscode/chef/embedded/apps/chef/lib/chef/client.rb:448:in `run'
C:/opscode/chef/embedded/apps/chef/lib/chef/application.rb:253:in `run_with_graceful_exit_option'
C:/opscode/chef/embedded/apps/chef/lib/chef/application.rb:230:in `block in run_chef_client'
C:/opscode/chef/embedded/apps/chef/lib/chef/local_mode.rb:38:in `with_server_connectivity'
C:/opscode/chef/embedded/apps/chef/lib/chef/application.rb:213:in `run_chef_client'
C:/opscode/chef/embedded/apps/chef/lib/chef/application/client.rb:392:in `block in interval_run_chef_client'
C:/opscode/chef/embedded/apps/chef/lib/chef/application/client.rb:382:in `loop'
C:/opscode/chef/embedded/apps/chef/lib/chef/application/client.rb:382:in `interval_run_chef_client'
C:/opscode/chef/embedded/apps/chef/lib/chef/application/client.rb:372:in `run_application'
C:/opscode/chef/embedded/apps/chef/lib/chef/application.rb:60:in `run'
C:/opscode/chef/embedded/apps/chef/bin/chef-client:26:in `<top (required)>'
C:/opscode/chef/bin/chef-client:64:in `load'
C:/opscode/chef/bin/chef-client:64:in `<main>'
I have tried different versions of the chef-client to resolve the issue, but that did not help. I'm not sure if the problem is with the jenkins recipe, chef-provisioning, or what.
Because the jenkins recipes work on a local vagrant machine running the same OS (win 2012 R2), I'm thinking this may be a problem with chef-provisioning-fog.
It turns out the problem is with WinRM. The current version of the chef-provisioning-fog driver hard-codes the AWS user data in order to set up WinRM on the machine. Part of this setup sets the per-shell memory limit to 300MB, and the java command executed by the jenkins recipe wants to reserve 2GB of heap; hence the fatal error.
The short-term fix is to up the per-shell WinRM limit from 300MB to 2GB:
set-item wsman:localhost\Shell\MaxMemoryPerShellMB 2048
With chef-provisioning, put this resource after getting the machine ready and before converging:
machine_execute 'set-item wsman:localhost\Shell\MaxMemoryPerShellMB 2048' do
machine "jenkins-win-slave-#{i}"
end
Long term, hopefully the issue is resolved and user data can be customized to set up winrm however the user sees fit.

vmc tunnel not working on api.cloudfoundry.com with Ruby 2.0

I am trying to tunnel the mysql service on api.cloudfoundry.com but facing the error below.
I have installed Ruby 2.0
installed gem versions :
* LOCAL GEMS *
addressable (2.3.3, 2.2.8),async_sinatra (0.5.0),bigdecimal (1.2.0),caldecott (0.0.5),caldecott-client (0.0.2),cf-uaa-lib (1.3.10),cfoundry (0.5.3.rc5),clouseau (0.0.2),
em-http-request (0.3.0),em-websocket (0.3.8),escape_utils (0.3.2),eventmachine (1.0.3 ruby x86-mingw32),interact (0.5.2),io-console (0.4.2),json (1.7.7, 1.6.8),json_pure (1.7.7),
manifests-vmc-plugin (0.6.3.rc2),mime-types (1.21),minitest (4.3.2),mothership (0.5.1),
multi_json (1.7.0),multipart-post (1.2.0),psych (2.0.0),rack (1.5.2),rack-protection (1.5.0),rake (0.9.6),rdoc (4.0.0),rest-client (1.6.7),rubygems-update (2.0.3),
rubyzip (0.9.9),sinatra (1.4.1),test-unit (2.0.0.0),tilt (1.3.6),tunnel-vmc-plugin (0.2.2),
uuidtools (2.1.3),vmc (0.5.1.rc4)
C:\Users\user>vmc tunnel
DL is deprecated, please use Fiddle
1: mongo-hello
2: mysql-hello
3: rabbit-hello
Which service instance?> 2
1: none
2: mysql
3: mysqldump
Which client would you like to start?> 2
Opening tunnel on port 10000... FAILED
CFoundry::BadResponse: 400: <h2>Client sent a bad request.</h2>
For more information, see ~/.vmc/crash
crash contents:
Time of crash:
2013-03-20 17:30:10 +0530
CFoundry::BadResponse: 400: <h2>Client sent a bad request.</h2>
<<<
REQUEST: GET http://api.cloudfoundry.com/apps/caldecott
REQUEST_HEADERS:
Accept : application/json
Authorization : bearer eyJhbGciOiJSUzI1NiJ9.eyJleHAiOjEzNjQwOTc3OTksInVzZXJfbmFtZSI6ImFtdWxsYXdvcmtAZ21haWwuY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5yZWFkIiwib3BlbmlkIiwicGFzc3dvcmQud3JpdGUiXSwiZW1haWwiOiJhbXVsbGF3b3JrQGdtYWlsLmNvbSIsImF1ZCI6WyJvcGVuaWQiLCJjbG91ZF9jb250cm9sbGVyIiwicGFzc3dvcmQiXSwianRpIjoiOGEzYmNhYzEtOTdjMC00OGY2LWE1YjAtNmZhNjFkNTM1YzRiIiwidXNlcl9pZCI6Ijc1NGE0YmE0LTQxNDMtNDA1NC05OWE3LWRkOGJlYTA1NzMyOSIsImNsaWVudF9pZCI6InZtYyJ9.bgY7BUi7DpjKL4gy5YkbTJDYuYXHhHPzKPZApabeA_dpRLfcr1yhprlx2Yx1Shavdso-R9jYg3jiy9MuTUhZ6hvIVVoKcaFxcw43owb2ztXxb_VM6N2wmyXnLX5dmSXNIv7xa5hgbeuwE32rSR66sLNGEgHu-sreaKQIN9V6GbOe-Bj4WN-uux0O8AGmol5sp1QhD4Nf2nAmsiPHR63OhS6-SDBYgizcmpfWgwGeOMvcTumbYJ6PpvRNPa20pQomjDOqSY2Jn_tQM7RfZCklpyZKvdt2RIQK5fWAekMLWlnG3aJYHE90UHnxg0UclhwzgrgI0HiDWkQ_42dqOX446g
Content-Length : 297
Content-Type : application/json
REQUEST_BODY: {"name":"caldecott","instances":1,"staging":{"model":"sinatra","stack":"ruby19","command":"bundle exec ruby server.rb -p $VCAP_APP_PORT"},"resources":{"memory":64},"env":["CALDECOTT_AUTH=9d498baf-9102-4c80-851d-f400530a261f"],"uris":["caldecott-b58c1.cloudfoundry.com"],"services":["mysql-hello"]}
RESPONSE: [400]
RESPONSE_HEADERS:
content-type : text/html
RESPONSE_BODY:
<h2>Client sent a bad request.</h2>
>>>
cfoundry-0.5.3.rc5/lib/cfoundry/baseclient.rb:167:in `handle_error_response'
cfoundry-0.5.3.rc5/lib/cfoundry/baseclient.rb:137:in `handle_response'
cfoundry-0.5.3.rc5/lib/cfoundry/baseclient.rb:87:in `request'
cfoundry-0.5.3.rc5/lib/cfoundry/baseclient.rb:72:in `post'
cfoundry-0.5.3.rc5/lib/cfoundry/v1/model_magic.rb:46:in `block (2 levels) in define_client_methods'
cfoundry-0.5.3.rc5/lib/cfoundry/v1/model.rb:83:in `create!'
tunnel-vmc-plugin-0.2.2/lib/tunnel-vmc-plugin/tunnel.rb:145:in `push_helper'
tunnel-vmc-plugin-0.2.2/lib/tunnel-vmc-plugin/tunnel.rb:88:in `create_helper'
tunnel-vmc-plugin-0.2.2/lib/tunnel-vmc-plugin/tunnel.rb:28:in `open!'
tunnel-vmc-plugin-0.2.2/lib/tunnel-vmc-plugin/plugin.rb:41:in `block in tunnel'
interact-0.5.2/lib/interact/progress.rb:98:in `with_progress'
tunnel-vmc-plugin-0.2.2/lib/tunnel-vmc-plugin/plugin.rb:40:in `tunnel'
mothership-0.5.1/lib/mothership/base.rb:66:in `run'
mothership-0.5.1/lib/mothership/command.rb:72:in `block in invoke'
mothership-0.5.1/lib/mothership/command.rb:86:in `instance_exec'
mothership-0.5.1/lib/mothership/command.rb:86:in `invoke'
mothership-0.5.1/lib/mothership/base.rb:55:in `execute'
vmc-0.5.1.rc4/lib/vmc/cli.rb:150:in `block (2 levels) in execute'
vmc-0.5.1.rc4/lib/vmc/cli.rb:161:in `save_token_if_it_changes'
vmc-0.5.1.rc4/lib/vmc/cli.rb:149:in `block in execute'
vmc-0.5.1.rc4/lib/vmc/cli.rb:100:in `wrap_errors'
vmc-0.5.1.rc4/lib/vmc/cli.rb:145:in `execute'
mothership-0.5.1/lib/mothership.rb:45:in `start'
vmc-0.5.1.rc4/bin/vmc:11:in `<top (required)>'
D:/Ruby200/bin/vmc:23:in `load'
D:/Ruby200/bin/vmc:23:in `<main>'
Try deleting the caldecott application and then trying the tunnel again;
$ vmc delete caldecott
$ vmc tunnel