From 07cd4008c08ed7714da43ad92569d0a51cd4ce85 Mon Sep 17 00:00:00 2001 From: Torben Knerr Date: Tue, 19 May 2015 08:37:38 +0200 Subject: [PATCH 1/9] add a windows guest example to the sample Vagrantfile --- Vagrantfile | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/Vagrantfile b/Vagrantfile index e7e2d1d..28ab410 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -21,7 +21,7 @@ Vagrant.configure("2") do |config| ms_config.omnibus.chef_version = "12.0.3" ms_config.berkshelf.enabled = true - + ms_config.vm.provider :managed do |managed_config, override| managed_config.server = "192.168.40.35" override.ssh.username = "vagrant" @@ -35,4 +35,33 @@ Vagrant.configure("2") do |config| end end + + + # + # fake a managed windows server by bringing up a virtualbox vm + # + config.vm.define :fake_managed_windows_server do |fms_config| + fms_config.vm.box = "boxcutter/eval-win7x86-enterprise" + fms_config.vm.network :private_network, ip: "192.168.40.36" + fms_config.berkshelf.enabled = false + end + + # + # configure managed provider to connect to `fake_managed_windows_server` + # + config.vm.define :my_windows_server do |ms_config| + + ms_config.vm.box = "tknerr/managed-server-dummy" + + ms_config.berkshelf.enabled = false + + ms_config.vm.communicator = :winrm + ms_config.winrm.username = 'vagrant' + ms_config.winrm.password = 'vagrant' + + ms_config.vm.provider :managed do |managed, override| + managed.server = '192.168.40.36' + end + end + end From d847555f1a1e575af706161c62f4a143a6c8e6a8 Mon Sep 17 00:00:00 2001 From: Torben Knerr Date: Tue, 19 May 2015 08:52:30 +0200 Subject: [PATCH 2/9] lock to vagrant version 1.7.2 for a stable test base --- Gemfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 29de67d..70a4e0e 100644 --- a/Gemfile +++ b/Gemfile @@ -6,11 +6,11 @@ group :development do # We depend on Vagrant for development, but we don't add it as a # gem dependency because we expect to be installed within the # Vagrant environment itself using `vagrant plugin`. - gem "vagrant", git: "https://github.com/mitchellh/vagrant.git" + gem "vagrant", git: "https://github.com/mitchellh/vagrant.git", ref: "v1.7.2" end group :plugins do gem "vagrant-managed-servers", path: "." gem "vagrant-omnibus", "1.4.1" gem "vagrant-berkshelf", "3.0.1" -end \ No newline at end of file +end From 87b96100f449846a0564cc590487c32d484d4f03 Mon Sep 17 00:00:00 2001 From: Torben Knerr Date: Tue, 19 May 2015 08:58:40 +0200 Subject: [PATCH 3/9] differentiate explicitly between linux and windows servers in the sample Vagrantfile --- README.md | 14 +++++++------- Vagrantfile | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 7df6b38..b5ba615 100644 --- a/README.md +++ b/README.md @@ -190,20 +190,20 @@ If those pass, you're ready to start developing the plugin. You can test the plugin without installing it into your Vagrant environment by using the `Vagrantfile` in the top level of this directory and use bundler to execute Vagrant. -First, fake a managed server by bringing up the `fake_managed_server` vagrant VM with the default virtualbox provider: +First, fake a managed server by bringing up the `fake_managed_linux_server` vagrant VM with the default virtualbox provider: ``` -$ bundle exec vagrant up fake_managed_server +$ bundle exec vagrant up fake_managed_linux_server ``` -Now you can use the managed provider (defined in a separate VM named `my_server`) to ssh into or provision the (fake) managed server: +Now you can use the managed provider (defined in a separate VM named `my_linux_server`) to ssh into or provision the (fake) managed server: ``` $ # link vagrant with the server -$ bundle exec vagrant up my_server --provider=managed +$ bundle exec vagrant up my_linux_server --provider=managed $ # ssh / provision -$ bundle exec vagrant ssh my_server -$ bundle exec vagrant provision my_server +$ bundle exec vagrant ssh my_linux_server +$ bundle exec vagrant provision my_linux_server $ # unlink -$ bundle exec vagrant destroy my_server +$ bundle exec vagrant destroy my_linux_server ``` diff --git a/Vagrantfile b/Vagrantfile index 28ab410..12fcdbd 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -4,18 +4,18 @@ Vagrant.configure("2") do |config| # - # fake a managed server by bringing up a virtualbox vm + # fake a managed linux server by bringing up a virtualbox vm # - config.vm.define :fake_managed_server do |fms_config| + config.vm.define :fake_managed_linux_server do |fms_config| fms_config.vm.box = "chef/ubuntu-12.04-i386" fms_config.vm.network :private_network, ip: "192.168.40.35" fms_config.berkshelf.enabled = false end # - # configure managed provider to connect to `fake_managed_server` + # configure managed provider to connect to `fake_managed_linux_server` # - config.vm.define :my_server do |ms_config| + config.vm.define :my_linux_server do |ms_config| ms_config.vm.box = "tknerr/managed-server-dummy" @@ -25,7 +25,7 @@ Vagrant.configure("2") do |config| ms_config.vm.provider :managed do |managed_config, override| managed_config.server = "192.168.40.35" override.ssh.username = "vagrant" - override.ssh.private_key_path = ".vagrant/machines/fake_managed_server/virtualbox/private_key" + override.ssh.private_key_path = ".vagrant/machines/fake_managed_linux_server/virtualbox/private_key" end ms_config.vm.provision :chef_solo do |chef| From 87fb76bb12e8c4f858b833e2d0b3485f8f2597cf Mon Sep 17 00:00:00 2001 From: Torben Knerr Date: Tue, 19 May 2015 08:59:05 +0200 Subject: [PATCH 4/9] add the windows examples to the acceptance tests --- Rakefile | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Rakefile b/Rakefile index 87d45d1..cf33fa6 100644 --- a/Rakefile +++ b/Rakefile @@ -13,12 +13,15 @@ task :default => "spec" desc "runs the acceptance \"test\" as described in README" task :acceptance do - begin - sh "vagrant up fake_managed_server" - sh "vagrant up my_server --provider=managed" - sh "vagrant provision my_server" - sh "vagrant reload my_server" - ensure - sh "vagrant destroy -f" + ['linux', 'windows'],each do |os| + begin + sh "vagrant up fake_managed_server" + sh "vagrant up my_server --provider=managed" + sh "vagrant provision my_server" + sh "vagrant reload my_server" + ensure + sh "vagrant destroy -f my_server" + sh "vagrant destroy -f fake_managed_server" + end end end From cf824f70edc084fa02c52675a9b1c20a5475020d Mon Sep 17 00:00:00 2001 From: Torben Knerr Date: Tue, 19 May 2015 09:00:03 +0200 Subject: [PATCH 5/9] oops fix typo --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index cf33fa6..3ef295f 100644 --- a/Rakefile +++ b/Rakefile @@ -13,7 +13,7 @@ task :default => "spec" desc "runs the acceptance \"test\" as described in README" task :acceptance do - ['linux', 'windows'],each do |os| + ['linux', 'windows'].each do |os| begin sh "vagrant up fake_managed_server" sh "vagrant up my_server --provider=managed" From 6ecae54f358b18396ae5dc00b08a386aac570eb2 Mon Sep 17 00:00:00 2001 From: Torben Knerr Date: Tue, 19 May 2015 09:04:53 +0200 Subject: [PATCH 6/9] use the `#{os}` to run the OS specific acceptance tests --- Rakefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Rakefile b/Rakefile index 3ef295f..a9875b9 100644 --- a/Rakefile +++ b/Rakefile @@ -15,13 +15,13 @@ desc "runs the acceptance \"test\" as described in README" task :acceptance do ['linux', 'windows'].each do |os| begin - sh "vagrant up fake_managed_server" - sh "vagrant up my_server --provider=managed" - sh "vagrant provision my_server" - sh "vagrant reload my_server" + sh "vagrant up fake_managed_#{os}_server" + sh "vagrant up my_#{os}_server --provider=managed" + sh "vagrant provision my_#{os}_server" + sh "vagrant reload my_#{os}_server" ensure - sh "vagrant destroy -f my_server" - sh "vagrant destroy -f fake_managed_server" + sh "vagrant destroy -f my_#{os}_server" + sh "vagrant destroy -f fake_managed_#{os}_server" end end end From dc019f3f1e1891360cd47afcab1dbf98f8f947f8 Mon Sep 17 00:00:00 2001 From: Torben Knerr Date: Wed, 20 May 2015 00:13:28 +0200 Subject: [PATCH 7/9] better naming of the vagrant VMs (thanks @chrisbaldauf for the suggestion) --- README.md | 14 +++++++------- Rakefile | 12 ++++++------ Vagrantfile | 48 ++++++++++++++++++++++++------------------------ 3 files changed, 37 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index b5ba615..ccbcd22 100644 --- a/README.md +++ b/README.md @@ -190,20 +190,20 @@ If those pass, you're ready to start developing the plugin. You can test the plugin without installing it into your Vagrant environment by using the `Vagrantfile` in the top level of this directory and use bundler to execute Vagrant. -First, fake a managed server by bringing up the `fake_managed_linux_server` vagrant VM with the default virtualbox provider: +First, let's pretend we have a managed server by bringing up the `local_linux` vagrant VM with the default virtualbox provider: ``` -$ bundle exec vagrant up fake_managed_linux_server +$ bundle exec vagrant up local_linux ``` -Now you can use the managed provider (defined in a separate VM named `my_linux_server`) to ssh into or provision the (fake) managed server: +Now you can use the managed provider (defined in a separate VM named `managed_linux`) to ssh into or provision the actual managed server: ``` $ # link vagrant with the server -$ bundle exec vagrant up my_linux_server --provider=managed +$ bundle exec vagrant up managed_linux --provider=managed $ # ssh / provision -$ bundle exec vagrant ssh my_linux_server -$ bundle exec vagrant provision my_linux_server +$ bundle exec vagrant ssh managed_linux +$ bundle exec vagrant provision managed_linux $ # unlink -$ bundle exec vagrant destroy my_linux_server +$ bundle exec vagrant destroy managed_linux ``` diff --git a/Rakefile b/Rakefile index a9875b9..203898b 100644 --- a/Rakefile +++ b/Rakefile @@ -15,13 +15,13 @@ desc "runs the acceptance \"test\" as described in README" task :acceptance do ['linux', 'windows'].each do |os| begin - sh "vagrant up fake_managed_#{os}_server" - sh "vagrant up my_#{os}_server --provider=managed" - sh "vagrant provision my_#{os}_server" - sh "vagrant reload my_#{os}_server" + sh "vagrant up local_#{os}" + sh "vagrant up managed_#{os} --provider=managed" + sh "vagrant provision managed_#{os}" + sh "vagrant reload managed_#{os}" ensure - sh "vagrant destroy -f my_#{os}_server" - sh "vagrant destroy -f fake_managed_#{os}_server" + sh "vagrant destroy -f managed_#{os}" + sh "vagrant destroy -f local_#{os}" end end end diff --git a/Vagrantfile b/Vagrantfile index 12fcdbd..e9ccb65 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -6,29 +6,29 @@ Vagrant.configure("2") do |config| # # fake a managed linux server by bringing up a virtualbox vm # - config.vm.define :fake_managed_linux_server do |fms_config| - fms_config.vm.box = "chef/ubuntu-12.04-i386" - fms_config.vm.network :private_network, ip: "192.168.40.35" - fms_config.berkshelf.enabled = false + config.vm.define :local_linux do |ll_config| + ll_config.vm.box = "chef/ubuntu-12.04-i386" + ll_config.vm.network :private_network, ip: "192.168.40.35" + ll_config.berkshelf.enabled = false end # - # configure managed provider to connect to `fake_managed_linux_server` + # configure managed provider to connect to `local_linux` # - config.vm.define :my_linux_server do |ms_config| + config.vm.define :managed_linux do |ml_config| - ms_config.vm.box = "tknerr/managed-server-dummy" + ml_config.vm.box = "tknerr/managed-server-dummy" - ms_config.omnibus.chef_version = "12.0.3" - ms_config.berkshelf.enabled = true + ml_config.omnibus.chef_version = "12.0.3" + ml_config.berkshelf.enabled = true - ms_config.vm.provider :managed do |managed_config, override| + ml_config.vm.provider :managed do |managed_config, override| managed_config.server = "192.168.40.35" override.ssh.username = "vagrant" - override.ssh.private_key_path = ".vagrant/machines/fake_managed_linux_server/virtualbox/private_key" + override.ssh.private_key_path = ".vagrant/machines/local_linux/virtualbox/private_key" end - ms_config.vm.provision :chef_solo do |chef| + ml_config.vm.provision :chef_solo do |chef| chef.cookbooks_path = [ './cookbooks' ] chef.add_recipe "apt" chef.add_recipe "apache2" @@ -40,26 +40,26 @@ Vagrant.configure("2") do |config| # # fake a managed windows server by bringing up a virtualbox vm # - config.vm.define :fake_managed_windows_server do |fms_config| - fms_config.vm.box = "boxcutter/eval-win7x86-enterprise" - fms_config.vm.network :private_network, ip: "192.168.40.36" - fms_config.berkshelf.enabled = false + config.vm.define :local_windows do |lw_config| + lw_config.vm.box = "boxcutter/eval-win7x86-enterprise" + lw_config.vm.network :private_network, ip: "192.168.40.36" + lw_config.berkshelf.enabled = false end # - # configure managed provider to connect to `fake_managed_windows_server` + # configure managed provider to connect to `local_windows` # - config.vm.define :my_windows_server do |ms_config| + config.vm.define :managed_windows do |mw_config| - ms_config.vm.box = "tknerr/managed-server-dummy" + mw_config.vm.box = "tknerr/managed-server-dummy" - ms_config.berkshelf.enabled = false + mw_config.berkshelf.enabled = false - ms_config.vm.communicator = :winrm - ms_config.winrm.username = 'vagrant' - ms_config.winrm.password = 'vagrant' + mw_config.vm.communicator = :winrm + mw_config.winrm.username = 'vagrant' + mw_config.winrm.password = 'vagrant' - ms_config.vm.provider :managed do |managed, override| + mw_config.vm.provider :managed do |managed, override| managed.server = '192.168.40.36' end end From 2c4fc571eb69a422a92e62cd3738a1b058ad740d Mon Sep 17 00:00:00 2001 From: Torben Knerr Date: Wed, 20 May 2015 00:38:50 +0200 Subject: [PATCH 8/9] disable default synced folder for a more realistic scenario --- Vagrantfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Vagrantfile b/Vagrantfile index e9ccb65..99407a5 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -10,6 +10,7 @@ Vagrant.configure("2") do |config| ll_config.vm.box = "chef/ubuntu-12.04-i386" ll_config.vm.network :private_network, ip: "192.168.40.35" ll_config.berkshelf.enabled = false + ll_config.vm.synced_folder ".", "/vagrant", disabled: true end # @@ -44,6 +45,7 @@ Vagrant.configure("2") do |config| lw_config.vm.box = "boxcutter/eval-win7x86-enterprise" lw_config.vm.network :private_network, ip: "192.168.40.36" lw_config.berkshelf.enabled = false + lw_config.vm.synced_folder ".", "/vagrant", disabled: true end # From 9967d299e77b2d247a09897978c47c85985fa6f3 Mon Sep 17 00:00:00 2001 From: Torben Knerr Date: Wed, 20 May 2015 01:40:42 +0200 Subject: [PATCH 9/9] update to latest vagrant-berkshelf plugin, also update Berksfile source URL --- Berksfile | 4 ++-- Gemfile | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Berksfile b/Berksfile index ef85b2b..c2652b5 100644 --- a/Berksfile +++ b/Berksfile @@ -1,4 +1,4 @@ -source "https://supermarket.getchef.com" +source "https://supermarket.chef.io" cookbook 'apt' -cookbook 'apache2' \ No newline at end of file +cookbook 'apache2' diff --git a/Gemfile b/Gemfile index 70a4e0e..e3213a0 100644 --- a/Gemfile +++ b/Gemfile @@ -12,5 +12,5 @@ end group :plugins do gem "vagrant-managed-servers", path: "." gem "vagrant-omnibus", "1.4.1" - gem "vagrant-berkshelf", "3.0.1" + gem "vagrant-berkshelf", "4.0.4" end