From 548e4df9da1c1a862c2a7fb635cfc03c04a7df48 Mon Sep 17 00:00:00 2001 From: Christian Berendt Date: Wed, 16 Apr 2014 12:43:42 +0200 Subject: [PATCH 01/42] added subcommand keypairs to list SSH key pairs Example output of this subcommand (one keypair with the name vagrant is available on Rackspace Servers): ``` $ vagrant rackspace keypairs ==> default: KeyPair Name ==> default: vagrant ``` --- lib/vagrant-rackspace/action.rb | 8 +++++++ lib/vagrant-rackspace/action/list_keypairs.rb | 20 ++++++++++++++++++ lib/vagrant-rackspace/command/keypairs.rb | 21 +++++++++++++++++++ lib/vagrant-rackspace/command/root.rb | 4 ++++ 4 files changed, 53 insertions(+) create mode 100644 lib/vagrant-rackspace/action/list_keypairs.rb create mode 100644 lib/vagrant-rackspace/command/keypairs.rb diff --git a/lib/vagrant-rackspace/action.rb b/lib/vagrant-rackspace/action.rb index 8773cad..71ebb89 100644 --- a/lib/vagrant-rackspace/action.rb +++ b/lib/vagrant-rackspace/action.rb @@ -142,6 +142,13 @@ def self.action_list_flavors end end + def self.action_list_keypairs + Vagrant::Action::Builder.new.tap do |b| + b.use ConnectRackspace + b.use ListKeyPairs + end + end + # The autoload farm action_root = Pathname.new(File.expand_path("../action", __FILE__)) autoload :ConnectRackspace, action_root.join("connect_rackspace") @@ -156,6 +163,7 @@ def self.action_list_flavors autoload :CreateImage, action_root.join("create_image") autoload :ListImages, action_root.join("list_images") autoload :ListFlavors, action_root.join("list_flavors") + autoload :ListKeyPairs, action_root.join("list_keypairs") end end end diff --git a/lib/vagrant-rackspace/action/list_keypairs.rb b/lib/vagrant-rackspace/action/list_keypairs.rb new file mode 100644 index 0000000..0ba77d5 --- /dev/null +++ b/lib/vagrant-rackspace/action/list_keypairs.rb @@ -0,0 +1,20 @@ +module VagrantPlugins + module Rackspace + module Action + class ListKeyPairs + def initialize(app, env) + @app = app + end + + def call(env) + compute_service = env[:rackspace_compute] + env[:ui].info ('%s' % ['KeyPair Name']) + compute_service.key_pairs.sort_by(&:name).each do |keypair| + env[:ui].info ('%s' % [keypair.name]) + end + @app.call(env) + end + end + end + end +end diff --git a/lib/vagrant-rackspace/command/keypairs.rb b/lib/vagrant-rackspace/command/keypairs.rb new file mode 100644 index 0000000..336ed7b --- /dev/null +++ b/lib/vagrant-rackspace/command/keypairs.rb @@ -0,0 +1,21 @@ +module VagrantPlugins + module Rackspace + module Command + class KeyPairs < Vagrant.plugin("2", :command) + def execute + options = {} + opts = OptionParser.new do |o| + o.banner = "Usage: vagrant rackspace keypairs [options]" + end + + argv = parse_options(opts) + return if !argv + + with_target_vms(argv, :provider => :rackspace) do |machine| + machine.action('list_keypairs') + end + end + end + end + end +end diff --git a/lib/vagrant-rackspace/command/root.rb b/lib/vagrant-rackspace/command/root.rb index 2fb584f..1b786a6 100644 --- a/lib/vagrant-rackspace/command/root.rb +++ b/lib/vagrant-rackspace/command/root.rb @@ -20,6 +20,10 @@ def initialize(argv, env) require File.expand_path("../flavors", __FILE__) Flavors end + @subcommands.register(:keypairs) do + require File.expand_path("../keypairs", __FILE__) + KeyPairs + end super(argv, env) end From 43d3ec279cd79e17b68f3151f070d37352a10d3e Mon Sep 17 00:00:00 2001 From: Christian Berendt Date: Wed, 16 Apr 2014 13:07:00 +0200 Subject: [PATCH 02/42] added subcommand networks to list networks Example output of this subcommand: ``` $ vagrant rackspace networks ==> default: Network Name Network CIDR ==> default: private ==> default: public ==> default: vagrant001 192.168.3.0/24 ==> default: vagrant002 192.168.4.0/24 ==> default: vagrant003 192.168.5.0/24 ``` --- lib/vagrant-rackspace/action.rb | 8 +++++++ lib/vagrant-rackspace/action/list_networks.rb | 20 ++++++++++++++++++ lib/vagrant-rackspace/command/networks.rb | 21 +++++++++++++++++++ lib/vagrant-rackspace/command/root.rb | 4 ++++ 4 files changed, 53 insertions(+) create mode 100644 lib/vagrant-rackspace/action/list_networks.rb create mode 100644 lib/vagrant-rackspace/command/networks.rb diff --git a/lib/vagrant-rackspace/action.rb b/lib/vagrant-rackspace/action.rb index 8773cad..a6bbb80 100644 --- a/lib/vagrant-rackspace/action.rb +++ b/lib/vagrant-rackspace/action.rb @@ -142,6 +142,13 @@ def self.action_list_flavors end end + def self.action_list_networks + Vagrant::Action::Builder.new.tap do |b| + b.use ConnectRackspace + b.use ListNetworks + end + end + # The autoload farm action_root = Pathname.new(File.expand_path("../action", __FILE__)) autoload :ConnectRackspace, action_root.join("connect_rackspace") @@ -156,6 +163,7 @@ def self.action_list_flavors autoload :CreateImage, action_root.join("create_image") autoload :ListImages, action_root.join("list_images") autoload :ListFlavors, action_root.join("list_flavors") + autoload :ListNetworks, action_root.join("list_networks") end end end diff --git a/lib/vagrant-rackspace/action/list_networks.rb b/lib/vagrant-rackspace/action/list_networks.rb new file mode 100644 index 0000000..d2f9936 --- /dev/null +++ b/lib/vagrant-rackspace/action/list_networks.rb @@ -0,0 +1,20 @@ +module VagrantPlugins + module Rackspace + module Action + class ListNetworks + def initialize(app, env) + @app = app + end + + def call(env) + compute_service = env[:rackspace_compute] + env[:ui].info ('%-36s %s' % ['Network Name', 'Network CIDR']) + compute_service.networks.sort_by(&:label).each do |network| + env[:ui].info ('%-36s %s' % [network.label, network.cidr]) + end + @app.call(env) + end + end + end + end +end diff --git a/lib/vagrant-rackspace/command/networks.rb b/lib/vagrant-rackspace/command/networks.rb new file mode 100644 index 0000000..9405e7e --- /dev/null +++ b/lib/vagrant-rackspace/command/networks.rb @@ -0,0 +1,21 @@ +module VagrantPlugins + module Rackspace + module Command + class Networks < Vagrant.plugin("2", :command) + def execute + options = {} + opts = OptionParser.new do |o| + o.banner = "Usage: vagrant rackspace networks [options]" + end + + argv = parse_options(opts) + return if !argv + + with_target_vms(argv, :provider => :rackspace) do |machine| + machine.action('list_networks') + end + end + end + end + end +end diff --git a/lib/vagrant-rackspace/command/root.rb b/lib/vagrant-rackspace/command/root.rb index 2fb584f..150de64 100644 --- a/lib/vagrant-rackspace/command/root.rb +++ b/lib/vagrant-rackspace/command/root.rb @@ -20,6 +20,10 @@ def initialize(argv, env) require File.expand_path("../flavors", __FILE__) Flavors end + @subcommands.register(:networks) do + require File.expand_path("../networks", __FILE__) + Networks + end super(argv, env) end From b47fb590c0c80e17681a23d2e731d17e09499859 Mon Sep 17 00:00:00 2001 From: Christian Berendt Date: Wed, 16 Apr 2014 15:59:01 +0200 Subject: [PATCH 03/42] added subcommand servers to list servers Example output of this subcommand: ``` $ vagrant rackspace servers ==> devstack: Server Name State IPv4 address ==> devstack: devstack ACTIVE 166.78.18.8 ``` --- lib/vagrant-rackspace/action.rb | 8 ++++++++ lib/vagrant-rackspace/action/list_servers.rb | 20 +++++++++++++++++++ lib/vagrant-rackspace/command/root.rb | 4 ++++ lib/vagrant-rackspace/command/servers.rb | 21 ++++++++++++++++++++ 4 files changed, 53 insertions(+) create mode 100644 lib/vagrant-rackspace/action/list_servers.rb create mode 100644 lib/vagrant-rackspace/command/servers.rb diff --git a/lib/vagrant-rackspace/action.rb b/lib/vagrant-rackspace/action.rb index 8773cad..7bad53d 100644 --- a/lib/vagrant-rackspace/action.rb +++ b/lib/vagrant-rackspace/action.rb @@ -142,6 +142,13 @@ def self.action_list_flavors end end + def self.action_list_servers + Vagrant::Action::Builder.new.tap do |b| + b.use ConnectRackspace + b.use ListServers + end + end + # The autoload farm action_root = Pathname.new(File.expand_path("../action", __FILE__)) autoload :ConnectRackspace, action_root.join("connect_rackspace") @@ -156,6 +163,7 @@ def self.action_list_flavors autoload :CreateImage, action_root.join("create_image") autoload :ListImages, action_root.join("list_images") autoload :ListFlavors, action_root.join("list_flavors") + autoload :ListServers, action_root.join("list_servers") end end end diff --git a/lib/vagrant-rackspace/action/list_servers.rb b/lib/vagrant-rackspace/action/list_servers.rb new file mode 100644 index 0000000..a4ea87b --- /dev/null +++ b/lib/vagrant-rackspace/action/list_servers.rb @@ -0,0 +1,20 @@ +module VagrantPlugins + module Rackspace + module Action + class ListServers + def initialize(app, env) + @app = app + end + + def call(env) + compute_service = env[:rackspace_compute] + env[:ui].info ('%-20s %-20s %s' % ['Server Name', 'State', 'IPv4 address']) + compute_service.servers.sort_by(&:name).each do |server| + env[:ui].info ('%-20s %-20s %s' % [server.name, server.state, server.access_ipv4_address]) + end + @app.call(env) + end + end + end + end +end diff --git a/lib/vagrant-rackspace/command/root.rb b/lib/vagrant-rackspace/command/root.rb index 2fb584f..d55cd94 100644 --- a/lib/vagrant-rackspace/command/root.rb +++ b/lib/vagrant-rackspace/command/root.rb @@ -20,6 +20,10 @@ def initialize(argv, env) require File.expand_path("../flavors", __FILE__) Flavors end + @subcommands.register(:servers) do + require File.expand_path("../servers", __FILE__) + Servers + end super(argv, env) end diff --git a/lib/vagrant-rackspace/command/servers.rb b/lib/vagrant-rackspace/command/servers.rb new file mode 100644 index 0000000..c780271 --- /dev/null +++ b/lib/vagrant-rackspace/command/servers.rb @@ -0,0 +1,21 @@ +module VagrantPlugins + module Rackspace + module Command + class Servers < Vagrant.plugin("2", :command) + def execute + options = {} + opts = OptionParser.new do |o| + o.banner = "Usage: vagrant rackspace servers [options]" + end + + argv = parse_options(opts) + return if !argv + + with_target_vms(argv, :provider => :rackspace) do |machine| + machine.action('list_servers') + end + end + end + end + end +end From 1a43a28ed5de96f1c6ab9f70fbdf2193b7cecc45 Mon Sep 17 00:00:00 2001 From: Christian Berendt Date: Thu, 8 May 2014 09:50:42 +0200 Subject: [PATCH 04/42] rewrote the custom commands section Also added new commands introduced by #90, #91 and #92. --- README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5d845d7..f1d2e71 100644 --- a/README.md +++ b/README.md @@ -96,21 +96,20 @@ If you are using RackConnect with vagrant, you will need to add the following li The plugin includes several Rackspace-specific vagrant commands. You can get the list of available commands with `vagrant rackspace -h`. -If you want to know what images or flavors are available for a machine, you can use: +For example to list all available images for a machine you can use: ``` $ vagrant rackspace images -$ vagrant rackspace flavors ``` In a multi-machine Vagrantfile you can also query for a single machine: + ``` $ vagrant rackspace images -$ vagrant rackspace flavors ``` -These command will connect to Rackspace using the settings associated with the machine, -and query the region to get the list of available images or flavors. +These commands will connect to Rackspace using the settings associated with the machine, +and query the region to get the list of available flavors, images, keypairs, networks and servers. ## Box Format From 8b4f486edbbf5a166dca4b4f105a8ecb8d5a3b03 Mon Sep 17 00:00:00 2001 From: Christian Berendt Date: Thu, 8 May 2014 09:57:08 +0200 Subject: [PATCH 05/42] added column Network ID to the network list ``` ==> devstack: Network Name Network CIDR Network ID ==> devstack: private 11111111-1111-1111-1111-111111111111 ==> devstack: public 00000000-0000-0000-0000-000000000000 ==> devstack: vagrant001 192.168.3.0/24 c7da5d07-ac80-49ca-8575-8822c71bc758 ==> devstack: vagrant002 192.168.4.0/24 f45ba323-dd21-4999-a5d7-c98a3edfb7a3 ==> devstack: vagrant003 192.168.5.0/24 e49a86df-6c98-42d1-a66b-11c80e1252e1 ``` --- lib/vagrant-rackspace/action/list_networks.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/vagrant-rackspace/action/list_networks.rb b/lib/vagrant-rackspace/action/list_networks.rb index d2f9936..6e7d98a 100644 --- a/lib/vagrant-rackspace/action/list_networks.rb +++ b/lib/vagrant-rackspace/action/list_networks.rb @@ -8,9 +8,9 @@ def initialize(app, env) def call(env) compute_service = env[:rackspace_compute] - env[:ui].info ('%-36s %s' % ['Network Name', 'Network CIDR']) + env[:ui].info ('%-36s %-24s %s' % ['Network Name', 'Network CIDR', 'Network ID']) compute_service.networks.sort_by(&:label).each do |network| - env[:ui].info ('%-36s %s' % [network.label, network.cidr]) + env[:ui].info ('%-36s %-24s %s' % [network.label, network.cidr, network.id]) end @app.call(env) end From cebafef1df23320ebf4940097db0f41ded0a9539 Mon Sep 17 00:00:00 2001 From: David Kinzer Date: Thu, 24 Jul 2014 12:02:11 -0400 Subject: [PATCH 06/42] Confirm Rackspace server destruction. This pull request implements a fix for mitchellh/vagrant-rackspace#114 --- lib/vagrant-rackspace/action.rb | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/vagrant-rackspace/action.rb b/lib/vagrant-rackspace/action.rb index 3ee07a4..4882478 100644 --- a/lib/vagrant-rackspace/action.rb +++ b/lib/vagrant-rackspace/action.rb @@ -12,15 +12,22 @@ module Action def self.action_destroy Vagrant::Action::Builder.new.tap do |b| b.use ConfigValidate - b.use Call, IsCreated do |env, b2| + b.use Call, IsCreated do |env, b1| if !env[:result] - b2.use MessageNotCreated + b1.use MessageNotCreated next end - b2.use ConnectRackspace - b2.use DeleteServer - b2.use ProvisionerCleanup if defined?(ProvisionerCleanup) + b1.use Call, DestroyConfirm do |env1, b2| + if env1[:resul] + b2.use ConnectRackspace + b2.use DeleteServer + b2.use ProvisionerCleanup if defined?(ProvisionerCleanup) + else + b2.use MessageWillNotDestroy + next + end + end end end end From 48fcda5b0adbe0782bd47be67ce6cc01189e4d6d Mon Sep 17 00:00:00 2001 From: Max Lincoln Date: Tue, 9 Dec 2014 12:13:06 -0500 Subject: [PATCH 07/42] Sample Vagrantfile that includes Ubuntu, CentOS, and Windows servers --- Vagrantfile | 161 +++++++++++++++++----------------------------------- 1 file changed, 51 insertions(+), 110 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 5edc089..6e66d3e 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -4,125 +4,66 @@ # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! VAGRANTFILE_API_VERSION = "2" +%w{RAX_USERNAME RAX_API_KEY VAGRANT_ADMIN_PASSWORD}.each do |var| + abort "Please set the environment variable #{var} in order to run the test" unless ENV.key? var +end + Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| - Vagrant.require_plugin "vagrant-rackspace" # All Vagrant configuration is done here. The most common configuration # options are documented and commented below. For a complete reference, # please see the online documentation at vagrantup.com. # Every Vagrant virtual environment requires a box to build off of. config.vm.box = "dummy" - config.vm.provider :rackspace do |rs| - rs.username = ENV['RAX_USERNAME'] - rs.admin_password = ENV['VAGRANT_ADMIN_PASSWORD'] - rs.api_key = ENV['RAX_API_KEY'] - rs.flavor = /1 GB Performance/ - rs.image = /Ubuntu/ - rs.rackspace_region = :iad - # rs.rsync_include 'PATTERN' # per man page for rsync + config.vm.define :ubuntu do |ubuntu| + ubuntu.ssh.private_key_path = '~/.ssh/id_rsa' + ubuntu.vm.provider :rackspace do |rs| + rs.username = ENV['RAX_USERNAME'] + rs.admin_password = ENV['VAGRANT_ADMIN_PASSWORD'] + rs.api_key = ENV['RAX_API_KEY'] + rs.flavor = /1 GB Performance/ + rs.image = /Ubuntu/ + rs.rackspace_region = :iad + rs.public_key_path = '~/.ssh/id_rsa.pub' + end end - # The url from where the 'config.vm.box' box will be fetched if it - # doesn't already exist on the user's system. - # config.vm.box_url = "http://domain.com/path/to/above.box" - - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine. In the example below, - # accessing "localhost:8080" will access port 80 on the guest machine. - # config.vm.network :forwarded_port, guest: 80, host: 8080 - - # Create a private network, which allows host-only access to the machine - # using a specific IP. - # config.vm.network :private_network, ip: "192.168.33.10" - - # Create a public network, which generally matched to bridged network. - # Bridged networks make the machine appear as another physical device on - # your network. - # config.vm.network :public_network - - # If true, then any SSH connections made will enable agent forwarding. - # Default value: false - # config.ssh.forward_agent = true - # Share an additional folder to the guest VM. The first argument is - # the path on the host to the actual folder. The second argument is - # the path on the guest to mount the folder. And the optional third - # argument is a set of non-required options. - # config.vm.synced_folder "../data", "/vagrant_data" - - # Provider-specific configuration so you can fine-tune various - # backing providers for Vagrant. These expose provider-specific options. - # Example for VirtualBox: - # - # config.vm.provider :virtualbox do |vb| - # # Don't boot with headless mode - # vb.gui = true - # - # # Use VBoxManage to customize the VM. For example to change memory: - # vb.customize ["modifyvm", :id, "--memory", "1024"] - # end - # - # View the documentation for the provider you're using for more - # information on available options. - - # Enable provisioning with Puppet stand alone. Puppet manifests - # are contained in a directory path relative to this Vagrantfile. - # You will need to create the manifests directory and a manifest in - # the file base.pp in the manifests_path directory. - # - # An example Puppet manifest to provision the message of the day: - # - # # group { "puppet": - # # ensure => "present", - # # } - # # - # # File { owner => 0, group => 0, mode => 0644 } - # # - # # file { '/etc/motd': - # # content => "Welcome to your Vagrant-built virtual machine! - # # Managed by Puppet.\n" - # # } - # - # config.vm.provision :puppet do |puppet| - # puppet.manifests_path = "manifests" - # puppet.manifest_file = "init.pp" - # end - - # Enable provisioning with chef solo, specifying a cookbooks path, roles - # path, and data_bags path (all relative to this Vagrantfile), and adding - # some recipes and/or roles. - # - # config.vm.provision :chef_solo do |chef| - # chef.cookbooks_path = "../my-recipes/cookbooks" - # chef.roles_path = "../my-recipes/roles" - # chef.data_bags_path = "../my-recipes/data_bags" - # chef.add_recipe "mysql" - # chef.add_role "web" - # - # # You may also specify custom JSON attributes: - # chef.json = { :mysql_password => "foo" } - # end + config.vm.define :centos do |centos| + centos.ssh.private_key_path = '~/.ssh/id_rsa' + centos.ssh.pty = true + centos.vm.provider :rackspace do |rs| + rs.username = ENV['RAX_USERNAME'] + rs.admin_password = ENV['VAGRANT_ADMIN_PASSWORD'] + rs.api_key = ENV['RAX_API_KEY'] + rs.flavor = /1 GB Performance/ + rs.image = /^CentOS/ # Don't match OnMetal - CentOS + rs.rackspace_region = :iad + rs.public_key_path = '~/.ssh/id_rsa.pub' + rs.init_script = 'sed -i\'.bk\' -e \'s/^\(Defaults\s\+requiretty\)/# \1/\' /etc/sudoers' + end + end - # Enable provisioning with chef server, specifying the chef server URL, - # and the path to the validation key (relative to this Vagrantfile). - # - # The Opscode Platform uses HTTPS. Substitute your organization for - # ORGNAME in the URL and validation key. - # - # If you have your own Chef Server, use the appropriate URL, which may be - # HTTP instead of HTTPS depending on your configuration. Also change the - # validation key to validation.pem. - # - # config.vm.provision :chef_client do |chef| - # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME" - # chef.validation_key_path = "ORGNAME-validator.pem" - # end - # - # If you're using the Opscode platform, your validator client is - # ORGNAME-validator, replacing ORGNAME with your organization name. - # - # If you have your own Chef Server, the default validation client name is - # chef-validator, unless you changed the configuration. - # - # chef.validation_client_name = "ORGNAME-validator" + config.vm.define :windows do |windows| + windows.vm.provision :shell, :inline => 'Write-Output "WinRM is working!"' + windows.vm.communicator = :winrm + windows.winrm.username = 'Administrator' + windows.winrm.password = ENV['VAGRANT_ADMIN_PASSWORD'] + begin + windows.winrm.transport = :ssl + windows.winrm.ssl_peer_verification = false + rescue + puts "Warning: Vagrant #{Vagrant::VERSION} does not support WinRM over SSL." + end + windows.vm.synced_folder ".", "/vagrant", disabled: true + windows.vm.provider :rackspace do |rs| + rs.username = ENV['RAX_USERNAME'] + rs.api_key = ENV['RAX_API_KEY'] + rs.admin_password = ENV['VAGRANT_ADMIN_PASSWORD'] + rs.flavor = /2 GB Performance/ + rs.image = 'Windows Server 2012' + rs.rackspace_region = ENV['RAX_REGION'] ||= 'dfw' + rs.init_script = File.read 'bootstrap.cmd' + end + end end From 65ef6f19f9e3abc79d0beca28d585514f48bc3b4 Mon Sep 17 00:00:00 2001 From: Max Lincoln Date: Tue, 9 Dec 2014 12:14:24 -0500 Subject: [PATCH 08/42] Generic communicator variable for either ssh or winrm --- lib/vagrant-rackspace/action/create_server.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/vagrant-rackspace/action/create_server.rb b/lib/vagrant-rackspace/action/create_server.rb index 7aa10e3..4a32110 100644 --- a/lib/vagrant-rackspace/action/create_server.rb +++ b/lib/vagrant-rackspace/action/create_server.rb @@ -16,8 +16,14 @@ def initialize(app, env) end def call(env) - # Get the configs - config = env[:machine].provider_config + # Get the Rackspace configs + config = env[:machine].provider_config + machine_config = env[:machine].config + begin + communicator = machine_config.vm.communicator ||= :ssh + rescue NoMethodError + communicator = :ssh + end # Find the flavor env[:ui].info(I18n.t("vagrant_rackspace.finding_flavor")) From 4e4dcf54c2fe72722b38a57e824777bd99e409e1 Mon Sep 17 00:00:00 2001 From: Max Lincoln Date: Tue, 9 Dec 2014 12:15:11 -0500 Subject: [PATCH 09/42] Support for init_script --- lib/vagrant-rackspace/action/create_server.rb | 18 +++++++++++++++++- lib/vagrant-rackspace/config.rb | 13 +++++++++++++ spec/vagrant-rackspace/config_spec.rb | 6 ++++-- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/lib/vagrant-rackspace/action/create_server.rb b/lib/vagrant-rackspace/action/create_server.rb index 4a32110..253a595 100644 --- a/lib/vagrant-rackspace/action/create_server.rb +++ b/lib/vagrant-rackspace/action/create_server.rb @@ -84,7 +84,17 @@ def call(env) options[:personality] = [ { :path => "/root/.ssh/authorized_keys", - :contents => Base64.encode64(File.read(public_key_path)) + :contents => encode64(File.read(public_key_path)) + } + ] + end + + if config.init_script && communicator == :winrm + # Might want to check init_script against known limits + options[:personality] = [ + { + :path => 'C:\\cloud-automation\\bootstrap.cmd', + :contents => encode64(config.init_script, :crlf_newline => true) } ] end @@ -149,6 +159,7 @@ def call(env) env[:ui].info(I18n.t("vagrant_rackspace.ready")) end + env[:machine].communicate.sudo config.init_script if config.init_script && communicator == :ssh @app.call(env) end @@ -180,6 +191,11 @@ def find_matching(collection, name) item end + def encode64(content, options = nil) + content = content.encode options if options + encoded = Base64.encode64 content + encoded.strip + end end end diff --git a/lib/vagrant-rackspace/config.rb b/lib/vagrant-rackspace/config.rb index e1aa526..f40f15a 100644 --- a/lib/vagrant-rackspace/config.rb +++ b/lib/vagrant-rackspace/config.rb @@ -119,6 +119,17 @@ class Config < Vagrant.plugin("2", :config) # @return [String] attr_accessor :admin_password + # A initialization script to run on the target machine before + # Vagrant connects. It should generally be used only for enabling + # and shell connection transport protocols, like SSH or WinRM. Use + # normal Vagrant provisioners for other purposes. + # + # This script may be subject to the limits for Server Personality. + # + # @return [String] + # @see http://docs.rackspace.com/servers/api/v2/cs-devguide/content/Server_Personality-d1e2543.html Server Personality + attr_accessor :init_script + # Default Rackspace Cloud Network IDs SERVICE_NET_ID = '11111111-1111-1111-1111-111111111111' PUBLIC_NET_ID = '00000000-0000-0000-0000-000000000000' @@ -139,6 +150,7 @@ def initialize @disk_config = UNSET_VALUE @networks = [] @rsync_includes = [] + @init_script = UNSET_VALUE end def finalize! @@ -157,6 +169,7 @@ def finalize! @disk_config = nil if @disk_config == UNSET_VALUE @networks = nil if @networks.empty? @rsync_includes = nil if @rsync_includes.empty? + @init_script = nil if @init_script == UNSET_VALUE if @public_key_path == UNSET_VALUE @public_key_path = Vagrant.source_root.join("keys/vagrant.pub") diff --git a/spec/vagrant-rackspace/config_spec.rb b/spec/vagrant-rackspace/config_spec.rb index a5f3239..d36dfa5 100644 --- a/spec/vagrant-rackspace/config_spec.rb +++ b/spec/vagrant-rackspace/config_spec.rb @@ -25,6 +25,7 @@ its(:networks) { should be_nil } its(:rsync_includes) { should be_nil } its(:admin_password) { should be_nil } + its(:init_script) { should be_nil } end describe "overriding defaults" do @@ -39,7 +40,8 @@ :server_name, :disk_config, :username, - :admin_password].each do |attribute| + :admin_password, + :init_script].each do |attribute| it "should not default #{attribute} if overridden" do subject.send("#{attribute}=".to_sym, "foo") subject.finalize! @@ -56,7 +58,7 @@ subject.send(:networks).should include(VagrantPlugins::Rackspace::Config::SERVICE_NET_ID) end - it "should not default rsync_includes if overridden" do + it "should not default rsync_includes if overridden" do inc = "core" subject.send(:rsync_include, inc) subject.finalize! From 7c6af4c7c3e37f84580a706e701cf5f66dcb873a Mon Sep 17 00:00:00 2001 From: Max Lincoln Date: Tue, 9 Dec 2014 12:19:03 -0500 Subject: [PATCH 10/42] Sample init_script for WinRM setup --- bootstrap.cmd | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 bootstrap.cmd diff --git a/bootstrap.cmd b/bootstrap.cmd new file mode 100644 index 0000000..a443a29 --- /dev/null +++ b/bootstrap.cmd @@ -0,0 +1,16 @@ +Function SetupWinRM +{ + Param( + [String]$hostname, + [String]$thumbprint + ) + netsh advfirewall firewall set rule group="remote administration" new enable=yes + netsh advfirewall firewall add rule name="WinRM HTTP" dir=in action=allow protocol=TCP localport=5985 + netsh advfirewall firewall add rule name="WinRM HTTPS" dir=in action=allow protocol=TCP localport=5986 + winrm create winrm/config/Listener?Address=*+Transport=HTTPS "@{Hostname=`"${hostname}`"; CertificateThumbprint=`"${thumbprint}`"}" +} + +$hostname = $env:COMPUTERNAME +$cert = New-SelfSignedCertificate -CertStoreLocation cert:\LocalMachine\My -DnsName $hostname +$thumbprint = $cert.Thumbprint +SetupWinRM -hostname $hostname -thumbprint $thumbprint From 69a70542ba18c7940fd0d7f2155fdae3a2ce06b4 Mon Sep 17 00:00:00 2001 From: Max Lincoln Date: Tue, 9 Dec 2014 13:54:58 -0500 Subject: [PATCH 11/42] Fixed doc typo --- lib/vagrant-rackspace/config.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/vagrant-rackspace/config.rb b/lib/vagrant-rackspace/config.rb index f40f15a..b1f4ba6 100644 --- a/lib/vagrant-rackspace/config.rb +++ b/lib/vagrant-rackspace/config.rb @@ -121,8 +121,8 @@ class Config < Vagrant.plugin("2", :config) # A initialization script to run on the target machine before # Vagrant connects. It should generally be used only for enabling - # and shell connection transport protocols, like SSH or WinRM. Use - # normal Vagrant provisioners for other purposes. + # or securing shell connection transport protocols, like SSH or WinRM. + # Use normal Vagrant provisioners for other purposes. # # This script may be subject to the limits for Server Personality. # From 1a756f974b7ac5b0e817c11fa8c8947136dc7c02 Mon Sep 17 00:00:00 2001 From: Max Lincoln Date: Tue, 9 Dec 2014 14:25:29 -0500 Subject: [PATCH 12/42] README update [ci skip] --- README.md | 53 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ae44709..2423ac3 100644 --- a/README.md +++ b/README.md @@ -35,11 +35,56 @@ box file for Vagrant. The default configuration of the RHEL family of Linux distributions requires a tty in order to run sudo. Vagrant does not connect with a tty by default, so you may experience the error: > sudo: sorry, you must have a tty to run sudo -The best way to deal with this error is to upgrade to Vagrant 1.4 or later, and enable: +If you are using Vagrant 1.4 or later you can tell it to use a pty for SSH connections. However, +RSync doesn't work very well with a pty, so you would still have trouble. The best approach is to +use an `init_script` setting to modify the sudoers file and disable the require_tty requirement. + +The following settings show an example of how you can workaround the issue: +```ruby +Vagrant.configure("2") do |config| + config.vm.box = "dummy" + config.ssh.pty = true + + config.vm.provider :rackspace do |rs| + rs.username = "YOUR USERNAME" + rs.api_key = "YOUR API KEY" + rs.flavor = /1 GB Performance/ + rs.image = /^CentOS/ + rs.init_script = 'sed -i\'.bk\' -e \'s/^\(Defaults\s\+requiretty\)/# \1/\' /etc/sudoers' + end +end +``` + +### Windows (enabling WinRM) + +Vagrant 1.6 and later support WinRM as an alternative to SSH for communicating with Windows machines. However, WinRM is not enabled by default on the Rackspace images for Windows. You can use the `init_script +to enable and secure WinRM so Vagrant will be able to connect. This example enables WinRM for both HTTP and HTTPS traffic. + +Security warnings: +- Vagrant's WinRM support is not as secure as SSH. You should only use it for testing purposes where these warnings are acceptible. If you require a more secure setup you'll need to either configure SSH on Windows, or to wait until for future Vagrant releases with better WinRM security. + - The current Vagrant release (v1.6.5) only supports WinRM as plaintext over HTTP, but [SSL support is in progress](https://github.com/mitchellh/vagrant/pull/4236) and should hopefully be included in the next release. + - The default setup, even with SSL support, uses self-signed certificates. If you want to use a real Certificate Authority you'll need to customize your Windows images or `init_script`. + +If you're okay with those warnings, you can create a Windows server using these settings: + ```ruby -config.ssh.pty = true +Vagrant.configure("2") do |config| + config.vm.box = "dummy" + config.ssh.pty = true + + config.vm.provider :rackspace do |rs| + rs.username = "YOUR USERNAME" + rs.api_key = "YOUR API KEY" + rs.flavor = /1 GB Performance/ + rs.image = 'Windows Server 2012' + rs.init_script = File.read 'bootstrap.cmd' + end +end ``` +You can get a sample [bootstrap.cmd](bootstrap.cmd) file from this repo. + + ## Quick Start After installing the plugin (instructions above), the quickest way to get @@ -133,9 +178,9 @@ This provider exposes quite a few provider-specific configuration options: * `image` - The server image to boot. This can be a string matching the exact ID or name of the image, or this can be a regular expression to partially match some image. -* `rackspace_region` - The region to hit. By default this is :dfw. Valid options are: +* `rackspace_region` - The region to hit. By default this is :dfw. Valid options are: :dfw, :ord, :lon, :iad, :syd. Users should preference using this setting over `rackspace_compute_url` setting. -* `rackspace_compute_url` - The compute_url to hit. This is good for custom endpoints. +* `rackspace_compute_url` - The compute_url to hit. This is good for custom endpoints. * `rackspace_auth_url` - The endpoint to authentication against. By default, vagrant will use the global rackspace authentication endpoint for all regions with the exception of :lon. IF :lon region is specified vagrant will authenticate against the UK authentication endpoint. From 0a4315a380785c9dc4a76800a26eeec1cc4b13a9 Mon Sep 17 00:00:00 2001 From: Max Lincoln Date: Sat, 8 Nov 2014 23:14:58 -0500 Subject: [PATCH 13/42] Appraisal setup including windows WIP fork --- .travis.yml | 2 +- Appraisals | 18 +++++++++++++++--- Gemfile | 18 ++++++------------ gemfiles/latest_stable.gemfile | 12 +++++++----- gemfiles/oldest_current.gemfile | 12 +++++++----- gemfiles/previous_release.gemfile | 12 +++++++----- gemfiles/windows_wip.gemfile | 14 ++++++++++++++ 7 files changed, 57 insertions(+), 31 deletions(-) create mode 100644 gemfiles/windows_wip.gemfile diff --git a/.travis.yml b/.travis.yml index 2075783..6f91a6d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,4 +9,4 @@ gemfile: - gemfiles/latest_stable.gemfile - gemfiles/oldest_current.gemfile - gemfiles/previous_release.gemfile - + - gemfiles/windows_wip.gemfile diff --git a/Appraisals b/Appraisals index 9ea31d3..df52dbd 100644 --- a/Appraisals +++ b/Appraisals @@ -1,14 +1,26 @@ appraise "latest-stable" do - gem "vagrant", :git => 'git://github.com/mitchellh/vagrant.git', :branch => 'v1.4.2' + group :development do + gem "vagrant", :git => 'git://github.com/mitchellh/vagrant.git', :branch => 'v1.4.2' + end end # Oldest (current release) appraise "oldest-current" do - gem "vagrant", :git => 'git://github.com/mitchellh/vagrant.git', :branch => 'v1.4.0' + group :development do + gem "vagrant", :git => 'git://github.com/mitchellh/vagrant.git', :branch => 'v1.4.0' + end end # Latest patch (previous release) appraise "previous-release" do - gem "vagrant", :git => 'git://github.com/mitchellh/vagrant.git', :branch => 'v1.3.5' + group :development do + gem "vagrant", :git => 'git://github.com/mitchellh/vagrant.git', :branch => 'v1.3.5' + end +end + +appraise "windows-wip" do + group :development do + gem "vagrant", :git => 'git://github.com/maxlinc/vagrant.git', :branch => 'winrmssl' + end end diff --git a/Gemfile b/Gemfile index c77e9a5..5df0a1f 100644 --- a/Gemfile +++ b/Gemfile @@ -1,19 +1,13 @@ source 'https://rubygems.org' - -group :plugins do - gemspec - gem 'vagrant', :git => 'https://github.com/mitchellh/vagrant' -end - -gem "appraisal", "1.0.0.beta2" - 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 'coveralls', require: false gem 'pry' + gem 'appraisal', '~> 1.0' +end + +group :plugins do + gemspec end - \ No newline at end of file diff --git a/gemfiles/latest_stable.gemfile b/gemfiles/latest_stable.gemfile index 0ea0a09..d1c8050 100644 --- a/gemfiles/latest_stable.gemfile +++ b/gemfiles/latest_stable.gemfile @@ -2,11 +2,13 @@ source "https://rubygems.org" -gem "appraisal", "1.0.0.beta2" -gem "vagrant", :git=>"git://github.com/mitchellh/vagrant.git", :branch=>"v1.4.2" - group :development do - gem "coveralls", :require=>false + gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :branch => "v1.4.2" + gem "coveralls", :require => false + gem "pry" + gem "appraisal", "~> 1.0" end -gemspec :path=>".././" +group :plugins do + gemspec path: ".." +end diff --git a/gemfiles/oldest_current.gemfile b/gemfiles/oldest_current.gemfile index aa6121a..600470f 100644 --- a/gemfiles/oldest_current.gemfile +++ b/gemfiles/oldest_current.gemfile @@ -2,11 +2,13 @@ source "https://rubygems.org" -gem "appraisal", "1.0.0.beta2" -gem "vagrant", :git=>"git://github.com/mitchellh/vagrant.git", :branch=>"v1.4.0" - group :development do - gem "coveralls", :require=>false + gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :branch => "v1.4.0" + gem "coveralls", :require => false + gem "pry" + gem "appraisal", "~> 1.0" end -gemspec :path=>".././" +group :plugins do + gemspec path: ".." +end diff --git a/gemfiles/previous_release.gemfile b/gemfiles/previous_release.gemfile index 1403ac8..d0c025f 100644 --- a/gemfiles/previous_release.gemfile +++ b/gemfiles/previous_release.gemfile @@ -2,11 +2,13 @@ source "https://rubygems.org" -gem "appraisal", "1.0.0.beta2" -gem "vagrant", :git=>"git://github.com/mitchellh/vagrant.git", :branch=>"v1.3.5" - group :development do - gem "coveralls", :require=>false + gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :branch => "v1.3.5" + gem "coveralls", :require => false + gem "pry" + gem "appraisal", "~> 1.0" end -gemspec :path=>".././" +group :plugins do + gemspec path: ".." +end diff --git a/gemfiles/windows_wip.gemfile b/gemfiles/windows_wip.gemfile new file mode 100644 index 0000000..58fdbcd --- /dev/null +++ b/gemfiles/windows_wip.gemfile @@ -0,0 +1,14 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +group :development do + gem "vagrant", :git => "git://github.com/maxlinc/vagrant.git", :branch => "winrmssl" + gem "coveralls", :require => false + gem "pry" + gem "appraisal", "~> 1.0" +end + +group :plugins do + gemspec path: ".." +end From 9805ae6da5bd9234313812b5e1e1bcc83d89385e Mon Sep 17 00:00:00 2001 From: Max Lincoln Date: Tue, 9 Dec 2014 14:43:59 -0500 Subject: [PATCH 14/42] Better winrm messages --- lib/vagrant-rackspace/action/create_server.rb | 34 +++++++++++++------ locales/en.yml | 15 ++++++-- 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/lib/vagrant-rackspace/action/create_server.rb b/lib/vagrant-rackspace/action/create_server.rb index 253a595..d576c5f 100644 --- a/lib/vagrant-rackspace/action/create_server.rb +++ b/lib/vagrant-rackspace/action/create_server.rb @@ -38,14 +38,19 @@ def call(env) # Figure out the name for the server server_name = config.server_name || env[:machine].name - # If we are using a key name, can ignore the public key path - if not config.key_name - # If we're using the default keypair, then show a warning - default_key_path = Vagrant.source_root.join("keys/vagrant.pub").to_s - public_key_path = File.expand_path(config.public_key_path, env[:root_path]) - - if default_key_path == public_key_path - env[:ui].warn(I18n.t("vagrant_rackspace.warn_insecure_ssh")) + if communicator == :winrm + env[:ui].warn(I18n.t("vagrant_rackspace.warn_insecure_winrm")) if !winrm_secure?(machine_config) + env[:ui].warn(I18n.t("vagrant_rackspace.warn_winrm_password")) if config.admin_password != machine_config.winrm.password + else # communicator == :ssh + # If we are using a key name, can ignore the public key path + if not config.key_name + # If we're using the default keypair, then show a warning + default_key_path = Vagrant.source_root.join("keys/vagrant.pub").to_s + public_key_path = File.expand_path(config.public_key_path, env[:root_path]) + + if default_key_path == public_key_path + env[:ui].warn(I18n.t("vagrant_rackspace.warn_insecure_ssh")) + end end end @@ -147,8 +152,10 @@ def call(env) end end - # Wait for SSH to become available - env[:ui].info(I18n.t("vagrant_rackspace.waiting_for_ssh")) + # Wait for a communicator + env[:ui].info(I18n.t("vagrant_rackspace.waiting_for_communicator", + :communicator => communicator, :address => server.public_ip_address)) + while true # If we're interrupted then just back out break if env[:interrupted] @@ -197,6 +204,13 @@ def encode64(content, options = nil) encoded.strip end + # This method checks to see if WinRM over SSL is supported and used + def winrm_secure?(machine_config) + machine_config.winrm.transport == :ssl + rescue NoMethodError + false + end + end end end diff --git a/locales/en.yml b/locales/en.yml index bbf114f..3159040 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -24,14 +24,23 @@ en: Waiting for the server to be built... waiting_for_rackconnect: |- Waiting for RackConnect to complete... - waiting_for_ssh: |- - Waiting for SSH to become available... + waiting_for_communicator: |- + Waiting for %{communicator} to become available at %{address}... warn_insecure_ssh: |- Warning! By not specifying a custom public/private keypair, Vagrant is defaulting to use the insecure keypair that ships with Vagrant. While this isn't much of a big deal for local development, this is quite insecure for remote servers. Please specify a custom public/private keypair. + warn_insecure_winrm: |- + Warning! Vagrant is using plaintext communication for WinRM. While + this isn't much of a big deal for local development, this is quite + insecure for remote servers. Please configure WinRM to use SSL. + warn_winrm_password: |- + Warning! Vagrant has no way to store the Administrator password generated + by Rackspace for later use with WinRM. Please configure Vagrant to use + the same value for the winrm password and the Rackspace admin_password so + Vagrant will be able to connect via WinRM. warn_networks: |- Warning! The Rackspace provider doesn't support any of the Vagrant high-level network configurations (`config.vm.network`). They @@ -40,7 +49,7 @@ en: The server will not be deleted. sync_folders: |- Rackspace support for Vagrant 1.3 has been deprecated. Please - upgrade to the latest version of vagrant for continued support. + upgrade to the latest version of vagrant for continued support. config: api_key_required: |- From 1d4733f1e28f9eac84e97666a9b56dfe771cb5fd Mon Sep 17 00:00:00 2001 From: Max Lincoln Date: Tue, 9 Dec 2014 16:49:34 -0500 Subject: [PATCH 15/42] Don't upload SSH keys unless communicator is ssh --- lib/vagrant-rackspace/action/create_server.rb | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/vagrant-rackspace/action/create_server.rb b/lib/vagrant-rackspace/action/create_server.rb index d576c5f..7a15d24 100644 --- a/lib/vagrant-rackspace/action/create_server.rb +++ b/lib/vagrant-rackspace/action/create_server.rb @@ -82,16 +82,18 @@ def call(env) options[:config_drive] = config.config_drive end - if config.key_name - options[:key_name] = config.key_name - env[:ui].info(" -- Key Name: #{config.key_name}") - else - options[:personality] = [ - { - :path => "/root/.ssh/authorized_keys", - :contents => encode64(File.read(public_key_path)) - } - ] + if communicator == :ssh + if config.key_name + options[:key_name] = config.key_name + env[:ui].info(" -- Key Name: #{config.key_name}") + else + options[:personality] = [ + { + :path => "/root/.ssh/authorized_keys", + :contents => encode64(File.read(public_key_path)) + } + ] + end end if config.init_script && communicator == :winrm From 34833c5deecc86e78d70980adad3133b48d674ab Mon Sep 17 00:00:00 2001 From: Max Lincoln Date: Tue, 9 Dec 2014 18:26:12 -0500 Subject: [PATCH 16/42] Make appraisal work with plugins group --- Appraisals | 8 ++++---- Gemfile | 6 +++--- gemfiles/latest_stable.gemfile | 7 ++++--- gemfiles/oldest_current.gemfile | 7 ++++--- gemfiles/previous_release.gemfile | 7 ++++--- gemfiles/windows_wip.gemfile | 7 ++++--- 6 files changed, 23 insertions(+), 19 deletions(-) diff --git a/Appraisals b/Appraisals index df52dbd..2fe8981 100644 --- a/Appraisals +++ b/Appraisals @@ -1,25 +1,25 @@ appraise "latest-stable" do - group :development do + group :plugins do gem "vagrant", :git => 'git://github.com/mitchellh/vagrant.git', :branch => 'v1.4.2' end end # Oldest (current release) appraise "oldest-current" do - group :development do + group :plugins do gem "vagrant", :git => 'git://github.com/mitchellh/vagrant.git', :branch => 'v1.4.0' end end # Latest patch (previous release) appraise "previous-release" do - group :development do + group :plugins do gem "vagrant", :git => 'git://github.com/mitchellh/vagrant.git', :branch => 'v1.3.5' end end appraise "windows-wip" do - group :development do + group :plugins do gem "vagrant", :git => 'git://github.com/maxlinc/vagrant.git', :branch => 'winrmssl' end end diff --git a/Gemfile b/Gemfile index 5df0a1f..4a551c8 100644 --- a/Gemfile +++ b/Gemfile @@ -1,13 +1,13 @@ source 'https://rubygems.org' group :development do - gem "vagrant", git: "https://github.com/mitchellh/vagrant.git" gem 'coveralls', require: false gem 'pry' - gem 'appraisal', '~> 1.0' + # My branch contains a fix for https://github.com/thoughtbot/appraisal/issues/76 + gem 'appraisal', '~> 1.0', git: 'https://github.com/maxlinc/appraisal', branch: 'gemspec_in_group' end group :plugins do + gem "vagrant", git: "https://github.com/mitchellh/vagrant.git", :branch => 'master' gemspec end - diff --git a/gemfiles/latest_stable.gemfile b/gemfiles/latest_stable.gemfile index d1c8050..8177939 100644 --- a/gemfiles/latest_stable.gemfile +++ b/gemfiles/latest_stable.gemfile @@ -3,12 +3,13 @@ source "https://rubygems.org" group :development do - gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :branch => "v1.4.2" gem "coveralls", :require => false gem "pry" - gem "appraisal", "~> 1.0" + gem "appraisal", "~> 1.0", :git => "https://github.com/maxlinc/appraisal", :branch => "gemspec_in_group" end group :plugins do - gemspec path: ".." + gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :branch => "v1.4.2" + + gemspec :path => "../" end diff --git a/gemfiles/oldest_current.gemfile b/gemfiles/oldest_current.gemfile index 600470f..6bf18b6 100644 --- a/gemfiles/oldest_current.gemfile +++ b/gemfiles/oldest_current.gemfile @@ -3,12 +3,13 @@ source "https://rubygems.org" group :development do - gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :branch => "v1.4.0" gem "coveralls", :require => false gem "pry" - gem "appraisal", "~> 1.0" + gem "appraisal", "~> 1.0", :git => "https://github.com/maxlinc/appraisal", :branch => "gemspec_in_group" end group :plugins do - gemspec path: ".." + gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :branch => "v1.4.0" + + gemspec :path => "../" end diff --git a/gemfiles/previous_release.gemfile b/gemfiles/previous_release.gemfile index d0c025f..b4b04f8 100644 --- a/gemfiles/previous_release.gemfile +++ b/gemfiles/previous_release.gemfile @@ -3,12 +3,13 @@ source "https://rubygems.org" group :development do - gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :branch => "v1.3.5" gem "coveralls", :require => false gem "pry" - gem "appraisal", "~> 1.0" + gem "appraisal", "~> 1.0", :git => "https://github.com/maxlinc/appraisal", :branch => "gemspec_in_group" end group :plugins do - gemspec path: ".." + gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :branch => "v1.3.5" + + gemspec :path => "../" end diff --git a/gemfiles/windows_wip.gemfile b/gemfiles/windows_wip.gemfile index 58fdbcd..73e30ea 100644 --- a/gemfiles/windows_wip.gemfile +++ b/gemfiles/windows_wip.gemfile @@ -3,12 +3,13 @@ source "https://rubygems.org" group :development do - gem "vagrant", :git => "git://github.com/maxlinc/vagrant.git", :branch => "winrmssl" gem "coveralls", :require => false gem "pry" - gem "appraisal", "~> 1.0" + gem "appraisal", "~> 1.0", :git => "https://github.com/maxlinc/appraisal", :branch => "gemspec_in_group" end group :plugins do - gemspec path: ".." + gem "vagrant", :git => "git://github.com/maxlinc/vagrant.git", :branch => "winrmssl" + + gemspec :path => "../" end From 1793481ae43d12349c93020dcd3cb2d2dcab4707 Mon Sep 17 00:00:00 2001 From: Max Lincoln Date: Mon, 15 Dec 2014 13:06:49 -0500 Subject: [PATCH 17/42] Set box_optional and parallel attributes --- lib/vagrant-rackspace/plugin.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vagrant-rackspace/plugin.rb b/lib/vagrant-rackspace/plugin.rb index e40b6b3..6f0c433 100644 --- a/lib/vagrant-rackspace/plugin.rb +++ b/lib/vagrant-rackspace/plugin.rb @@ -23,7 +23,7 @@ class Plugin < Vagrant.plugin("2") Config end - provider(:rackspace) do + provider(:rackspace, { :box_optional => true, parallel: true}) do # Setup some things Rackspace.init_i18n Rackspace.init_logging From 1fbb603161c2379eb4371ca0a2948606c6681ca2 Mon Sep 17 00:00:00 2001 From: Max Lincoln Date: Tue, 16 Dec 2014 11:19:00 -0500 Subject: [PATCH 18/42] Report progress, scoped by machine --- lib/vagrant-rackspace/action/create_server.rb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/vagrant-rackspace/action/create_server.rb b/lib/vagrant-rackspace/action/create_server.rb index 7a15d24..9f6c245 100644 --- a/lib/vagrant-rackspace/action/create_server.rb +++ b/lib/vagrant-rackspace/action/create_server.rb @@ -122,8 +122,7 @@ def call(env) next if env[:interrupted] # Set the progress - env[:ui].clear_line - env[:ui].report_progress(server.progress, 100, false) + report_server_progress(env[:machine], server.progress, 100, false) # Wait for the server to be ready begin @@ -213,6 +212,19 @@ def winrm_secure?(machine_config) false end + # Ported from Vagrant::UI, but scoped to the machine's UI + def report_server_progress(machine, progress, total, show_parts) + machine.ui.clear_line + if total && total > 0 + percent = (progress.to_f / total.to_f) * 100 + line = "Progress: #{percent.to_i}%" + line << " (#{progress} / #{total})" if show_parts + else + line = "Progress: #{progress}" + end + + machine.ui.info(line, new_line: false) + end end end end From 57ec21e89864f876660cbb2821e91d49d9725792 Mon Sep 17 00:00:00 2001 From: Ash Wilson Date: Tue, 16 Dec 2014 14:30:30 -0500 Subject: [PATCH 19/42] v0.1.10 --- lib/vagrant-rackspace/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vagrant-rackspace/version.rb b/lib/vagrant-rackspace/version.rb index 2a02b47..8e4a559 100644 --- a/lib/vagrant-rackspace/version.rb +++ b/lib/vagrant-rackspace/version.rb @@ -1,5 +1,5 @@ module VagrantPlugins module Rackspace - VERSION = "0.1.10dev" + VERSION = "0.1.10" end end From 3144f2e9d66a9bb8560adaa8e777cb8a9f30d768 Mon Sep 17 00:00:00 2001 From: Ash Wilson Date: Tue, 16 Dec 2014 14:32:57 -0500 Subject: [PATCH 20/42] v0.1.11dev --- lib/vagrant-rackspace/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vagrant-rackspace/version.rb b/lib/vagrant-rackspace/version.rb index 8e4a559..38d0b75 100644 --- a/lib/vagrant-rackspace/version.rb +++ b/lib/vagrant-rackspace/version.rb @@ -1,5 +1,5 @@ module VagrantPlugins module Rackspace - VERSION = "0.1.10" + VERSION = "0.1.11dev" end end From 3689cd46f6bd03977bdbab15b09c9ac3209f71ae Mon Sep 17 00:00:00 2001 From: Max Lincoln Date: Tue, 16 Dec 2014 10:45:00 -0500 Subject: [PATCH 21/42] Update gemfiles --- Appraisals | 17 +++++++++++++---- Gemfile | 1 + gemfiles/latest_stable.gemfile | 2 +- gemfiles/oldest_current.gemfile | 2 +- gemfiles/oldest_supported.gemfile | 17 +++++++++++++++++ gemfiles/previous_release.gemfile | 4 +++- gemfiles/windows_wip.gemfile | 2 +- 7 files changed, 37 insertions(+), 8 deletions(-) create mode 100644 gemfiles/oldest_supported.gemfile diff --git a/Appraisals b/Appraisals index 2fe8981..2fc3bee 100644 --- a/Appraisals +++ b/Appraisals @@ -1,26 +1,35 @@ appraise "latest-stable" do group :plugins do - gem "vagrant", :git => 'git://github.com/mitchellh/vagrant.git', :branch => 'v1.4.2' + gem "vagrant", :git => 'https://github.com/mitchellh/vagrant', :branch => 'v1.7.1' end end # Oldest (current release) appraise "oldest-current" do group :plugins do - gem "vagrant", :git => 'git://github.com/mitchellh/vagrant.git', :branch => 'v1.4.0' + gem "vagrant", :git => 'https://github.com/mitchellh/vagrant', :branch => 'v1.7.0' end end # Latest patch (previous release) appraise "previous-release" do + gem 'bundler', '< 1.7.0', '>= 1.5.2' group :plugins do - gem "vagrant", :git => 'git://github.com/mitchellh/vagrant.git', :branch => 'v1.3.5' + gem "vagrant", :git => 'https://github.com/mitchellh/vagrant', :branch => 'v1.6.5' + end +end + +# Latest patch (previous release) +appraise "oldest-supported" do + gem 'bundler', '< 1.7.0', '>= 1.5.2' + group :plugins do + gem "vagrant", :git => 'https://github.com/mitchellh/vagrant', :branch => 'v1.5.0' end end appraise "windows-wip" do group :plugins do - gem "vagrant", :git => 'git://github.com/maxlinc/vagrant.git', :branch => 'winrmssl' + gem "vagrant", :git => 'https://github.com/maxlinc/vagrant', :branch => 'winrmssl' end end diff --git a/Gemfile b/Gemfile index 4a551c8..202de68 100644 --- a/Gemfile +++ b/Gemfile @@ -11,3 +11,4 @@ group :plugins do gem "vagrant", git: "https://github.com/mitchellh/vagrant.git", :branch => 'master' gemspec end + diff --git a/gemfiles/latest_stable.gemfile b/gemfiles/latest_stable.gemfile index 8177939..90ea9a7 100644 --- a/gemfiles/latest_stable.gemfile +++ b/gemfiles/latest_stable.gemfile @@ -9,7 +9,7 @@ group :development do end group :plugins do - gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :branch => "v1.4.2" + gem "vagrant", :git => "https://github.com/mitchellh/vagrant", :branch => "v1.7.1" gemspec :path => "../" end diff --git a/gemfiles/oldest_current.gemfile b/gemfiles/oldest_current.gemfile index 6bf18b6..5b86769 100644 --- a/gemfiles/oldest_current.gemfile +++ b/gemfiles/oldest_current.gemfile @@ -9,7 +9,7 @@ group :development do end group :plugins do - gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :branch => "v1.4.0" + gem "vagrant", :git => "https://github.com/mitchellh/vagrant", :branch => "v1.7.0" gemspec :path => "../" end diff --git a/gemfiles/oldest_supported.gemfile b/gemfiles/oldest_supported.gemfile new file mode 100644 index 0000000..38b0d0f --- /dev/null +++ b/gemfiles/oldest_supported.gemfile @@ -0,0 +1,17 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "bundler", "< 1.7.0", ">= 1.5.2" + +group :development do + gem "coveralls", :require => false + gem "pry" + gem "appraisal", "~> 1.0", :git => "https://github.com/maxlinc/appraisal", :branch => "gemspec_in_group" +end + +group :plugins do + gem "vagrant", :git => "https://github.com/mitchellh/vagrant", :branch => "v1.5.0" + + gemspec :path => "../" +end diff --git a/gemfiles/previous_release.gemfile b/gemfiles/previous_release.gemfile index b4b04f8..333336a 100644 --- a/gemfiles/previous_release.gemfile +++ b/gemfiles/previous_release.gemfile @@ -2,6 +2,8 @@ source "https://rubygems.org" +gem "bundler", "< 1.7.0", ">= 1.5.2" + group :development do gem "coveralls", :require => false gem "pry" @@ -9,7 +11,7 @@ group :development do end group :plugins do - gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :branch => "v1.3.5" + gem "vagrant", :git => "https://github.com/mitchellh/vagrant", :branch => "v1.6.5" gemspec :path => "../" end diff --git a/gemfiles/windows_wip.gemfile b/gemfiles/windows_wip.gemfile index 73e30ea..e4c602d 100644 --- a/gemfiles/windows_wip.gemfile +++ b/gemfiles/windows_wip.gemfile @@ -9,7 +9,7 @@ group :development do end group :plugins do - gem "vagrant", :git => "git://github.com/maxlinc/vagrant.git", :branch => "winrmssl" + gem "vagrant", :git => "https://github.com/maxlinc/vagrant", :branch => "winrmssl" gemspec :path => "../" end From fd1b29b45ffa8280a23fe9e5c16a3a887efb9dd7 Mon Sep 17 00:00:00 2001 From: Max Lincoln Date: Tue, 16 Dec 2014 10:52:18 -0500 Subject: [PATCH 22/42] Update travis config - no more Ruby 1.9.3 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6f91a6d..f7537ec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: ruby rvm: - - 1.9.3 - 2.0.0 - 2.1.0 script: "appraisal rake" @@ -9,4 +8,5 @@ gemfile: - gemfiles/latest_stable.gemfile - gemfiles/oldest_current.gemfile - gemfiles/previous_release.gemfile + - gemfiles/oldest_supported.gemfile - gemfiles/windows_wip.gemfile From 9daf6fae6fe254c4c849db4605f180eede2aa9b0 Mon Sep 17 00:00:00 2001 From: Max Lincoln Date: Tue, 16 Dec 2014 12:35:15 -0500 Subject: [PATCH 23/42] README updates --- README.md | 226 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 151 insertions(+), 75 deletions(-) diff --git a/README.md b/README.md index 2423ac3..4a5cc3c 100644 --- a/README.md +++ b/README.md @@ -1,43 +1,82 @@ # Vagrant Rackspace Cloud Provider -This is a [Vagrant](http://www.vagrantup.com) 1.1+ plugin that adds a +This is a [Vagrant](http://www.vagrantup.com) 1.5+ plugin that adds a [Rackspace Cloud](http://www.rackspace.com/cloud) provider to Vagrant, allowing Vagrant to control and provision machines within Rackspace cloud. -**Note:** This plugin requires Vagrant 1.1+. +**Note:** This plugin requires Vagrant 1.5+. Windows support requires Vagrant 1.6+. ## Features * Boot Rackspace Cloud instances. * SSH into the instances. * Provision the instances with any built-in Vagrant provisioner. -* Minimal synced folder support via `rsync`. +* Sync folders with any built-in Vagrant synchronized folder plugin (e.g. `rsync`) +* Create Rackspace images from a running Vagrant box -## Usage +## Installation -Install using standard Vagrant 1.1+ plugin installation methods. After -installing, `vagrant up` and specify the `rackspace` provider. An example is -shown below. +Install using standard Vagrant plugin installation methods. ``` $ vagrant plugin install vagrant-rackspace -... +``` + +## Usage + +One the plugin is installed, you use it with `vagrant up` by specifing +the `rackspace` provider: +``` $ vagrant up --provider=rackspace -... ``` -Of course prior to doing this, you'll need to obtain an Rackspace-compatible -box file for Vagrant. +You'll need a Vagrantfile in order to test it out. You can generate a sample +Vagrantfile with `vagrant init`. Here's an example with Rackspace configuration: + +```ruby +Vagrant.configure("2") do |config| + # The box is optional in newer versions of Vagrant + # config.vm.box = "dummy" + + config.vm.provider :rackspace do |rs| + rs.username = "YOUR USERNAME" + rs.api_key = "YOUR API KEY" + rs.flavor = /1 GB Performance/ + rs.image = /Ubuntu/ + rs.metadata = {"key" => "value"} # optional + end +end +``` + +You may be required to use a box, depending on your version of Vagrant. If necessary you can +add the "dummy" box with the command: +``` +$ vagrant box add dummy https://github.com/mitchellh/vagrant-rackspace/raw/master/dummy.box +``` + +Then uncomment the line containing `config.vm.box = "dummy"`. + +### RackConnect + +If you are using RackConnect with vagrant, you will need to add the following line to the `config.vm.provider` section to prevent timeouts. + + ``` + rs.rackconnect = true + ``` -### CentOS / RHEL (sudo: sorry, you must have a tty to run sudo) +### CentOS / RHEL / Fedora -The default configuration of the RHEL family of Linux distributions requires a tty in order to run sudo. Vagrant does not connect with a tty by default, so you may experience the error: +The default configuration of the RHEL family of Linux distributions requires a tty in order to run sudo.Vagrant does not connect with a tty by default, so you may experience the error: > sudo: sorry, you must have a tty to run sudo -If you are using Vagrant 1.4 or later you can tell it to use a pty for SSH connections. However, -RSync doesn't work very well with a pty, so you would still have trouble. The best approach is to -use an `init_script` setting to modify the sudoers file and disable the require_tty requirement. +You can tell Vagrant it should use a pseudo-terminal (pty) to get around this issue with the option: +```ruby + config.ssh.pty = true +``` + +However, Vagrant does not always work well with the pty. In particular, rsync may not work. So we recommend +using this configuration for a workaround which will reconfigure the server so a tty is not required to run sudo: The following settings show an example of how you can workaround the issue: ```ruby @@ -57,20 +96,18 @@ end ### Windows (enabling WinRM) -Vagrant 1.6 and later support WinRM as an alternative to SSH for communicating with Windows machines. However, WinRM is not enabled by default on the Rackspace images for Windows. You can use the `init_script -to enable and secure WinRM so Vagrant will be able to connect. This example enables WinRM for both HTTP and HTTPS traffic. +Vagrant 1.6 and later support WinRM as an alternative to SSH for communicating with Windows machines, though secure WinRM connections at this time. They are expected to be added in a 1.7.x release of Vagrant. -Security warnings: +Be aware of the security limitations: - Vagrant's WinRM support is not as secure as SSH. You should only use it for testing purposes where these warnings are acceptible. If you require a more secure setup you'll need to either configure SSH on Windows, or to wait until for future Vagrant releases with better WinRM security. - - The current Vagrant release (v1.6.5) only supports WinRM as plaintext over HTTP, but [SSL support is in progress](https://github.com/mitchellh/vagrant/pull/4236) and should hopefully be included in the next release. - - The default setup, even with SSL support, uses self-signed certificates. If you want to use a real Certificate Authority you'll need to customize your Windows images or `init_script`. + - The current Vagrant release (v1.7.0) only supports WinRM as plaintext over HTTP, but [SSL support is in progress](https://github.com/mitchellh/vagrant/pull/4236) and should hopefully be released in the near future. + - The default setup, even with SSL support, uses self-signed certificates. If you want to use a real Certificate Authority you'll need to customize your Windows images or `init_script -If you're okay with those warnings, you can create a Windows server using these settings: +If you still choose to use Vagrant and WinRM for development and testing, then you'll need a Windows image with WinRM enabled. WinRM is not enabled by default for the Rackspace images, but you can use the `init_script` configuration option to enable and secure it so Vagrant will be able to connect. This example enables WinRM for both HTTP and HTTPS traffic: ```ruby Vagrant.configure("2") do |config| config.vm.box = "dummy" - config.ssh.pty = true config.vm.provider :rackspace do |rs| rs.username = "YOUR USERNAME" @@ -84,57 +121,107 @@ end You can get a sample [bootstrap.cmd](bootstrap.cmd) file from this repo. +### Parallel, multi-machine setup -## Quick Start +You can define multiple machines in a single Vagrant file, for example: -After installing the plugin (instructions above), the quickest way to get -started is to actually use a dummy Rackspace box and specify all the details -manually within a `config.vm.provider` block. So first, add the dummy -box using any name you want: +```ruby +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + # All Vagrant configuration is done here. The most common configuration + # options are documented and commented below. For a complete reference, + # please see the online documentation at vagrantup.com. -``` -$ vagrant box add dummy https://github.com/mitchellh/vagrant-rackspace/raw/master/dummy.box -... -``` + # Every Vagrant virtual environment requires a box to build off of. + config.vm.box = "dummy" -And then make a Vagrantfile that looks like the following, filling in -your information where necessary. + config.vm.define :ubuntu do |ubuntu| + ubuntu.ssh.private_key_path = '~/.ssh/id_rsa' + ubuntu.vm.provider :rackspace do |rs| + rs.username = ENV['RAX_USERNAME'] + rs.admin_password = ENV['VAGRANT_ADMIN_PASSWORD'] + rs.api_key = ENV['RAX_API_KEY'] + rs.flavor = /1 GB Performance/ + rs.image = /Ubuntu/ + rs.rackspace_region = :iad + rs.public_key_path = '~/.ssh/id_rsa.pub' + end + end -```ruby -Vagrant.configure("2") do |config| - config.vm.box = "dummy" + config.vm.define :centos do |centos| + centos.ssh.private_key_path = '~/.ssh/id_rsa' + centos.ssh.pty = true + centos.vm.provider :rackspace do |rs| + rs.username = ENV['RAX_USERNAME'] + rs.admin_password = ENV['VAGRANT_ADMIN_PASSWORD'] + rs.api_key = ENV['RAX_API_KEY'] + rs.flavor = /1 GB Performance/ + rs.image = /^CentOS/ # Don't match OnMetal - CentOS + rs.rackspace_region = :iad + rs.public_key_path = '~/.ssh/id_rsa.pub' + rs.init_script = 'sed -i\'.bk\' -e \'s/^\(Defaults\s\+requiretty\)/# \1/\' /etc/sudoers' + end + end - config.vm.provider :rackspace do |rs| - rs.username = "YOUR USERNAME" - rs.api_key = "YOUR API KEY" - rs.flavor = /1 GB Performance/ - rs.image = /Ubuntu/ - rs.metadata = {"key" => "value"} # optional + config.vm.define :windows do |windows| + windows.vm.provision :shell, :inline => 'Write-Output "WinRM is working!"' + windows.vm.communicator = :winrm + windows.winrm.username = 'Administrator' + windows.winrm.password = ENV['VAGRANT_ADMIN_PASSWORD'] + begin + windows.winrm.transport = :ssl + windows.winrm.ssl_peer_verification = false + rescue + puts "Warning: Vagrant #{Vagrant::VERSION} does not support WinRM over SSL." + end + windows.vm.synced_folder ".", "/vagrant", disabled: true + windows.vm.provider :rackspace do |rs| + rs.username = ENV['RAX_USERNAME'] + rs.api_key = ENV['RAX_API_KEY'] + rs.admin_password = ENV['VAGRANT_ADMIN_PASSWORD'] + rs.flavor = /2 GB Performance/ + rs.image = 'Windows Server 2012' + rs.rackspace_region = ENV['RAX_REGION'] ||= 'dfw' + rs.init_script = File.read 'bootstrap.cmd' + end end end ``` -And then run `vagrant up --provider=rackspace`. +You than can then launch them all with `vagrant up --provider rackspace`, or a specific server +with `vagrant up --provider rackspace `. + +Vagrant will create all machines simultaneously when you have multi-machine setup. If you want to +create them one at a time or have any trouble, you can use the `--no-parallel` option. + +## Custom Commands -This will start an Ubuntu 12.04 instance in the DFW datacenter region within -your account. And assuming your SSH information was filled in properly -within your Vagrantfile, SSH and provisioning will work as well. +The plugin includes several Rackspace-specific vagrant commands. You can get the +list of available commands with `vagrant rackspace -h`. -Note that normally a lot of this boilerplate is encoded within the box -file, but the box file used for the quick start, the "dummy" box, has -no preconfigured defaults. +Note that some commands run per-machine if you have a multi-machine setup. This can look repre ### Flavors / Images - To determine what flavors and images are avliable in your region refer to the [Custom Commands](#custom-commands) section. +You can list all available images with the command: -### RackConnect +``` +$ vagrant rackspace images +``` + +``` +$ vagrant rackspace flavors +``` + +If you have a multi-machine setup than this will show the images/flavors for each machine. This seems +a bit repetitive, but since machines can be configured for different regions or even accounts they may +have a different set of available images or flavors. You can also get the list for a specific machine by specifying it's name as an argument: + +``` +$ vagrant rackspace images +$ vagrant rackspace flavors +``` -If you are using RackConnect with vagrant, you will need to add the following line to the `config.vm.provider` section to prevent timeouts. - ``` - rs.rackconnect = true - ``` ## Custom Commands @@ -156,17 +243,6 @@ $ vagrant rackspace images These commands will connect to Rackspace using the settings associated with the machine, and query the region to get the list of available flavors, images, keypairs, networks and servers. -## Box Format - -Every provider in Vagrant must introduce a custom box format. This -provider introduces `rackspace` boxes. You can view an example box in -the [example_box/ directory](https://github.com/mitchellh/vagrant-rackspace/tree/master/example_box). -That directory also contains instructions on how to build a box. - -The box format is basically just the required `metadata.json` file -along with a `Vagrantfile` that does default settings for the -provider-specific configuration for this provider. - ## Configuration This provider exposes quite a few provider-specific configuration options: @@ -210,7 +286,9 @@ Vagrant.configure("2") do |config| end ``` -## Networks +You can find a more complete list the documentation for the [Config class](http://www.rubydoc.info/gems/vagrant-rackspace/VagrantPlugins/Rackspace/Config). + +### Networks Networking features in the form of `config.vm.network` are not supported with `vagrant-rackspace`, currently. If any of these are @@ -229,15 +307,13 @@ config.vm.provider :rackspace do |rs| end ``` -## Synced Folders +### Synced Folders + +You can use this provider with the Vagrant [synced folders](https://docs.vagrantup.com/v2/synced-folders/basic_usage.html). The default type should be `rsync` for most images, with the possible exception of Windows. -There is minimal support for synced folders. Upon `vagrant up`, -`vagrant reload`, and `vagrant provision`, the Rackspace provider will use -`rsync` (if available) to uni-directionally sync the folder to -the remote machine over SSH. +### Plugins -This is good enough for all built-in Vagrant provisioners (shell, -chef, and puppet) to work! +Vagrant has great support for plugins and many of them should work alongside `vagrant-rackspace`. See the list of [Available Vagrant Plugins](https://github.com/mitchellh/vagrant/wiki/Available-Vagrant-Plugins). ## Development From 646c319aaee893dbdd290df9f5330b8f5ea02db9 Mon Sep 17 00:00:00 2001 From: Max Lincoln Date: Tue, 16 Dec 2014 16:12:55 -0500 Subject: [PATCH 24/42] Only test Windows on Vagrant 1.6+ --- Vagrantfile | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 6e66d3e..5b41e31 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -44,26 +44,28 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| end end - config.vm.define :windows do |windows| - windows.vm.provision :shell, :inline => 'Write-Output "WinRM is working!"' - windows.vm.communicator = :winrm - windows.winrm.username = 'Administrator' - windows.winrm.password = ENV['VAGRANT_ADMIN_PASSWORD'] - begin - windows.winrm.transport = :ssl - windows.winrm.ssl_peer_verification = false - rescue - puts "Warning: Vagrant #{Vagrant::VERSION} does not support WinRM over SSL." - end - windows.vm.synced_folder ".", "/vagrant", disabled: true - windows.vm.provider :rackspace do |rs| - rs.username = ENV['RAX_USERNAME'] - rs.api_key = ENV['RAX_API_KEY'] - rs.admin_password = ENV['VAGRANT_ADMIN_PASSWORD'] - rs.flavor = /2 GB Performance/ - rs.image = 'Windows Server 2012' - rs.rackspace_region = ENV['RAX_REGION'] ||= 'dfw' - rs.init_script = File.read 'bootstrap.cmd' + if Gem::Version.new(Vagrant::VERSION) >= Gem::Version.new('1.6.0') + config.vm.define :windows do |windows| + windows.vm.provision :shell, :inline => 'Write-Output "WinRM is working!"' + windows.vm.communicator = :winrm + windows.winrm.username = 'Administrator' + windows.winrm.password = ENV['VAGRANT_ADMIN_PASSWORD'] + begin + windows.winrm.transport = :ssl + windows.winrm.ssl_peer_verification = false + rescue + puts "Warning: Vagrant #{Vagrant::VERSION} does not support WinRM over SSL." + end + windows.vm.synced_folder ".", "/vagrant", disabled: true + windows.vm.provider :rackspace do |rs| + rs.username = ENV['RAX_USERNAME'] + rs.api_key = ENV['RAX_API_KEY'] + rs.admin_password = ENV['VAGRANT_ADMIN_PASSWORD'] + rs.flavor = /2 GB Performance/ + rs.image = 'Windows Server 2012' + rs.rackspace_region = ENV['RAX_REGION'] ||= 'dfw' + rs.init_script = File.read 'bootstrap.cmd' + end end end end From 15abef8025d3e832bec7eaafed7d253acfd2dece Mon Sep 17 00:00:00 2001 From: Max Lincoln Date: Tue, 16 Dec 2014 16:13:57 -0500 Subject: [PATCH 25/42] Use built-in actions for SyncedFolders and WaitForCommunicator --- lib/vagrant-rackspace/action.rb | 16 +--- lib/vagrant-rackspace/action/create_server.rb | 5 - .../action/run_init_script.rb | 28 ++++++ lib/vagrant-rackspace/action/sync_folders.rb | 96 ------------------- 4 files changed, 33 insertions(+), 112 deletions(-) create mode 100644 lib/vagrant-rackspace/action/run_init_script.rb delete mode 100644 lib/vagrant-rackspace/action/sync_folders.rb diff --git a/lib/vagrant-rackspace/action.rb b/lib/vagrant-rackspace/action.rb index 04f71da..78d887c 100644 --- a/lib/vagrant-rackspace/action.rb +++ b/lib/vagrant-rackspace/action.rb @@ -43,11 +43,7 @@ def self.action_provision end b2.use Provision - if defined?(SyncedFolders) - b2.use SyncedFolders - else - b2.use SyncFolders - end + b2.use SyncedFolders end end end @@ -113,12 +109,10 @@ def self.action_up b2.use ConnectRackspace b2.use Provision - if defined?(SyncedFolders) - b2.use SyncedFolders - else - b2.use SyncFolders - end + b2.use SyncedFolders + b2.use RunInitScript b2.use CreateServer + b2.use WaitForCommunicator end end end @@ -174,7 +168,7 @@ def self.action_list_keypairs autoload :MessageNotCreated, action_root.join("message_not_created") autoload :ReadSSHInfo, action_root.join("read_ssh_info") autoload :ReadState, action_root.join("read_state") - autoload :SyncFolders, action_root.join("sync_folders") + autoload :RunInitScript, action_root.join("run_init_script") autoload :CreateImage, action_root.join("create_image") autoload :ListImages, action_root.join("list_images") autoload :ListFlavors, action_root.join("list_flavors") diff --git a/lib/vagrant-rackspace/action/create_server.rb b/lib/vagrant-rackspace/action/create_server.rb index 9f6c245..5c76362 100644 --- a/lib/vagrant-rackspace/action/create_server.rb +++ b/lib/vagrant-rackspace/action/create_server.rb @@ -153,10 +153,6 @@ def call(env) end end - # Wait for a communicator - env[:ui].info(I18n.t("vagrant_rackspace.waiting_for_communicator", - :communicator => communicator, :address => server.public_ip_address)) - while true # If we're interrupted then just back out break if env[:interrupted] @@ -167,7 +163,6 @@ def call(env) env[:ui].info(I18n.t("vagrant_rackspace.ready")) end - env[:machine].communicate.sudo config.init_script if config.init_script && communicator == :ssh @app.call(env) end diff --git a/lib/vagrant-rackspace/action/run_init_script.rb b/lib/vagrant-rackspace/action/run_init_script.rb new file mode 100644 index 0000000..c4778e9 --- /dev/null +++ b/lib/vagrant-rackspace/action/run_init_script.rb @@ -0,0 +1,28 @@ +require "log4r" + +module VagrantPlugins + module Rackspace + module Action + class RunInitScript + def initialize(app, env) + @app = app + @logger = Log4r::Logger.new("vagrant_rackspace::action::read_state") + end + + def call(env) + config = env[:machine].provider_config + machine_config = env[:machine].config + begin + communicator = machine_config.vm.communicator ||= :ssh + rescue NoMethodError + communicator = :ssh + end + + # Can we handle Windows config here? + @app.call(env) + env[:machine].communicate.sudo config.init_script if config.init_script && communicator == :ssh + end + end + end + end +end diff --git a/lib/vagrant-rackspace/action/sync_folders.rb b/lib/vagrant-rackspace/action/sync_folders.rb deleted file mode 100644 index 2d31068..0000000 --- a/lib/vagrant-rackspace/action/sync_folders.rb +++ /dev/null @@ -1,96 +0,0 @@ -require "log4r" -require 'rbconfig' -require "vagrant/util/subprocess" - -module VagrantPlugins - module Rackspace - module Action - # This middleware uses `rsync` to sync the folders over to the - # remote instance. - class SyncFolders - def initialize(app, env) - @app = app - @logger = Log4r::Logger.new("vagrant_rackspace::action::sync_folders") - @host_os = RbConfig::CONFIG['host_os'] - end - - def call(env) - @app.call(env) - env[:ui].warn(I18n.t("vagrant_rackspace.sync_folders")) - - ssh_info = env[:machine].ssh_info - - config = env[:machine].provider_config - rsync_includes = config.rsync_includes.to_a - - env[:machine].config.vm.synced_folders.each do |id, data| - hostpath = File.expand_path(data[:hostpath], env[:root_path]) - guestpath = data[:guestpath] - - # Make sure there is a trailing slash on the host path to - # avoid creating an additional directory with rsync - hostpath = "#{hostpath}/" if hostpath !~ /\/$/ - - # If on Windows, modify the path to work with cygwin rsync - if @host_os =~ /mswin|mingw|cygwin/ - hostpath = hostpath.sub(/^([A-Za-z]):\//) { "/cygdrive/#{$1.downcase}/" } - end - - env[:ui].info(I18n.t("vagrant_rackspace.rsync_folder", - :hostpath => hostpath, - :guestpath => guestpath)) - - # Create the guest path - env[:machine].communicate.sudo("mkdir -p '#{guestpath}'") - env[:machine].communicate.sudo( - "chown -R #{ssh_info[:username]} '#{guestpath}'") - - # Generate rsync include commands - includes = rsync_includes.each_with_object([]) { |incl, incls| - incls << "--include" - incls << incl - } - - # Rsync over to the guest path using the SSH info. add - # .hg/ to exclude list as that isn't covered in - # --cvs-exclude - command = [ - "rsync", "--verbose", "--archive", "-z", "-L", - "--cvs-exclude", - "--exclude", ".hg/", - *includes, - "-e", "ssh -p #{ssh_info[:port]} -o StrictHostKeyChecking=no #{ssh_key_options(ssh_info)}", - hostpath, - "#{ssh_info[:username]}@#{ssh_info[:host]}:#{guestpath}"] - command.compact! - - # during rsync, ignore files specified in .hgignore and - # .gitignore traditional .gitignore or .hgignore files - ignore_files = [".hgignore", ".gitignore"] - ignore_files.each do |ignore_file| - abs_ignore_file = env[:root_path].to_s + "/" + ignore_file - if File.exist?(abs_ignore_file) - command = command + ["--exclude-from", abs_ignore_file] - end - end - - r = Vagrant::Util::Subprocess.execute(*command) - if r.exit_code != 0 - raise Errors::RsyncError, - :guestpath => guestpath, - :hostpath => hostpath, - :stderr => r.stderr - end - end - end - - private - - def ssh_key_options(ssh_info) - # Ensure that `private_key_path` is an Array (for Vagrant < 1.4) - Array(ssh_info[:private_key_path]).map { |path| "-i '#{path}' " }.join - end - end - end - end -end From b29b84b20b7d68351d38c282907a4e6ed7460f97 Mon Sep 17 00:00:00 2001 From: Max Lincoln Date: Tue, 16 Dec 2014 17:04:58 -0500 Subject: [PATCH 26/42] Fix commands that were lost in a merge... --- lib/vagrant-rackspace/action.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/vagrant-rackspace/action.rb b/lib/vagrant-rackspace/action.rb index 78d887c..dee9d01 100644 --- a/lib/vagrant-rackspace/action.rb +++ b/lib/vagrant-rackspace/action.rb @@ -158,6 +158,20 @@ def self.action_list_keypairs end end + def self.action_list_networks + Vagrant::Action::Builder.new.tap do |b| + b.use ConnectRackspace + b.use ListNetworks + end + end + + def self.action_list_servers + Vagrant::Action::Builder.new.tap do |b| + b.use ConnectRackspace + b.use ListServers + end + end + # The autoload farm action_root = Pathname.new(File.expand_path("../action", __FILE__)) autoload :ConnectRackspace, action_root.join("connect_rackspace") From 17f6f1e2473b91782279b813aea49bd0b78de4b1 Mon Sep 17 00:00:00 2001 From: Max Lincoln Date: Tue, 16 Dec 2014 19:54:04 -0500 Subject: [PATCH 27/42] Fix logger name --- lib/vagrant-rackspace/action/run_init_script.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vagrant-rackspace/action/run_init_script.rb b/lib/vagrant-rackspace/action/run_init_script.rb index c4778e9..eb9c08f 100644 --- a/lib/vagrant-rackspace/action/run_init_script.rb +++ b/lib/vagrant-rackspace/action/run_init_script.rb @@ -6,7 +6,7 @@ module Action class RunInitScript def initialize(app, env) @app = app - @logger = Log4r::Logger.new("vagrant_rackspace::action::read_state") + @logger = Log4r::Logger.new("vagrant_rackspace::action::run_init_script") end def call(env) From 03631f46813321a24af750f1f46f0880fba5ea2f Mon Sep 17 00:00:00 2001 From: Max Lincoln Date: Wed, 17 Dec 2014 15:38:45 -0500 Subject: [PATCH 28/42] Fix README typos --- README.md | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 4a5cc3c..a61e538 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ If you are using RackConnect with vagrant, you will need to add the following li ### CentOS / RHEL / Fedora -The default configuration of the RHEL family of Linux distributions requires a tty in order to run sudo.Vagrant does not connect with a tty by default, so you may experience the error: +The default configuration of the RHEL family of Linux distributions requires a tty in order to run sudo. Vagrant does not connect with a tty by default, so you may experience the error: > sudo: sorry, you must have a tty to run sudo You can tell Vagrant it should use a pseudo-terminal (pty) to get around this issue with the option: @@ -195,11 +195,9 @@ create them one at a time or have any trouble, you can use the `--no-parallel` o ## Custom Commands -The plugin includes several Rackspace-specific vagrant commands. You can get the +The plugin includes several Rackspace-specific vagrant commands. You can get the list of available commands with `vagrant rackspace -h`. -Note that some commands run per-machine if you have a multi-machine setup. This can look repre - ### Flavors / Images You can list all available images with the command: @@ -221,11 +219,9 @@ $ vagrant rackspace images $ vagrant rackspace flavors ``` - - ## Custom Commands -The plugin includes several Rackspace-specific vagrant commands. You can get the +The plugin includes several Rackspace-specific vagrant commands. You can get the list of available commands with `vagrant rackspace -h`. For example to list all available images for a machine you can use: @@ -255,7 +251,7 @@ This provider exposes quite a few provider-specific configuration options: exact ID or name of the image, or this can be a regular expression to partially match some image. * `rackspace_region` - The region to hit. By default this is :dfw. Valid options are: -:dfw, :ord, :lon, :iad, :syd. Users should preference using this setting over `rackspace_compute_url` setting. +:dfw, :ord, :lon, :iad, :syd. Users should preference using this setting over `rackspace_compute_url` setting. * `rackspace_compute_url` - The compute_url to hit. This is good for custom endpoints. * `rackspace_auth_url` - The endpoint to authentication against. By default, vagrant will use the global rackspace authentication endpoint for all regions with the exception of :lon. IF :lon region is specified @@ -263,7 +259,7 @@ vagrant will authenticate against the UK authentication endpoint. * `public_key_path` - The path to a public key to initialize with the remote server. This should be the matching pair for the private key configured with `config.ssh.private_key_path` on Vagrant. -* `key_name` - If a public key has been [uploaded to the account already](http://docs.rackspace.com/servers/api/v2/cs-devguide/content/ServersKeyPairs-d1e2545.html), the uploaded key can be used to initialize the remote server by providing its name. The uploaded public key should be the matching pair for the private key configured +* `key_name` - If a public key has been [uploaded to the account already](http://docs.rackspace.com/servers/api/v2/cs-devguide/content/ServersKeyPairs-d1e2545.html), the uploaded key can be used to initialize the remote server by providing its name. The uploaded public key should be the matching pair for the private key configured with `config.ssh.private_key_path` on Vagrant. * `server_name` - The name of the server within RackSpace Cloud. This defaults to the name of the Vagrant machine (via `config.vm.define`), but From 1af3f6ffed04be59563e496ac859b89cd43c0646 Mon Sep 17 00:00:00 2001 From: Max Lincoln Date: Wed, 17 Dec 2014 20:15:38 -0500 Subject: [PATCH 29/42] Travis matrix: match Vagrant versions to their supported Ruby version --- .travis.yml | 25 +++++++++------- Appraisals | 29 ++++++++++++------- ...upported.gemfile => vagrant_1.5.0.gemfile} | 2 +- ...us_release.gemfile => vagrant_1.5.gemfile} | 2 +- ...st_current.gemfile => vagrant_1.6.gemfile} | 4 ++- ...est_stable.gemfile => vagrant_1.7.gemfile} | 2 +- gemfiles/windows_wip.gemfile | 2 +- 7 files changed, 39 insertions(+), 27 deletions(-) rename gemfiles/{oldest_supported.gemfile => vagrant_1.5.0.gemfile} (95%) rename gemfiles/{previous_release.gemfile => vagrant_1.5.gemfile} (95%) rename gemfiles/{oldest_current.gemfile => vagrant_1.6.gemfile} (86%) rename gemfiles/{latest_stable.gemfile => vagrant_1.7.gemfile} (94%) diff --git a/.travis.yml b/.travis.yml index f7537ec..cdefeb1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,15 @@ language: ruby -rvm: - - 2.0.0 - - 2.1.0 -script: "appraisal rake" -gemfile: - - Gemfile - - gemfiles/latest_stable.gemfile - - gemfiles/oldest_current.gemfile - - gemfiles/previous_release.gemfile - - gemfiles/oldest_supported.gemfile - - gemfiles/windows_wip.gemfile +matrix: + include: + - gemfile: Gemfile + rvm: 2.1.1 # Just to make sure we're ready... + - gemfile: Gemfile + rvm: 2.0.0 + - gemfile: gemfiles/vagrant-1.7.gemfile + rvm: 2.0.0 + - gemfile: gemfiles/vagrant-1.6.gemfile + rvm: 2.0.0 + - gemfile: gemfiles/vagrant-1.5.gemfile + rvm: 2.0.0 + - gemfile: gemfiles/vagrant-1.5.0.gemfile + rvm: 2.0.0 diff --git a/Appraisals b/Appraisals index 2fc3bee..06bc6b1 100644 --- a/Appraisals +++ b/Appraisals @@ -1,35 +1,42 @@ -appraise "latest-stable" do +appraise "vagrant-1.7" do group :plugins do - gem "vagrant", :git => 'https://github.com/mitchellh/vagrant', :branch => 'v1.7.1' + gem "vagrant", :git => 'https://github.com/mitchellh/vagrant', :tag => 'v1.7.1' end end -# Oldest (current release) -appraise "oldest-current" do +appraise "vagrant-1.6" do + gem 'bundler', '< 1.7.0', '>= 1.5.2' group :plugins do - gem "vagrant", :git => 'https://github.com/mitchellh/vagrant', :branch => 'v1.7.0' + gem "vagrant", :git => 'https://github.com/mitchellh/vagrant', :tag => 'v1.6.5' end end # Latest patch (previous release) -appraise "previous-release" do +appraise "vagrant-1.5" do gem 'bundler', '< 1.7.0', '>= 1.5.2' group :plugins do - gem "vagrant", :git => 'https://github.com/mitchellh/vagrant', :branch => 'v1.6.5' + gem "vagrant", :git => 'https://github.com/mitchellh/vagrant', :tag => 'v1.6.5' end end -# Latest patch (previous release) -appraise "oldest-supported" do +appraise "vagrant-1.5" do + gem 'bundler', '< 1.7.0', '>= 1.5.2' + group :plugins do + gem "vagrant", :git => 'https://github.com/mitchellh/vagrant', :tag => 'v1.5.4' + end +end + +# Oldest supported release +appraise "vagrant-1.5.0" do gem 'bundler', '< 1.7.0', '>= 1.5.2' group :plugins do - gem "vagrant", :git => 'https://github.com/mitchellh/vagrant', :branch => 'v1.5.0' + gem "vagrant", :git => 'https://github.com/mitchellh/vagrant', :tag => 'v1.5.4' end end appraise "windows-wip" do group :plugins do - gem "vagrant", :git => 'https://github.com/maxlinc/vagrant', :branch => 'winrmssl' + gem "vagrant", :git => 'https://github.com/maxlinc/vagrant', :branch => 'winrm-1.3' end end diff --git a/gemfiles/oldest_supported.gemfile b/gemfiles/vagrant_1.5.0.gemfile similarity index 95% rename from gemfiles/oldest_supported.gemfile rename to gemfiles/vagrant_1.5.0.gemfile index 38b0d0f..f87aa4a 100644 --- a/gemfiles/oldest_supported.gemfile +++ b/gemfiles/vagrant_1.5.0.gemfile @@ -11,7 +11,7 @@ group :development do end group :plugins do - gem "vagrant", :git => "https://github.com/mitchellh/vagrant", :branch => "v1.5.0" + gem "vagrant", :git => "https://github.com/mitchellh/vagrant", :tag => "v1.5.4" gemspec :path => "../" end diff --git a/gemfiles/previous_release.gemfile b/gemfiles/vagrant_1.5.gemfile similarity index 95% rename from gemfiles/previous_release.gemfile rename to gemfiles/vagrant_1.5.gemfile index 333336a..f87aa4a 100644 --- a/gemfiles/previous_release.gemfile +++ b/gemfiles/vagrant_1.5.gemfile @@ -11,7 +11,7 @@ group :development do end group :plugins do - gem "vagrant", :git => "https://github.com/mitchellh/vagrant", :branch => "v1.6.5" + gem "vagrant", :git => "https://github.com/mitchellh/vagrant", :tag => "v1.5.4" gemspec :path => "../" end diff --git a/gemfiles/oldest_current.gemfile b/gemfiles/vagrant_1.6.gemfile similarity index 86% rename from gemfiles/oldest_current.gemfile rename to gemfiles/vagrant_1.6.gemfile index 5b86769..e4c0da2 100644 --- a/gemfiles/oldest_current.gemfile +++ b/gemfiles/vagrant_1.6.gemfile @@ -2,6 +2,8 @@ source "https://rubygems.org" +gem "bundler", "< 1.7.0", ">= 1.5.2" + group :development do gem "coveralls", :require => false gem "pry" @@ -9,7 +11,7 @@ group :development do end group :plugins do - gem "vagrant", :git => "https://github.com/mitchellh/vagrant", :branch => "v1.7.0" + gem "vagrant", :git => "https://github.com/mitchellh/vagrant", :tag => "v1.6.5" gemspec :path => "../" end diff --git a/gemfiles/latest_stable.gemfile b/gemfiles/vagrant_1.7.gemfile similarity index 94% rename from gemfiles/latest_stable.gemfile rename to gemfiles/vagrant_1.7.gemfile index 90ea9a7..e96f6d2 100644 --- a/gemfiles/latest_stable.gemfile +++ b/gemfiles/vagrant_1.7.gemfile @@ -9,7 +9,7 @@ group :development do end group :plugins do - gem "vagrant", :git => "https://github.com/mitchellh/vagrant", :branch => "v1.7.1" + gem "vagrant", :git => "https://github.com/mitchellh/vagrant", :tag => "v1.7.1" gemspec :path => "../" end diff --git a/gemfiles/windows_wip.gemfile b/gemfiles/windows_wip.gemfile index e4c602d..56e9c92 100644 --- a/gemfiles/windows_wip.gemfile +++ b/gemfiles/windows_wip.gemfile @@ -9,7 +9,7 @@ group :development do end group :plugins do - gem "vagrant", :git => "https://github.com/maxlinc/vagrant", :branch => "winrmssl" + gem "vagrant", :git => "https://github.com/maxlinc/vagrant", :branch => "winrm-1.3" gemspec :path => "../" end From da6ec3cb1485b1e60487ed1ec7cd1355c9ba7e70 Mon Sep 17 00:00:00 2001 From: Max Lincoln Date: Wed, 17 Dec 2014 20:46:41 -0500 Subject: [PATCH 30/42] Don't install pry or appraisal on travis --- .travis.yml | 1 + Gemfile | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index cdefeb1..83ff017 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: ruby +bundler_args: --without development matrix: include: - gemfile: Gemfile diff --git a/Gemfile b/Gemfile index 202de68..b6b3312 100644 --- a/Gemfile +++ b/Gemfile @@ -1,12 +1,16 @@ source 'https://rubygems.org' +# This group will not be installed on Travis group :development do - gem 'coveralls', require: false gem 'pry' # My branch contains a fix for https://github.com/thoughtbot/appraisal/issues/76 gem 'appraisal', '~> 1.0', git: 'https://github.com/maxlinc/appraisal', branch: 'gemspec_in_group' end +group :test do + gem 'coveralls', require: false +end + group :plugins do gem "vagrant", git: "https://github.com/mitchellh/vagrant.git", :branch => 'master' gemspec From a1dbf5dc652d6e3e5bbee9c9a309298f9292e2c7 Mon Sep 17 00:00:00 2001 From: Max Lincoln Date: Wed, 17 Dec 2014 21:01:51 -0500 Subject: [PATCH 31/42] Fix gemfiles --- .travis.yml | 8 ++++---- gemfiles/vagrant_1.5.0.gemfile | 5 ++++- gemfiles/vagrant_1.5.gemfile | 5 ++++- gemfiles/vagrant_1.6.gemfile | 5 ++++- gemfiles/vagrant_1.7.gemfile | 5 ++++- gemfiles/windows_wip.gemfile | 5 ++++- 6 files changed, 24 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 83ff017..7dbce5a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,11 +6,11 @@ matrix: rvm: 2.1.1 # Just to make sure we're ready... - gemfile: Gemfile rvm: 2.0.0 - - gemfile: gemfiles/vagrant-1.7.gemfile + - gemfile: gemfiles/vagrant_1.7.gemfile rvm: 2.0.0 - - gemfile: gemfiles/vagrant-1.6.gemfile + - gemfile: gemfiles/vagrant_1.6.gemfile rvm: 2.0.0 - - gemfile: gemfiles/vagrant-1.5.gemfile + - gemfile: gemfiles/vagrant_1.5.gemfile rvm: 2.0.0 - - gemfile: gemfiles/vagrant-1.5.0.gemfile + - gemfile: gemfiles/vagrant_1.5.0.gemfile rvm: 2.0.0 diff --git a/gemfiles/vagrant_1.5.0.gemfile b/gemfiles/vagrant_1.5.0.gemfile index f87aa4a..942b22a 100644 --- a/gemfiles/vagrant_1.5.0.gemfile +++ b/gemfiles/vagrant_1.5.0.gemfile @@ -5,11 +5,14 @@ source "https://rubygems.org" gem "bundler", "< 1.7.0", ">= 1.5.2" group :development do - gem "coveralls", :require => false gem "pry" gem "appraisal", "~> 1.0", :git => "https://github.com/maxlinc/appraisal", :branch => "gemspec_in_group" end +group :test do + gem "coveralls", :require => false +end + group :plugins do gem "vagrant", :git => "https://github.com/mitchellh/vagrant", :tag => "v1.5.4" diff --git a/gemfiles/vagrant_1.5.gemfile b/gemfiles/vagrant_1.5.gemfile index f87aa4a..942b22a 100644 --- a/gemfiles/vagrant_1.5.gemfile +++ b/gemfiles/vagrant_1.5.gemfile @@ -5,11 +5,14 @@ source "https://rubygems.org" gem "bundler", "< 1.7.0", ">= 1.5.2" group :development do - gem "coveralls", :require => false gem "pry" gem "appraisal", "~> 1.0", :git => "https://github.com/maxlinc/appraisal", :branch => "gemspec_in_group" end +group :test do + gem "coveralls", :require => false +end + group :plugins do gem "vagrant", :git => "https://github.com/mitchellh/vagrant", :tag => "v1.5.4" diff --git a/gemfiles/vagrant_1.6.gemfile b/gemfiles/vagrant_1.6.gemfile index e4c0da2..27f50b6 100644 --- a/gemfiles/vagrant_1.6.gemfile +++ b/gemfiles/vagrant_1.6.gemfile @@ -5,11 +5,14 @@ source "https://rubygems.org" gem "bundler", "< 1.7.0", ">= 1.5.2" group :development do - gem "coveralls", :require => false gem "pry" gem "appraisal", "~> 1.0", :git => "https://github.com/maxlinc/appraisal", :branch => "gemspec_in_group" end +group :test do + gem "coveralls", :require => false +end + group :plugins do gem "vagrant", :git => "https://github.com/mitchellh/vagrant", :tag => "v1.6.5" diff --git a/gemfiles/vagrant_1.7.gemfile b/gemfiles/vagrant_1.7.gemfile index e96f6d2..d4bc470 100644 --- a/gemfiles/vagrant_1.7.gemfile +++ b/gemfiles/vagrant_1.7.gemfile @@ -3,11 +3,14 @@ source "https://rubygems.org" group :development do - gem "coveralls", :require => false gem "pry" gem "appraisal", "~> 1.0", :git => "https://github.com/maxlinc/appraisal", :branch => "gemspec_in_group" end +group :test do + gem "coveralls", :require => false +end + group :plugins do gem "vagrant", :git => "https://github.com/mitchellh/vagrant", :tag => "v1.7.1" diff --git a/gemfiles/windows_wip.gemfile b/gemfiles/windows_wip.gemfile index 56e9c92..be24b6b 100644 --- a/gemfiles/windows_wip.gemfile +++ b/gemfiles/windows_wip.gemfile @@ -3,11 +3,14 @@ source "https://rubygems.org" group :development do - gem "coveralls", :require => false gem "pry" gem "appraisal", "~> 1.0", :git => "https://github.com/maxlinc/appraisal", :branch => "gemspec_in_group" end +group :test do + gem "coveralls", :require => false +end + group :plugins do gem "vagrant", :git => "https://github.com/maxlinc/vagrant", :branch => "winrm-1.3" From 05263b06550f4104d48ff34e8ddfbbde6ef9a2f7 Mon Sep 17 00:00:00 2001 From: Max Lincoln Date: Wed, 17 Dec 2014 21:30:04 -0500 Subject: [PATCH 32/42] Use specific bundler versions --- .travis.yml | 14 ++++++++++++++ Appraisals | 18 ++++++------------ gemfiles/vagrant_1.5.0.gemfile | 2 +- gemfiles/vagrant_1.5.gemfile | 2 +- gemfiles/vagrant_1.6.gemfile | 2 +- gemfiles/vagrant_1.7.gemfile | 1 + 6 files changed, 24 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7dbce5a..151bb47 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,30 @@ language: ruby +before_install: gem install bundler -v $BUNDLER_VERSION bundler_args: --without development matrix: include: - gemfile: Gemfile rvm: 2.1.1 # Just to make sure we're ready... + env: + BUNDLER_VERSION='>= 1.5.2, < 1.8.0' - gemfile: Gemfile rvm: 2.0.0 + env: + BUNDLER_VERSION='>= 1.5.2, < 1.8.0' - gemfile: gemfiles/vagrant_1.7.gemfile rvm: 2.0.0 + env: + BUNDLER_VERSION='>= 1.5.2, < 1.8.0' - gemfile: gemfiles/vagrant_1.6.gemfile rvm: 2.0.0 + env: + BUNDLER_VERSION='>= 1.5.2, < 1.7.0' - gemfile: gemfiles/vagrant_1.5.gemfile rvm: 2.0.0 + env: + BUNDLER_VERSION='= 1.5.2' + # The oldest Vagrant/Ruby/Bundler we support - gemfile: gemfiles/vagrant_1.5.0.gemfile rvm: 2.0.0 + env: + BUNDLER_VERSION='= 1.5.2' diff --git a/Appraisals b/Appraisals index 06bc6b1..188d771 100644 --- a/Appraisals +++ b/Appraisals @@ -1,34 +1,28 @@ +# Note: You may need to use bundler 1.5.2 to run `appraisal install` appraise "vagrant-1.7" do group :plugins do + gem 'bundler', '>= 1.5.2', '< 1.8.0' gem "vagrant", :git => 'https://github.com/mitchellh/vagrant', :tag => 'v1.7.1' end end appraise "vagrant-1.6" do - gem 'bundler', '< 1.7.0', '>= 1.5.2' + gem 'bundler', '>= 1.5.2', '< 1.7.0' group :plugins do gem "vagrant", :git => 'https://github.com/mitchellh/vagrant', :tag => 'v1.6.5' end end -# Latest patch (previous release) appraise "vagrant-1.5" do - gem 'bundler', '< 1.7.0', '>= 1.5.2' - group :plugins do - gem "vagrant", :git => 'https://github.com/mitchellh/vagrant', :tag => 'v1.6.5' - end -end - -appraise "vagrant-1.5" do - gem 'bundler', '< 1.7.0', '>= 1.5.2' + gem 'bundler', '= 1.5.2' group :plugins do gem "vagrant", :git => 'https://github.com/mitchellh/vagrant', :tag => 'v1.5.4' end end -# Oldest supported release +# Oldest supported appraise "vagrant-1.5.0" do - gem 'bundler', '< 1.7.0', '>= 1.5.2' + gem 'bundler', '= 1.5.2' group :plugins do gem "vagrant", :git => 'https://github.com/mitchellh/vagrant', :tag => 'v1.5.4' end diff --git a/gemfiles/vagrant_1.5.0.gemfile b/gemfiles/vagrant_1.5.0.gemfile index 942b22a..485ca82 100644 --- a/gemfiles/vagrant_1.5.0.gemfile +++ b/gemfiles/vagrant_1.5.0.gemfile @@ -2,7 +2,7 @@ source "https://rubygems.org" -gem "bundler", "< 1.7.0", ">= 1.5.2" +gem "bundler", "= 1.5.2" group :development do gem "pry" diff --git a/gemfiles/vagrant_1.5.gemfile b/gemfiles/vagrant_1.5.gemfile index 942b22a..485ca82 100644 --- a/gemfiles/vagrant_1.5.gemfile +++ b/gemfiles/vagrant_1.5.gemfile @@ -2,7 +2,7 @@ source "https://rubygems.org" -gem "bundler", "< 1.7.0", ">= 1.5.2" +gem "bundler", "= 1.5.2" group :development do gem "pry" diff --git a/gemfiles/vagrant_1.6.gemfile b/gemfiles/vagrant_1.6.gemfile index 27f50b6..3190222 100644 --- a/gemfiles/vagrant_1.6.gemfile +++ b/gemfiles/vagrant_1.6.gemfile @@ -2,7 +2,7 @@ source "https://rubygems.org" -gem "bundler", "< 1.7.0", ">= 1.5.2" +gem "bundler", ">= 1.5.2", "< 1.7.0" group :development do gem "pry" diff --git a/gemfiles/vagrant_1.7.gemfile b/gemfiles/vagrant_1.7.gemfile index d4bc470..e86471e 100644 --- a/gemfiles/vagrant_1.7.gemfile +++ b/gemfiles/vagrant_1.7.gemfile @@ -13,6 +13,7 @@ end group :plugins do gem "vagrant", :git => "https://github.com/mitchellh/vagrant", :tag => "v1.7.1" + gem "bundler", ">= 1.5.2", "< 1.8.0" gemspec :path => "../" end From ad26249ad7674a51011446588580842dacf82ab6 Mon Sep 17 00:00:00 2001 From: Max Lincoln Date: Wed, 17 Dec 2014 21:34:02 -0500 Subject: [PATCH 33/42] Quite gem install argument --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 151bb47..0d435fb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: ruby -before_install: gem install bundler -v $BUNDLER_VERSION +before_install: gem install bundler -v "$BUNDLER_VERSION" bundler_args: --without development matrix: include: From 7b2275fdb1e152e8807a30056ab2c7e8551996e4 Mon Sep 17 00:00:00 2001 From: Max Lincoln Date: Wed, 17 Dec 2014 21:39:50 -0500 Subject: [PATCH 34/42] Remove existing bundler gems --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0d435fb..70e8fe7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,7 @@ language: ruby -before_install: gem install bundler -v "$BUNDLER_VERSION" +before_install: + - gem uninstall bundler --all --force + - gem install bundler -v "$BUNDLER_VERSION" bundler_args: --without development matrix: include: From 658859a99c22a70a15e75d7e1df322e882922fa1 Mon Sep 17 00:00:00 2001 From: Max Lincoln Date: Wed, 17 Dec 2014 21:43:22 -0500 Subject: [PATCH 35/42] Try removing it from rvm global gemset as well... --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 70e8fe7..be3ea91 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: ruby before_install: + - rvm @global do gem uninstall bundler --all --force - gem uninstall bundler --all --force - gem install bundler -v "$BUNDLER_VERSION" bundler_args: --without development From c03298f59ba96f383bdd6c9652eb8215b15b510f Mon Sep 17 00:00:00 2001 From: Max Lincoln Date: Wed, 17 Dec 2014 21:46:07 -0500 Subject: [PATCH 36/42] OK removing executables --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index be3ea91..7da452f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: ruby before_install: - - rvm @global do gem uninstall bundler --all --force - - gem uninstall bundler --all --force + - rvm @global do gem uninstall bundler --all --force --executables + - gem uninstall bundler --all --force --executables - gem install bundler -v "$BUNDLER_VERSION" bundler_args: --without development matrix: From c8529c8805c22127632e65731ddadc59b329a89b Mon Sep 17 00:00:00 2001 From: Zachary Danger Date: Thu, 5 Mar 2015 09:45:50 -0600 Subject: [PATCH 37/42] Add `rackspace_region` configuration to sample config This key is required to do just about anything with the Rackspace API. :D --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a61e538..17cc169 100644 --- a/README.md +++ b/README.md @@ -40,11 +40,12 @@ Vagrant.configure("2") do |config| # config.vm.box = "dummy" config.vm.provider :rackspace do |rs| - rs.username = "YOUR USERNAME" - rs.api_key = "YOUR API KEY" - rs.flavor = /1 GB Performance/ - rs.image = /Ubuntu/ - rs.metadata = {"key" => "value"} # optional + rs.username = "YOUR USERNAME" + rs.api_key = "YOUR API KEY" + rs.rackspace_region = :ord + rs.flavor = /1 GB Performance/ + rs.image = /Ubuntu/ + rs.metadata = {"key" => "value"} # optional end end ``` From b8aed7ec4fe69756dada303244b6661f984372a5 Mon Sep 17 00:00:00 2001 From: "Hector Lecuanda (Macbook)" Date: Thu, 12 Mar 2015 14:17:35 -0700 Subject: [PATCH 38/42] Example showing best practice of keeping API KEY private Some of us are less proficient in ruby, and it took me a while to figure out how to read my environment variable from the vagrant file. I'm a bit wiser for this, and hopefuly it will save someone a bit of time. Hopefuly, also, it will prevent a couple of publicly spilled api keys... Changes to be committed: modified: README.md --- README.md | 50 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 17cc169..14d4425 100644 --- a/README.md +++ b/README.md @@ -40,8 +40,8 @@ Vagrant.configure("2") do |config| # config.vm.box = "dummy" config.vm.provider :rackspace do |rs| - rs.username = "YOUR USERNAME" - rs.api_key = "YOUR API KEY" + rs.username = ENV[RAX_USR] + rs.api_key = ENV[RAX_KEY] rs.rackspace_region = :ord rs.flavor = /1 GB Performance/ rs.image = /Ubuntu/ @@ -50,6 +50,44 @@ Vagrant.configure("2") do |config| end ``` +Optionally, set up environment variables on your shell, for frequently used parameters, +especially your username and api key, if you plan to share your vagrant files. this +will prevent accidentally divulging your keys. + +```tcsh + .tcshrc: + setenv RAX_USR "your-rackspace-user-name" + setenv RAX_REG ":region" + setenv API_KEY "your-rackspace-api-key" +``` + + +```bash + .bashrc or .zshrc + export RAX_USR="your-rackspace-user-name" + export RAX_REG=":region" + export API_KEY="your-rackspace-api-key" +``` + +Then, your vagrant file should look like this: + + +```ruby +Vagrant.configure("2") do |config| + # The box is optional in newer versions of Vagrant + # config.vm.box = "dummy" + + config.vm.provider :rackspace do |rs| + rs.username = ENV[RAX_USR] + rs.api_key = ENV[RAX_KEY] + rs.rackspace_region = ENV[RAX_REG] + rs.flavor = /1 GB Performance/ + rs.image = /Ubuntu/ + rs.metadata = {"key" => "value"} # optional + end +end +``` + You may be required to use a box, depending on your version of Vagrant. If necessary you can add the "dummy" box with the command: ``` @@ -86,8 +124,8 @@ Vagrant.configure("2") do |config| config.ssh.pty = true config.vm.provider :rackspace do |rs| - rs.username = "YOUR USERNAME" - rs.api_key = "YOUR API KEY" + rs.username = ENV[RAX_USR] + rs.api_key = ENV[RAX_KEY] rs.flavor = /1 GB Performance/ rs.image = /^CentOS/ rs.init_script = 'sed -i\'.bk\' -e \'s/^\(Defaults\s\+requiretty\)/# \1/\' /etc/sudoers' @@ -111,8 +149,8 @@ Vagrant.configure("2") do |config| config.vm.box = "dummy" config.vm.provider :rackspace do |rs| - rs.username = "YOUR USERNAME" - rs.api_key = "YOUR API KEY" + rs.username = ENV[RAX_USR] + rs.api_key = ENV[RAX_KEY] rs.flavor = /1 GB Performance/ rs.image = 'Windows Server 2012' rs.init_script = File.read 'bootstrap.cmd' From 6b4b84db41fc5e55b7ad04e8ebac9503bd489b33 Mon Sep 17 00:00:00 2001 From: "Hector Lecuanda (Macbook)" Date: Thu, 12 Mar 2015 14:42:31 -0700 Subject: [PATCH 39/42] Clarified environment setup for multi-machine vagrant file Also, added missing quotes on previous environment example. gotta get in this ruby thing.. =) Changes to be committed: modified: README.md --- README.md | 56 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 14d4425..b4a7eab 100644 --- a/README.md +++ b/README.md @@ -40,8 +40,8 @@ Vagrant.configure("2") do |config| # config.vm.box = "dummy" config.vm.provider :rackspace do |rs| - rs.username = ENV[RAX_USR] - rs.api_key = ENV[RAX_KEY] + rs.username = ENV['RAX_USR'] + rs.api_key = ENV['RAX_KEY'] rs.rackspace_region = :ord rs.flavor = /1 GB Performance/ rs.image = /Ubuntu/ @@ -61,7 +61,6 @@ will prevent accidentally divulging your keys. setenv API_KEY "your-rackspace-api-key" ``` - ```bash .bashrc or .zshrc export RAX_USR="your-rackspace-user-name" @@ -71,16 +70,15 @@ will prevent accidentally divulging your keys. Then, your vagrant file should look like this: - ```ruby Vagrant.configure("2") do |config| # The box is optional in newer versions of Vagrant # config.vm.box = "dummy" config.vm.provider :rackspace do |rs| - rs.username = ENV[RAX_USR] - rs.api_key = ENV[RAX_KEY] - rs.rackspace_region = ENV[RAX_REG] + rs.username = ENV['RAX_USR'] + rs.api_key = ENV['RAX_KEY'] + rs.rackspace_region = ENV['RAX_REG'] rs.flavor = /1 GB Performance/ rs.image = /Ubuntu/ rs.metadata = {"key" => "value"} # optional @@ -124,8 +122,8 @@ Vagrant.configure("2") do |config| config.ssh.pty = true config.vm.provider :rackspace do |rs| - rs.username = ENV[RAX_USR] - rs.api_key = ENV[RAX_KEY] + rs.username = ENV['RAX_USR'] + rs.api_key = ENV['RAX_KEY'] rs.flavor = /1 GB Performance/ rs.image = /^CentOS/ rs.init_script = 'sed -i\'.bk\' -e \'s/^\(Defaults\s\+requiretty\)/# \1/\' /etc/sudoers' @@ -149,8 +147,8 @@ Vagrant.configure("2") do |config| config.vm.box = "dummy" config.vm.provider :rackspace do |rs| - rs.username = ENV[RAX_USR] - rs.api_key = ENV[RAX_KEY] + rs.username = ENV['RAX_USR'] + rs.api_key = ENV['RAX_KEY'] rs.flavor = /1 GB Performance/ rs.image = 'Windows Server 2012' rs.init_script = File.read 'bootstrap.cmd' @@ -162,8 +160,28 @@ You can get a sample [bootstrap.cmd](bootstrap.cmd) file from this repo. ### Parallel, multi-machine setup -You can define multiple machines in a single Vagrant file, for example: +You can define multiple machines in a single Vagrant file, sourcing +common parameters from your shell environment, for example: + +*Environment* +```tcsh + .tcshrc: + setenv RAX_USR "your-rackspace-user-name" + setenv RAX_REG ":region" + setenv API_KEY "your-rackspace-api-key" + setenv VAGRANT_ADMIN_PASSWORD "your-vagrant-admin-password" +``` + +```bash + .bashrc or .zshrc + export RAX_USR="your-rackspace-user-name" + export RAX_REG=":region" + export API_KEY="your-rackspace-api-key" + export VAGRANT_ADMIN_PASSWORD="your-vagrant-admin-password" +``` + +*Vagrantfile:* ```ruby Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # All Vagrant configuration is done here. The most common configuration @@ -176,9 +194,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.define :ubuntu do |ubuntu| ubuntu.ssh.private_key_path = '~/.ssh/id_rsa' ubuntu.vm.provider :rackspace do |rs| - rs.username = ENV['RAX_USERNAME'] + rs.username = ENV['RAX_USR'] rs.admin_password = ENV['VAGRANT_ADMIN_PASSWORD'] - rs.api_key = ENV['RAX_API_KEY'] + rs.api_key = ENV['RAX_KEY'] rs.flavor = /1 GB Performance/ rs.image = /Ubuntu/ rs.rackspace_region = :iad @@ -190,9 +208,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| centos.ssh.private_key_path = '~/.ssh/id_rsa' centos.ssh.pty = true centos.vm.provider :rackspace do |rs| - rs.username = ENV['RAX_USERNAME'] + rs.username = ENV['RAX_USR'] rs.admin_password = ENV['VAGRANT_ADMIN_PASSWORD'] - rs.api_key = ENV['RAX_API_KEY'] + rs.api_key = ENV['RAX_KEY'] rs.flavor = /1 GB Performance/ rs.image = /^CentOS/ # Don't match OnMetal - CentOS rs.rackspace_region = :iad @@ -214,12 +232,12 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| end windows.vm.synced_folder ".", "/vagrant", disabled: true windows.vm.provider :rackspace do |rs| - rs.username = ENV['RAX_USERNAME'] - rs.api_key = ENV['RAX_API_KEY'] + rs.username = ENV['RAX_USR'] + rs.api_key = ENV['RAX_KEY'] rs.admin_password = ENV['VAGRANT_ADMIN_PASSWORD'] rs.flavor = /2 GB Performance/ rs.image = 'Windows Server 2012' - rs.rackspace_region = ENV['RAX_REGION'] ||= 'dfw' + rs.rackspace_region = ENV['RAX_REG'] ||= 'dfw' rs.init_script = File.read 'bootstrap.cmd' end end From 9f6e376893d3eac43ad4a8d45858ae29c4623029 Mon Sep 17 00:00:00 2001 From: "Hector Lecuanda (Macbook)" Date: Thu, 12 Mar 2015 14:51:40 -0700 Subject: [PATCH 40/42] Clarified flow. Keeping the API key private shoud not be optional --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b4a7eab..98d447d 100644 --- a/README.md +++ b/README.md @@ -40,8 +40,8 @@ Vagrant.configure("2") do |config| # config.vm.box = "dummy" config.vm.provider :rackspace do |rs| - rs.username = ENV['RAX_USR'] - rs.api_key = ENV['RAX_KEY'] + rs.username = "your-rackspace-user-name" + rs.api_key = "your-rackspace-api-key" rs.rackspace_region = :ord rs.flavor = /1 GB Performance/ rs.image = /Ubuntu/ @@ -50,7 +50,7 @@ Vagrant.configure("2") do |config| end ``` -Optionally, set up environment variables on your shell, for frequently used parameters, +Set up environment variables on your shell, for frequently used parameters, especially your username and api key, if you plan to share your vagrant files. this will prevent accidentally divulging your keys. @@ -68,7 +68,7 @@ will prevent accidentally divulging your keys. export API_KEY="your-rackspace-api-key" ``` -Then, your vagrant file should look like this: +Change your vagrant file to source your environment. It should look like this: ```ruby Vagrant.configure("2") do |config| From af92a094bbd5c121175102b094f533ad5329fe42 Mon Sep 17 00:00:00 2001 From: "Hector Lecuanda (Macbook)" Date: Thu, 12 Mar 2015 15:12:01 -0700 Subject: [PATCH 41/42] Changed env variable names to be consistent with provided Vagrantfile --- README.md | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 98d447d..cd35d4c 100644 --- a/README.md +++ b/README.md @@ -56,14 +56,14 @@ will prevent accidentally divulging your keys. ```tcsh .tcshrc: - setenv RAX_USR "your-rackspace-user-name" + setenv RAX_USERNAME "your-rackspace-user-name" setenv RAX_REG ":region" setenv API_KEY "your-rackspace-api-key" ``` ```bash .bashrc or .zshrc - export RAX_USR="your-rackspace-user-name" + export RAX_USERNAME="your-rackspace-user-name" export RAX_REG=":region" export API_KEY="your-rackspace-api-key" ``` @@ -76,8 +76,8 @@ Vagrant.configure("2") do |config| # config.vm.box = "dummy" config.vm.provider :rackspace do |rs| - rs.username = ENV['RAX_USR'] - rs.api_key = ENV['RAX_KEY'] + rs.username = ENV['RAX_USERNAME'] + rs.api_key = ENV['RAX_API_KEY'] rs.rackspace_region = ENV['RAX_REG'] rs.flavor = /1 GB Performance/ rs.image = /Ubuntu/ @@ -122,8 +122,8 @@ Vagrant.configure("2") do |config| config.ssh.pty = true config.vm.provider :rackspace do |rs| - rs.username = ENV['RAX_USR'] - rs.api_key = ENV['RAX_KEY'] + rs.username = ENV['RAX_USERNAME'] + rs.api_key = ENV['RAX_API_KEY'] rs.flavor = /1 GB Performance/ rs.image = /^CentOS/ rs.init_script = 'sed -i\'.bk\' -e \'s/^\(Defaults\s\+requiretty\)/# \1/\' /etc/sudoers' @@ -147,8 +147,8 @@ Vagrant.configure("2") do |config| config.vm.box = "dummy" config.vm.provider :rackspace do |rs| - rs.username = ENV['RAX_USR'] - rs.api_key = ENV['RAX_KEY'] + rs.username = ENV['RAX_USERNAME'] + rs.api_key = ENV['RAX_API_KEY'] rs.flavor = /1 GB Performance/ rs.image = 'Windows Server 2012' rs.init_script = File.read 'bootstrap.cmd' @@ -166,7 +166,7 @@ common parameters from your shell environment, for example: *Environment* ```tcsh .tcshrc: - setenv RAX_USR "your-rackspace-user-name" + setenv RAX_USERNAME "your-rackspace-user-name" setenv RAX_REG ":region" setenv API_KEY "your-rackspace-api-key" setenv VAGRANT_ADMIN_PASSWORD "your-vagrant-admin-password" @@ -174,7 +174,7 @@ common parameters from your shell environment, for example: ```bash .bashrc or .zshrc - export RAX_USR="your-rackspace-user-name" + export RAX_USERNAME="your-rackspace-user-name" export RAX_REG=":region" export API_KEY="your-rackspace-api-key" export VAGRANT_ADMIN_PASSWORD="your-vagrant-admin-password" @@ -194,9 +194,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.define :ubuntu do |ubuntu| ubuntu.ssh.private_key_path = '~/.ssh/id_rsa' ubuntu.vm.provider :rackspace do |rs| - rs.username = ENV['RAX_USR'] + rs.username = ENV['RAX_USERNAME'] rs.admin_password = ENV['VAGRANT_ADMIN_PASSWORD'] - rs.api_key = ENV['RAX_KEY'] + rs.api_key = ENV['RAX_API_KEY'] rs.flavor = /1 GB Performance/ rs.image = /Ubuntu/ rs.rackspace_region = :iad @@ -208,9 +208,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| centos.ssh.private_key_path = '~/.ssh/id_rsa' centos.ssh.pty = true centos.vm.provider :rackspace do |rs| - rs.username = ENV['RAX_USR'] + rs.username = ENV['RAX_USERNAME'] rs.admin_password = ENV['VAGRANT_ADMIN_PASSWORD'] - rs.api_key = ENV['RAX_KEY'] + rs.api_key = ENV['RAX_API_KEY'] rs.flavor = /1 GB Performance/ rs.image = /^CentOS/ # Don't match OnMetal - CentOS rs.rackspace_region = :iad @@ -232,8 +232,8 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| end windows.vm.synced_folder ".", "/vagrant", disabled: true windows.vm.provider :rackspace do |rs| - rs.username = ENV['RAX_USR'] - rs.api_key = ENV['RAX_KEY'] + rs.username = ENV['RAX_USERNAME'] + rs.api_key = ENV['RAX_API_KEY'] rs.admin_password = ENV['VAGRANT_ADMIN_PASSWORD'] rs.flavor = /2 GB Performance/ rs.image = 'Windows Server 2012' @@ -333,8 +333,8 @@ Vagrant.configure("2") do |config| # ... other stuff config.vm.provider :rackspace do |rs| - rs.username = "mitchellh" - rs.api_key = "foobarbaz" + rs.username = ENV['RAX_USERNAME'] + rs.api_key = ENV['RAX_API_KEY'] end end ``` @@ -352,8 +352,8 @@ However, you may attach a VM to an isolated [Cloud Network](http://www.rackspace ```ruby config.vm.provider :rackspace do |rs| - rs.username = "mitchellh" - rs.api_key = "foobarbaz" + rs.username = ENV['RAX_USERNAME'] + rs.api_key = ENV['RAX_API_KEY'] rs.network '443aff42-be57-effb-ad30-c097c1e4503f' rs.network '5e738e11-def2-4a75-ad1e-05bbe3b49efe' rs.network :service_net, :attached => false From 54571c05dcf656b90a2c282f6b11dbbf1af932c5 Mon Sep 17 00:00:00 2001 From: Tony Rizko Date: Fri, 15 Jan 2016 10:51:30 -0800 Subject: [PATCH 42/42] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cd35d4c..8ebe4e5 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ $ vagrant plugin install vagrant-rackspace ## Usage -One the plugin is installed, you use it with `vagrant up` by specifing +Once the plugin is installed, you use it with `vagrant up` by specifing the `rackspace` provider: ``` $ vagrant up --provider=rackspace