├── .gitignore ├── .travis.yml ├── Gemfile ├── LICENSE.txt ├── README.md ├── Rakefile ├── development └── Vagrantfile ├── lib ├── vagrant-windows-domain.rb └── vagrant-windows-domain │ ├── action │ └── leave_domain.rb │ ├── config.rb │ ├── locales │ └── en.yml │ ├── plugin.rb │ ├── provisioner.rb │ ├── templates │ └── runner.ps1.erb │ └── version.rb ├── spec ├── base.rb ├── provisioner │ ├── config_spec.rb │ └── provisioner_spec.rb └── spec_helper.rb └── vagrant-windows-domain.gemspec /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | .bundle 4 | .config 5 | .yardoc 6 | Gemfile.lock 7 | InstalledFiles 8 | _yardoc 9 | coverage 10 | doc/ 11 | lib/bundler/man 12 | pkg 13 | rdoc 14 | spec/reports 15 | test/tmp 16 | test/version_tmp 17 | tmp 18 | *.bundle 19 | *.so 20 | *.o 21 | *.a 22 | mkmf.log 23 | .vagrant 24 | .idea -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | before_install: 3 | - gem update --system 4 | - gem install bundler 5 | rvm: 6 | - ruby-head 7 | - 2.5.1 8 | - 2.4.4 9 | matrix: 10 | allow_failures: 11 | - rvm: ruby-head 12 | fast_finish: true 13 | env: 14 | matrix: 15 | - VAGRANT_VERSION=v2.1.5 16 | script: bundle exec rake test:unit 17 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Specify your gem's dependencies in vagrant-windows-domain.gemspec 4 | gemspec 5 | 6 | group :development do 7 | gem "vagrant", git: "https://github.com/mitchellh/vagrant.git", :tag => "v2.1.5" 8 | end 9 | 10 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Matt Fellows 2 | 3 | MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Vagrant Windows Domain Plugin 2 | 3 | [![Build Status](https://travis-ci.org/SEEK-Jobs/vagrant-windows-domain.svg)](https://travis-ci.org/SEEK-Jobs/vagrant-windows-domain) 4 | [![Coverage Status](https://coveralls.io/repos/SEEK-Jobs/vagrant-windows-domain/badge.svg?branch=master)](https://coveralls.io/r/SEEK-Jobs/vagrant-windows-domain?branch=master) 5 | [![Gem Version](https://badge.fury.io/rb/vagrant-windows-domain.svg)](http://badge.fury.io/rb/vagrant-windows-domain) 6 | 7 | A Vagrant Plugin that makes connecting and disconnecting your Windows Vagrant box to a Windows Domain a cinch. 8 | 9 | On a `vagrant up` - unless credentials are supplied - it will prompt the user for their domain credentials and add the guest to the domain, including restarting the guest without interfering with other provisioners. 10 | 11 | On a `vagrant destroy`, it will do the same and remove itself from the Domain, keeping things neat-n-tidy. 12 | 13 | ## Installation 14 | 15 | ```vagrant plugin install vagrant-windows-domain``` 16 | 17 | ## Usage 18 | 19 | In your Vagrantfile, add the following plugin and configure to your needs: 20 | 21 | ```ruby 22 | config.vm.provision :windows_domain do |domain| 23 | 24 | # The Windows Domain to join. 25 | # 26 | # Setting this will result in an additional restart. 27 | domain.domain = "domain.int" 28 | 29 | # The new Computer Name to use when joining the domain. 30 | # 31 | # Uses the Rename-Computer PowerShell command. 32 | # Specifies a new name for the computer in the new domain. 33 | domain.computer_name = "myfandangledname" 34 | 35 | # The Username to use when authenticating against the Domain. 36 | # 37 | # Specifies a user account that has permission to join the computers to a new domain. 38 | # 39 | # If not supplied the plugin will prompt the user during provisioning to provide one. 40 | domain.username = "me" 41 | 42 | # The Password to use when authenticating against the Domain. 43 | # 44 | # Specifies the password of a user account that has permission to 45 | # join the computers to a new domain. 46 | # 47 | # If not supplied the plugin will prompt the user during provisioning to provide one. 48 | domain.password = "iprobablyshouldntusethisfield" 49 | 50 | # IP address of primary DNS server 51 | # 52 | # Specifies the IP address you want assigned as the primary DNS server for the primary nic. 53 | # If not supplied, the nic's primary dns server will be assigned dynamically. 54 | domain.primary_dns = "8.8.8.8" 55 | 56 | #IP address of the secondary DNS server 57 | # 58 | # Specifies the IP address you want assigned as the secondary DNS server for the primary nic 59 | # If not supplied, the nic's secondary dns server will be assigned dynamically. 60 | domain.secondary_dns = "8.8.4.4" 61 | 62 | # The set of Advanced options to pass when joining the Domain. 63 | # 64 | # See (https://technet.microsoft.com/en-us/library/hh849798.aspx) for detail, these are generally not required. 65 | domain.join_options = [ "JoinReadOnly" ] 66 | 67 | # Organisational Unit path in AD. 68 | # 69 | # Specifies an organizational unit (OU) for the domain account. 70 | # Enter the full distinguished name of the OU in quotation marks. 71 | # The default value is the default OU for machine objects in the domain. 72 | domain.ou_path = "OU=testOU,DC=domain,DC=Domain,DC=com" 73 | 74 | # Performs an unsecure join to the specified domain. 75 | # 76 | # When this option is enabled username/password are not required and cannot be used. 77 | domain.unsecure = false 78 | end 79 | ``` 80 | ## Example 81 | 82 | There is a [sample](https://github.com/SEEK-Jobs/vagrant-windows-domain/tree/master/development) Vagrant setup used for development of this plugin. 83 | This is a great real-life example to get you on your way. 84 | 85 | ### Supported Environments 86 | 87 | Currently the plugin supports any Windows environment with Powershell 3+ installed (2008r2, 2012r2 should work nicely). 88 | 89 | ## Development 90 | 91 | Before getting started, read the Vagrant plugin [development basics](https://docs.vagrantup.com/v2/plugins/development-basics.html) and [packaging](https://docs.vagrantup.com/v2/plugins/packaging.html) documentation. 92 | 93 | You will need Ruby 2.1.5 and Bundler v1.12.5 installed before proceeding. 94 | 95 | _NOTE_: it _must_ be bundler v1.12.5 due to a hard dependency in Vagrant at this time. 96 | 97 | ``` 98 | git clone git@github.com:mefellows/vagrant-dsc.git 99 | cd vagrant-dsc 100 | bundle install 101 | ``` 102 | 103 | Run tests: 104 | ``` 105 | bundle exec rake spec 106 | ``` 107 | 108 | Run Vagrant in context of current vagrant-dsc plugin: 109 | ``` 110 | cd 111 | bundle exec vagrant up 112 | ``` 113 | 114 | There is a test Vagrant DSC setup in `./development` that is a good example of a simple acceptance test. 115 | 116 | ### Multiple Bundlers? 117 | 118 | If you have multiple Bundler versions, you can still use 1.12.5 with the following: 119 | 120 | ``` 121 | bundle _1.12.5_ 122 | ``` 123 | 124 | e.g. `bundle _1.12.5_ exec rake spec` 125 | 126 | ## Uninstallation 127 | 128 | ```vagrant plugin uninstall vagrant-windows-domain``` 129 | 130 | ## Contributing 131 | 132 | 1. Fork it ( https://github.com/[my-github-username]/vagrant-windows-domain/fork ) 133 | 2. Create your feature branch (`git checkout -b my-new-feature`) 134 | 3. Commit your changes (`git commit -am 'Add some feature'`) 135 | 4. Squash commits & push to the branch (`git push origin my-new-feature`) 136 | 5. Create a new Pull Request 137 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | require 'rspec/core/rake_task' 3 | task :default => [:test, :quality] 4 | # Remove 'install' task as the gem is installed to Vagrant, not to system 5 | Rake::Task[:install].clear 6 | namespace :test do 7 | RSpec::Core::RakeTask.new('unit') do |task| 8 | task.pattern = 'spec/**/*_spec.rb' 9 | end 10 | end 11 | desc "Run all tests" 12 | task :test => ['test:unit'] 13 | task :spec => :test -------------------------------------------------------------------------------- /development/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | $shell_script = <