Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a windows guest example to the sample Vagrantfile #48

Merged
merged 12 commits into from
May 22, 2015
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
end
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
17 changes: 10 additions & 7 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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_#{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_#{os}_server"
sh "vagrant destroy -f fake_managed_#{os}_server"
end
end
end
41 changes: 35 additions & 6 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@
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|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, I named these local_linux and managed_linux in my example and it has made it easier for me to tell them apart.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, much better. naming is hard :-)

I'll adapt to your suggestion

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"

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"
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|
Expand All @@ -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