How to forward port in apache2 cookbook - apache

I tried with below code in apache cookbook to map default port 80 to 443 however still I get error while running the chef. Can you please suggest on this. I tried to map to other than port # 80 since I have nginx recipe also in my cookbook so would like to set up apache2 to listen on diff port -
* apache/attribute/default.rb
default['apache']['dir'] = '/etc/apache2'
default['apache']['listen_ports'] = [ '80','443' ]
* apache/recipes/default.rb
package "apache2" do
action :install
end
service "apache2" do
action [:enable, :start]
end
template "/var/www/index.html" do
source "index.html.erb"
mode "0644"
end
Vagrant provision error -
================================================================================
==> default:
==> default: Error executing action `start` on resource 'service[apache2]'
==> default:
================================================================================
==> default:
==> default: Mixlib::ShellOut::ShellCommandFailed
==> default:
==> default: ------------------------------------
==> default:
==> default: Expected process to exit with [0], but received '1'
This time I had used ==>
attribute/default.rb with below content but still getting error -
default['apache']['dir'] = '/etc/apache2'
default['apache']['listen_ports'] = [ '81’ ]
Error
==> default: STDOUT: * Starting web server apache2
==> default:
==> default: Action 'start' failed.
==> default: The Apache error log may have more information.
==> default: ...fail!
==> default: STDERR: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
==> default: (98)Address already in use: make_sock: could not bind to address 0.0.0.0:80

listen_ports is not a mapping, it sets which ports to listen on. If you don't want to listen on 80, do not include it in that array.

Related

Issue with Vagrant apache2 cookbook

Issue that i have is about starting vagrant on some older project. I am on Ubuntu 18.04 and vagrant worked fine until i installed ssd on my laptop (not sure if related).
So when i do Vagrant up i get the following message:
==> default: * directory[/etc/apache2/ssl] action create
==> default: [2019-09-24T19:44:27+00:00] INFO: directory[/etc/apache2/ssl] created directory /etc/apache2/ssl
==> default:
==> default: - create new directory /etc/apache2/ssl
==> default: [2019-09-24T19:44:27+00:00] INFO: directory[/etc/apache2/ssl] owner changed to 0
==> default: [2019-09-24T19:44:27+00:00] INFO: directory[/etc/apache2/ssl] group changed to 0
==> default: [2019-09-24T19:44:27+00:00] INFO: directory[/etc/apache2/ssl] mode changed to 755
==> default:
==> default: - change mode from '' to '0755'
==> default: - change owner from '' to 'root'
==> default: - change group from '' to 'root'
==> default:
==> default:
==> default:
==> default: * directory[/etc/apache2/conf.d] action create
==> default: [2019-09-24T19:44:27+00:00] INFO: directory[/etc/apache2/conf.d] created directory /etc/apache2/conf.d
==> default:
==> default: - create new directory /etc/apache2/conf.d
==> default: [2019-09-24T19:44:27+00:00] INFO: directory[/etc/apache2/conf.d] owner changed to 0
==> default: [2019-09-24T19:44:27+00:00] INFO: directory[/etc/apache2/conf.d] group changed to 0
==> default: [2019-09-24T19:44:27+00:00] INFO: directory[/etc/apache2/conf.d] mode changed to 755
==> default:
==> default:
==> default: - change mode from '' to '0755'
==> default: - change owner from '' to 'root'
==> default: - change group from '' to 'root'
==> default:
==> default:
==> default:
==> default: * directory[/var/cache/apache2] action create
==> default: (up to date)
==> default: * template[/etc/sysconfig/httpd] action create
==> default: (skipped due to only_if)
==> default: * template[apache2.conf] action create
==> default:
==> default:
==> default:
==> default: ================================================================================
==> default:
==> default: Error executing action `create` on resource 'template[apache2.conf]'
==> default:
==> default: ================================================================================
==> default:
==> default:
==> default:
==> default:
==> default: Chef::Mixin::Template::TemplateError
==> default:
==> default: ------------------------------------
==> default:
==> default: undefined method `empty?' for nil:NilClass
==> default:
==> default:
==> default:
==> default:
==> default: Resource Declaration:
==> default:
==> default: ---------------------
==> default: # In /tmp/vagrant-chef/0ad2cd5b52108461d0c0cbda213593d4/cookbooks/!apache2/recipes/default.rb
==> default:
==> default: 149: template 'apache2.conf' do
==> default: 150: case node['platform_family']
==> default: 151: when 'rhel', 'fedora', 'arch'
==> default: 152: path "#{node['apache']['dir']}/conf/httpd.conf"
==> default: 153: when 'debian'
==> default: 154: path "#{node['apache']['dir']}/apache2.conf"
==> default: 155: when 'freebsd'
==> default: 156: path "#{node['apache']['dir']}/httpd.conf"
==> default: 157: end
==> default: 158: source 'apache2.conf.erb'
==> default:
==> default: Compiled Resource:
==> default: ------------------
==> default: # Declared in /tmp/vagrant-chef/0ad2cd5b52108461d0c0cbda213593d4/cookbooks/!apache2/recipes/default.rb:149:in `from_file'
==> default:
==> default: template("apache2.conf") do
==> default: action [:create]
==> default: retries 0
==> default: retry_delay 2
==> default: default_guard_interpreter :default
==> default: path "/etc/apache2/apache2.conf"
==> default: backup 5
==> default: atomic_update true
==> default: source "apache2.conf.erb"
==> default: declared_type :template
==> default: cookbook_name :apache2
==> default:
==> default: recipe_name "default"
==> default:
==> default: mode "0644"
==> default: owner "root"
==> default: group "root"
==> default: end
==> default:
==> default:
==> default:
==> default: Template Context:
==> default:
==> default: -----------------
==> default: on line #94
==> default: 92: # viewed by Web clients.
==> default:
==> default: 93: #
==> default: 94: <% access_file_name_prefix = node['apache']['access_file_name'][0..2] if !node['apache']['access_file_name'].empty?
==> default:
==> default: 95: if access_file_name_prefix != '.ht'
==> default: 96: file_name_prefix = '(' + access_file_name_prefix + '|\.ht)'
==> default:
==> default:
==> default:
==> default: [2019-09-24T19:44:28+00:00] INFO: Running queued delayed notifications before re-raising exception
==> default:
==> default: Running handlers:
==> default: [2019-09-24T19:44:28+00:00] ERROR: Running exception handlers
==> default: Running handlers complete
==> default:
==> default: [2019-09-24T19:44:28+00:00] ERROR: Exception handlers complete
==> default: Chef Client failed. 14 resources updated in 03 minutes 07 seconds
==> default: [2019-09-24T19:44:28+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> default: [2019-09-24T19:44:28+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
==> default: [2019-09-24T19:44:28+00:00] ERROR:
==> default:
==> default: Chef::Mixin::Template::TemplateError (undefined method `empty?' for nil:NilClass) on line #94:
==> default:
==> default: 92: # viewed by Web clients.
==> default: 93: #
==> default: 94: <% access_file_name_prefix = node['apache']['access_file_name'][0..2] if !node['apache']['access_file_name'].empty?
==> default: 95: if access_file_name_prefix != '.ht'
==> default: 96: file_name_prefix = '(' + access_file_name_prefix + '|\.ht)'
==> default:
==> default: (erubis):94:in `block in evaluate'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/erubis-2.7.0/lib/erubis/evaluator.rb:74:in `instance_eval'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/erubis-2.7.0/lib/erubis/evaluator.rb:74:in `evaluate'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/mixin/template.rb:162:in `_render_template'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/mixin/template.rb:148:in `render_template'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/provider/template/content.rb:53:in `file_for_provider'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/file_content_management/content_base.rb:40:in `tempfile'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/provider/file.rb:462:in `tempfile'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/provider/file.rb:339:in `do_generate_content'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/provider/file.rb:150:in `action_create'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/provider.rb:144:in `run_action'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/resource.rb:596:in `run_action'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/runner.rb:74:in `run_action'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/runner.rb:106:in `block (2 levels) in converge'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/runner.rb:106:in `each'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/runner.rb:106:in `block in converge'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/resource_collection/resource_list.rb:83:in `block in execute_each_resource'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/resource_collection/stepable_iterator.rb:116:in `call'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/resource_collection/resource_list.rb:81:in `execute_each_resource'
==> default: /opt/chef/embedded/lib/ruby/2.1.0/forwardable.rb:183:in `execute_each_resource'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/runner.rb:105:in `converge'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/client.rb:658:in `block in converge'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/client.rb:653:in `catch'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/client.rb:653:in `converge'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/client.rb:692:in `converge_and_save'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/client.rb:271:in `run'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/application.rb:261:in `block in fork_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/application.rb:249:in `fork'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/application.rb:249:in `fork_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/application.rb:215:in `block in run_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/local_mode.rb:44:in `with_server_connectivity'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/application.rb:203:in `run_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/application/solo.rb:286:in `block in interval_run_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/application/solo.rb:275:in `loop'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/application/solo.rb:275:in `interval_run_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/application/solo.rb:253:in `run_application'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/lib/chef/application.rb:58:in `run'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.6.0/bin/chef-solo:25:in `<top (required)>'
==> default: /usr/bin/chef-solo:54:in `load'
==> default: /usr/bin/chef-solo:54:in `<main>'
==> default: [2019-09-24T19:44:29+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.
Vagrant setup is running:
config.vm.provision "shell", path: "bootstrap.sh"
config.vm.provision :chef_solo do |chef|
chef.roles_path = "./chef/chef-repo/roles"
chef.cookbooks_path = ["./chef/chef-repo/cookbooks"]
chef.data_bags_path = "./chef/chef-repo/data_bags"
chef.environments_path = "./chef/chef-repo/environments"
chef.add_recipe "apt"
chef.add_recipe "chef_gem"
chef.add_recipe "base"
chef.add_recipe "build-essential"
chef.add_recipe "openssl"
chef.add_recipe "apache2"
chef.add_recipe "apache2::mod_php5"
chef.add_recipe "apache2::mod_rewrite"
chef.add_recipe "apache2::mod_ssl"
chef.add_recipe "mysql::server"
chef.add_recipe "mysql::client"
chef.add_recipe "mysql_charset"
chef.add_recipe "php"
chef.add_recipe "memcached"
chef.add_recipe "php::module_mysql"
chef.add_recipe "php::module_curl"
chef.add_recipe "php::module_gd"
chef.add_recipe "php::module_memcache"
chef.add_recipe "deploy"
chef.environment = "vagrant"
and apache2 part is failing.
https://supermarket.chef.io/cookbooks/apache2/versions/1.1.16
This is cookbook for apache2.
Any idea on reason of failing? Works on different computer, same version of vbox, vagrant, ruby.
So the error is caused by this erb template line (scroll to the right):
#==> default: 94: <% access_file_name_prefix = node['apache']['access_file_name'][0..2] if !node['apache']['access_file_name'].empty?
the error is undefined method `empty?' for nil:NilClass so after reading the template line, it's pretty clear what causes the error:
Somewhere in your recipes, attributes, roles, environments something is setting node['apache']['access_file_name'] to nil instead of just an empty string ("").
You also seem to use a very, very, very old version of the cookbook (1.1.16) which is 7 (seven) years old.

Using vagrant with berkshelf and chef-solo : Try to install apt and apache2

From https://www.vagrantup.com/docs/provisioning/chef_solo.html and http://berkshelf.com/, I'm trying to add apt and apache2 recipes.
My settings :
Host OS : Windows 10
vagrant : v1.8.1
Virtualbox : v5.0.14
Guest OS : Ubuntu Precise64 (default vagrant VM)
My different steps:
1) Set up vagrant plug-ins:
vagrant plugin install vagrant-berkshelf
vagrant plugin install vagrant-omnibus
vagrant plugin install vagrant-hostmanager
Installed versions:
$ vagrant plugin list
vagrant-berkshelf (4.1.0)
vagrant-hostmanager (1.8.2)
vagrant-omnibus (1.4.1)
vagrant-share (1.1.5, system)
2) Set up Chef dk 0.15.15 on the host (Necessary to start a vagrant VM with the Berkshelf plugin)
3) Vagrantfile file config
config.vm.network "private_network", ip: "192.168.33.10"
config.omnibus.chef_version = :latest
config.berkshelf.enabled = true
config.vm.provision "chef_solo" do |chef|
chef.add_recipe "apt"
chef.add_recipe "apache2"
end
4) Create manually the Berksfile file (in the same folder as Vagrantfile)
source "https://supermarket.chef.io"
cookbook "apt"
cookbook "apache2"
After doing these settings, I can do the vagrant up to start the machine.
vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Loading Berkshelf datafile...
==> default: Sharing cookbooks with VM
==> default: Checking if box 'hashicorp/precise64' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Updating Vagrant's Berkshelf...
==> default: Resolving cookbook dependencies...
==> default: Using apache2 (3.2.2)
==> default: Using apt (4.0.1)
==> default: Using compat_resource (12.10.6)
==> default: Vendoring apache2 (3.2.2) to C:/Users/No/.berkshelf/vagrant-berkshelf/shelves/berkshelf20160630-13400-d00zd2-default/apache2
==> default: Vendoring apt (4.0.1) to C:/Users/No/.berkshelf/vagrant-berkshelf/shelves/berkshelf20160630-13400-d00zd2-default/apt
==> default: Vendoring compat_resource (12.10.6) to C:/Users/No/.berkshelf/vagrant-berkshelf/shelves/berkshelf20160630-13400-d00zd2-default/compat_resource
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
default: The guest additions on this VM do not match the installed version of
default: VirtualBox! In most cases this is fine, but in rare cases it can
default: prevent things such as shared folders from working properly. If you see
default: shared folder errors, please make sure the guest additions within the
default: virtual machine match the version of VirtualBox you have installed on
default: your host and reload your VM.
default:
default: Guest Additions Version: 4.2.0
default: VirtualBox Version: 5.0
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
default: /vagrant => D:/Vagrant VMs Files/Linux/Ubuntu Standard/v12.04 LTS Precise/Hashicorp-Precise64 - Template (TUTO)
default: /tmp/vagrant-chef/83b8a9c0ce916541f1e94cb0043abcfa/cookbooks => C:/Users/No/.berkshelf/vagrant-berkshelf/shelves/berkshelf20160630-13400-d00zd2-default
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
And then doing a vagrant provision
vagrant provision
==> default: Loading Berkshelf datafile...
==> default: Sharing cookbooks with VM
==> default: Updating Vagrant's Berkshelf...
==> default: Resolving cookbook dependencies...
==> default: Using apache2 (3.2.2)
==> default: Using apt (4.0.1)
==> default: Using compat_resource (12.10.6)
==> default: Vendoring apache2 (3.2.2) to C:/Users/No/.berkshelf/vagrant-berkshelf/shelves/berkshelf20160630-13400-d00zd2-default/apache2
==> default: Vendoring apt (4.0.1) to C:/Users/No/.berkshelf/vagrant-berkshelf/shelves/berkshelf20160630-13400-d00zd2-default/apt
==> default: Vendoring compat_resource (12.10.6) to C:/Users/No/.berkshelf/vagrant-berkshelf/shelves/berkshelf20160630-13400-d00zd2-default/compat_resource
==> default: Chef 12.11.18 Omnibus package is already installed.
==> default: Running provisioner: chef_solo...
==> default: Detected Chef (latest) is already installed
==> default: Generating chef JSON and uploading...
==> default: Running chef-solo...
==> default: stdin: is not a tty
==> default: [2016-06-30T07:06:10+00:00] INFO: Started chef-zero at chefzero://localhost:8889 with repository at /tmp/vagrant-chef/83b8a9c0ce916541f1e94cb0043abcfa
==> default: One version per cookbook
==> default: [2016-06-30T07:06:10+00:00] INFO: Forking chef instance to converge...
==> default: Starting Chef Client, version 12.11.18
==> default: [2016-06-30T07:06:10+00:00] INFO: *** Chef 12.11.18 ***
==> default: [2016-06-30T07:06:10+00:00] INFO: Platform: x86_64-linux
==> default: [2016-06-30T07:06:10+00:00] INFO: Chef-client pid: 1377
==> default: [2016-06-30T07:06:13+00:00] INFO: GET /organizations/chef/nodes/vagrant-084b5399
==> default: [2016-06-30T07:06:13+00:00] INFO: #<ChefZero::RestErrorResponse: 404: Object not found: chefzero://localhost:8889/nodes/vagrant-084b5399>
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/rest_base.rb:91:in `rescue in get_data'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/rest_base.rb:83:in `get_data'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/endpoints/rest_object_endpoint.rb:18:in `get'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/rest_base.rb:62:in `call'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/rest_router.rb:24:in `call'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/server.rb:664:in `block in app'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/server.rb:336:in `call'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/server.rb:336:in `handle_socketless_request'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/socketless_server_map.rb:87:in `request'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/socketless_server_map.rb:33:in `request'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/http/socketless_chef_zero_client.rb:154:in `request'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/http.rb:305:in `block in send_http_request'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/http.rb:336:in `block in retrying_http_errors'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/http.rb:334:in `loop'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/http.rb:334:in `retrying_http_errors'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/http.rb:299:in `send_http_request'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/http.rb:144:in `request'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/http.rb:111:in `get'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/node.rb:604:in `load'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/node.rb:588:in `find_or_create'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/policy_builder/dynamic.rb:72:in `load_node'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/client.rb:467:in `load_node'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/client.rb:269:in `run'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:286:in `block in fork_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:274:in `fork'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:274:in `fork_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:239:in `block in run_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/local_mode.rb:44:in `with_server_connectivity'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:227:in `run_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/client.rb:456:in `sleep_then_run_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/client.rb:443:in `block in interval_run_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/client.rb:442:in `loop'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/client.rb:442:in `interval_run_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/client.rb:426:in `run_application'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:59:in `run'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/solo.rb:217:in `run'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/bin/chef-solo:25:in `<top (required)>'
==> default: /usr/bin/chef-solo:52:in `load'
==> default: /usr/bin/chef-solo:52:in `<main>'
==> default: [2016-06-30T07:06:13+00:00] INFO: HTTP Request Returned 404 Not Found: Object not found: chefzero://localhost:8889/nodes/vagrant-084b5399
==> default: [2016-06-30T07:06:13+00:00] INFO: POST /organizations/chef/nodes
==> default: --- POST BODY ---
==> default: {"name":"vagrant-084b5399","chef_environment":"_default","json_class":"Chef::Node","automatic":{},"normal":{},"chef_type":"node","default":{},"override":{},"run_list":[]}
==> default: --- END POST BODY ---
==> default: [2016-06-30T07:06:13+00:00] INFO: #<ChefZero::RestErrorResponse: 404: Parent not found: chefzero://localhost:8889/nodes>
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/rest_base.rb:187:in `rescue in create_data'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/rest_base.rb:181:in `create_data'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/endpoints/rest_list_endpoint.rb:31:in `post'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/endpoints/nodes_endpoint.rb:24:in `post'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/rest_base.rb:62:in `call'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/rest_router.rb:24:in `call'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/server.rb:664:in `block in app'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/server.rb:336:in `call'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/server.rb:336:in `handle_socketless_request'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/socketless_server_map.rb:87:in `request'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-zero-4.6.2/lib/chef_zero/socketless_server_map.rb:33:in `request'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/http/socketless_chef_zero_client.rb:154:in `request'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/http.rb:305:in `block in send_http_request'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/http.rb:336:in `block in retrying_http_errors'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/http.rb:334:in `loop'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/http.rb:334:in `retrying_http_errors'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/http.rb:299:in `send_http_request'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/http.rb:144:in `request'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/http.rb:127:in `post'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/node.rb:639:in `create'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/node.rb:592:in `rescue in find_or_create'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/node.rb:588:in `find_or_create'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/policy_builder/dynamic.rb:72:in `load_node'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/client.rb:467:in `load_node'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/client.rb:269:in `run'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:286:in `block in fork_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:274:in `fork'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:274:in `fork_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:239:in `block in run_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/local_mode.rb:44:in `with_server_connectivity'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:227:in `run_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/client.rb:456:in `sleep_then_run_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/client.rb:443:in `block in interval_run_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/client.rb:442:in `loop'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/client.rb:442:in `interval_run_chef_client'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/client.rb:426:in `run_application'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:59:in `run'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/solo.rb:217:in `run'
==> default: /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/bin/chef-solo:25:in `<top (required)>'
==> default: /usr/bin/chef-solo:52:in `load'
==> default: /usr/bin/chef-solo:52:in `<main>'
==> default: [2016-06-30T07:06:13+00:00] INFO: HTTP Request Returned 404 Not Found: Parent not found: chefzero://localhost:8889/nodes
==> default: ================================================================================
==> default: Chef encountered an error attempting to load the node data for "vagrant-084b5399"
==> default: ================================================================================
==> default:
==> default: Resource Not Found:
==> default: -------------------
==> default: The server returned a HTTP 404. This usually indicates that your chef_server_url is incorrect.
==> default: Relevant Config Settings:
==> default: -------------------------
==> default: chef_server_url "chefzero://localhost:8889"
==> default: Platform:
==> default: ---------
==> default: x86_64-linux
==> default:
==> default: Running handlers:
==> default: [2016-06-30T07:06:13+00:00] ERROR: Running exception handlers
==> default: Running handlers complete
==> default: [2016-06-30T07:06:13+00:00] ERROR: Exception handlers complete
==> default: Chef Client failed. 0 resources updated in 02 seconds
==> default: [2016-06-30T07:06:13+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> default: [2016-06-30T07:06:13+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
==> default: [2016-06-30T07:06:13+00:00] ERROR: 404 "Not Found"
==> default: [2016-06-30T07:06:14+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.
As you can see, I have some errors (Chef encountered an error attempting to load the node data for "vagrant-084b5399"), please see the chef-stacktrace.out file content below
Generated at 2016-06-30 07:06:13 +0000
Net::HTTPServerException: 404 "Not Found"
/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.11.18/lib/chef/http.rb:146:in `request'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/http.rb:127:in `post'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/node.rb:639:in `create'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/node.rb:592:in `rescue in find_or_create'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/node.rb:588:in `find_or_create'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/policy_builder/dynamic.rb:72:in `load_node'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/client.rb:467:in `load_node'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/client.rb:269:in `run'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:286:in `block in fork_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:274:in `fork'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:274:in `fork_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:239:in `block in run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/local_mode.rb:44:in `with_server_connectivity'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:227:in `run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/client.rb:456:in `sleep_then_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/client.rb:443:in `block in interval_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/client.rb:442:in `loop'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/client.rb:442:in `interval_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/client.rb:426:in `run_application'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application.rb:59:in `run'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/lib/chef/application/solo.rb:217:in `run'
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/chef-12.11.18/bin/chef-solo:25:in `<top (required)>'
/usr/bin/chef-solo:52:in `load'
/usr/bin/chef-solo:52:in `<main>'
I have verified, apache2 is not installed on the VM.
I don't know what these errors mean, is there a mistake somewhere?
You need to upgrade your Vagrant, the latest is 1.8.4. We made some changes to how chef-solo works internally that Vagrant had to adjust to.

Vagrant ssh stuck with "default: Warning: Connection timeout. Retrying..."

I am running vagrant(1.7.4)-salt on Virtual box 4.3 on a headless ubuntu 14.04. Salt is a standalone one.The reason I am using these version is because the work on my local ubuntu.
On vagrant up I get the following output:
==> default: Importing base box 'phusion/ubuntu-14.04-amd64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'phusion/ubuntu-14.04-amd64' is up to date...
==> default: Setting the name of the VM: drupal_default_1452863894453_19933
==> default: Clearing any previously set forwarded ports...
==> default: Fixed port collision for 22 => 2222. Now on port 2201.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 22 => 2201 (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2201
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
vagrant ssh-config gives:
Host default
HostName 127.0.0.1
User vagrant
Port 2201
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile /home/user/.vagrant.d/insecure_private_key
IdentitiesOnly yes
LogLevel FATAL
My Vagrantfile is:
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.host_name = "site#{rand(0..999999)}"
config.vm.provider "virtualbox" do |v|
config.ssh.insert_key = false
v.memory = 2048
v.cpus = 1
end
## For masterless, mount your salt file root
config.vm.synced_folder "salt/roots/","/srv/salt/"
# Network
config.vm.network :private_network, ip: "172.16.0.100"
# Server provisioner
config.vm.provision :salt do |salt|
salt.masterless = true
salt.minion_config = "salt/minion"
salt.run_highstate = true
salt.bootstrap_options = "-P"
end
# Provisioning scripts
config.vm.provision "dbsync", type: "shell", path: "provision/db.sh"
end
What could have missed? Any ubuntu network configuration? Any ssh configuration?

Selenium Grid, Vagrant, unable to run tests from Eclipse

I am attempting to automate our testing using Selenium and Selenium Grid 2. To do this I have create a VirtualBox VM and packaged it with vagrant into a box. Using simple batch scripts, eventually want to run this on a Jenkins CI server, I can start the vagrant box,but I get:
c:\seleniumServer>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'IE_Vagrant.box'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM:seleniumServer_default_1436811491763_573
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: bridged
==> default: Forwarding ports...
default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: password
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.
If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.
If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.
If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.
I can start the Selenium Hub, and selenium Node and they register. I can even ssh into the vagrant box after it is done telling it it cannot connect. I have setup cygwin and OpenSSH on the box.
When I try to run the testNg test from Eclipse I get :
Error forwarding the new session Error forwarding the request Connect to 10.0.2.15:5566 [/10.0.2.15] failed: Connection timed out: connect.
Here are the relevant bits.
Start node with
java -jar lib/selenium-server-standalone-2.46.0.jar -role webdriver -hub http://localhost:4444/grid/register -browser browserName="chrome",version=ANY,platform=WINDOWS,maxInstances=5 -Dwebdriver.chrome.driver="c\seleniumDrivers\chromedriver.exe"
Start the Hub with
java -jar selenium-server-standalone-2.46.0.jar -role hub
VagrantFile:
Vagrant.configure(2) do |config|
config.vm.boot_timeout = "300"
config.ssh.username = "vagrant"
config.ssh.password = "vagrant"
config.vm.network "public_network"
config.vm.box = "IE_Vagrant.box"
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
vb.gui = true
# # Customize the amount of memory on the VM:
# vb.memory = "1024"
end
And here is my test:
package com.hiiq.qa.testing.gen2;
import static org.junit.Assert.assertEquals;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.By;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class GridTest {
private static RemoteWebDriver driver;
#BeforeClass
public void setUp() throws MalformedURLException {
DesiredCapabilities capability = new DesiredCapabilities();
//capability.setBrowserName("chrome");
capability.setBrowserName(DesiredCapabilities.chrome().getBrowserName());
capability.setPlatform(Platform.WINDOWS);
//capability.setVersion("");
capability.setJavascriptEnabled(true);
driver = new RemoteWebDriver(new URL("http://10.70.1.28:4444/wd/hub"), capability);
driver.get("http://10.1.6.112:8383");
}
#Test
public void loginTest(){
Check this tutorial if the box is properly setup, especially virtualbox guest additions: https://dennypc.wordpress.com/2014/06/09/creating-a-windows-box-with-vagrant-1-6/
vagrant up and vagrant ssh should work properly.
Then setup your Vagrantfile for Port Forwarding:
Vagrant.configure(2) do |config|
config.vm.boot_timeout = "300"
config.ssh.username = "vagrant"
config.ssh.password = "vagrant"
config.vm.network "public_network"
config.vm.box = "IE_Vagrant.box"
config.vm.network "forwarded_port", guest: 4444, host: 4444
config.vm.network "forwarded_port", guest: 8383, host: 8383
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
vb.gui = true
# # Customize the amount of memory on the VM:
# vb.memory = "1024"
end
end
Contact your services in your tests by localhost:4444 and localhost:8383.

cannot ssh Docker Provided Container with Vagrant. Vagrant ssh doesnt work too

I am fairly new to Vagrant and Docker both.
What I am trying to do here is to get a container provided via docker in Vagrant and install a small webapp using the shell provisioner.
Here is my Vagrantfile
Vagrant.configure(2) do |config|
# config.vm.provision :shell, path: "bootstrap.sh"
config.vm.provision :shell, inline: 'echo Hi there !!!'
config.vm.provider :docker do |d|
d.name="appEnvironment"
d.image = "phusion/baseimage"
d.remains_running = true
d.has_ssh = true
d.cmd = ["/sbin/my_init","--enable-insecure-key"]
end
end
The problem that i am facing here is that after the container is created it keeps running the following and eventually just stops.
I can see a running docker container when i type in docker ps but it hasnt run the provisioning part. I am assuming it is because the ssh wasnt successful
==> default: Creating the container...
default: Name: appEnvironment
default: Image: phusion/baseimage
default: Cmd: /sbin/my_init --enable-insecure-key
default: Volume: /home/devops/vagrantBoxForDemo:/vagrant
default: Port: 127.0.0.1:2222:22
default:
default: Container created: 56a87b7cd10c22fe
==> default: Starting container...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 172.17.0.50:22
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection refused. Retrying...
default: Warning: Connection refused. Retrying...
default: Warning: Connection refused. Retrying...
Can someone let me know where i might be wrong? I tried changing the image as well but without success.
First download the insecure key provided by phusion from:
https://github.com/phusion/baseimage-docker/blob/master/image/insecure_key
* Remember the insecure key should be used only for development purposes.
Now, you need to enable ssh by adding the following into your Dockerfile:
FROM phusion/baseimage
RUN rm -f /etc/service/sshd/down
RUN /etc/my_init.d/00_regen_ssh_host_keys.sh
RUN /usr/sbin/enable_insecure_key
Enable ssh and specify the key file in your Vagrantfile:
Vagrant.configure("2") do |config|
config.vm.define "app" do |app|
app.vm.provider "docker" do |d|
d.build_dir = "."
d.cmd = ["/sbin/my_init", "--enable-insecure-key"]
d.has_ssh = true
end
end
config.ssh.username = "root"
config.ssh.private_key_path = "path/to/your/insecure_key"
end
Up your environment
vagrant up
Now you should be able to access your container by ssh
vagrant ssh app
phusion/baseimage does not have the insecure private key enabled by default. You have to create your own base image FROM phusion/baseimage with the following:
RUN /usr/sbin/enable_insecure_key