• This repository has been archived on 31/Oct/2023
  • Stars
    star
    234
  • Rank 171,630 (Top 4 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 11 years ago
  • Updated almost 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Use Vagrant to manage Rackspace Cloud instances.

Vagrant Rackspace Cloud Provider

This is a Vagrant 1.5+ plugin that adds a Rackspace Cloud provider to Vagrant, allowing Vagrant to control and provision machines within Rackspace cloud.

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.
  • Sync folders with any built-in Vagrant synchronized folder plugin (e.g. rsync)
  • Create Rackspace images from a running Vagrant box

Installation

Install using standard Vagrant plugin installation methods.

$ vagrant plugin install vagrant-rackspace

Usage

Once the plugin is installed, you use it with vagrant up by specifing the rackspace provider:

$ vagrant up --provider=rackspace

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:

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-rackspace-user-name"
    rs.api_key          = "your-rackspace-api-key"
    rs.rackspace_region = :ord
    rs.flavor           = /1 GB Performance/
    rs.image            = /Ubuntu/
    rs.metadata         = {"key" => "value"}       # optional
  end
end

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.

    .tcshrc:
        setenv RAX_USERNAME "your-rackspace-user-name"
        setenv RAX_REG ":region"
        setenv API_KEY "your-rackspace-api-key"
    .bashrc or .zshrc
        export RAX_USERNAME="your-rackspace-user-name"
        export RAX_REG=":region"
        export API_KEY="your-rackspace-api-key"

Change your vagrant file to source your environment. It should look like this:

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_USERNAME']
    rs.api_key          = ENV['RAX_API_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:

$ 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 / 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:

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:

  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:

Vagrant.configure("2") do |config|
  config.vm.box = "dummy"
  config.ssh.pty = true

  config.vm.provider :rackspace do |rs|
    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'
  end
end

Windows (enabling WinRM)

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.

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.7.0) only supports WinRM as plaintext over HTTP, but SSL support is in progress 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 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:

Vagrant.configure("2") do |config|
  config.vm.box = "dummy"

  config.vm.provider :rackspace do |rs|
    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'
  end
end

You can get a sample bootstrap.cmd file from this repo.

Parallel, multi-machine setup

You can define multiple machines in a single Vagrant file, sourcing common parameters from your shell environment, for example:

Environment

    .tcshrc:
        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"
    .bashrc or .zshrc
        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"

Vagrantfile:

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.

  # Every Vagrant virtual environment requires a box to build off of.
  config.vm.box = "dummy"

  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

  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.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_REG'] ||= 'dfw'
      rs.init_script = File.read 'bootstrap.cmd'
    end
  end
end

You than can then launch them all with vagrant up --provider rackspace, or a specific server with vagrant up --provider rackspace <name>.

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

The plugin includes several Rackspace-specific vagrant commands. You can get the list of available commands with vagrant rackspace -h.

Flavors / Images

You can list all available images with the command:

$ 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 <name>
$ vagrant rackspace flavors <name>

Custom Commands

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:

$ vagrant rackspace images

In a multi-machine Vagrantfile you can also query for a single machine:

$ vagrant rackspace images <name>

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.

Configuration

This provider exposes quite a few provider-specific configuration options:

  • api_key - The API key for accessing Rackspace.
  • flavor - The server flavor to boot. This can be a string matching the exact ID or name of the server, or this can be a regular expression to partially match some server flavor. Flavors are listed here.
  • 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: :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 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, 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 can be overridden with this.
  • username - The username with which to access Rackspace.
  • disk_config - Disk Configuration 'AUTO' or 'MANUAL'
  • metadata - A set of key pair values that will be passed to the instance for configuration.

These can be set like typical provider-specific configuration:

Vagrant.configure("2") do |config|
  # ... other stuff

  config.vm.provider :rackspace do |rs|
    rs.username = ENV['RAX_USERNAME']
    rs.api_key  = ENV['RAX_API_KEY']
  end
end

You can find a more complete list the documentation for the Config class.

Networks

Networking features in the form of config.vm.network are not supported with vagrant-rackspace, currently. If any of these are specified, Vagrant will emit a warning, but will otherwise boot the Rackspace server.

However, you may attach a VM to an isolated Cloud Network (or Networks) using the network configuration option. Here's an example which adds two Cloud Networks and disables ServiceNet with the :attach => false option:

config.vm.provider :rackspace do |rs|
  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
end

Synced Folders

You can use this provider with the Vagrant synced folders. The default type should be rsync for most images, with the possible exception of Windows.

Plugins

Vagrant has great support for plugins and many of them should work alongside vagrant-rackspace. See the list of Available Vagrant Plugins.

Development

To work on the vagrant-rackspace plugin, clone this repository out, and use Bundler to get the dependencies:

$ bundle

Once you have the dependencies, verify the unit tests pass with rake:

$ bundle exec rake

If those pass, you're ready to start developing the plugin. You can test the plugin without installing it into your Vagrant environment by just creating a Vagrantfile in the top level of this directory (it is gitignored) that uses it, and uses bundler to execute Vagrant:

$ bundle exec vagrant up --provider=rackspace

More Repositories

1

mapstructure

Go library for decoding generic map values into native Go structures and vice versa.
Go
7,685
star
2

gox

A dead simple, no frills Go cross compile tool
Go
4,594
star
3

vagrant-aws

Use Vagrant to manage your EC2 and VPC instances.
Ruby
2,609
star
4

nixos-config

My NixOS configurations.
Nix
1,791
star
5

cli

A Go library for implementing command-line interfaces.
Go
1,724
star
6

libxev

libxev is a cross-platform, high-performance event loop that provides abstractions for non-blocking IO, timers, events, and more and works on Linux (io_uring or epoll), macOS (kqueue), and Wasm + WASI. Available as both a Zig and C API.
Zig
1,589
star
7

gon

Sign, notarize, and package macOS CLI tools and applications written in any language. Available as both a CLI and a Go library.
Go
1,461
star
8

go-ps

Find, list, and inspect processes from Go (golang).
Go
1,449
star
9

go-homedir

Go library for detecting and expanding the user's home directory without cgo.
Go
1,390
star
10

go-server-timing

Go (golang) library for creating and consuming HTTP Server-Timing headers
Go
861
star
11

hashstructure

Get hash values for arbitrary values in Go (golang).
Go
745
star
12

goamz

Golang Amazon Library
Go
673
star
13

golicense

Scan and analyze OSS dependencies and licenses from compiled Go binaries
Go
666
star
14

ioprogress

Go (golang) package for progress bars around io.Reader/Writers.
Go
502
star
15

go-mruby

Go (golang) bindings to mruby.
Go
468
star
16

panicwrap

panicwrap is a Go library for catching and handling panics in Go applications.
Go
443
star
17

advent-2021-sql

Advent of Code 2021 using SQL (PostgreSQL-flavored)
PLpgSQL
436
star
18

boot2docker-vagrant-box

Packer scripts to build a Vagrant-compatible boot2docker box.
Smarty
425
star
19

copystructure

Go (golang) library for deep copying values in Go.
Go
345
star
20

vagrant-google

Vagrant provider for GCE.
Ruby
334
star
21

go-glint

Component-based UI-framework for command-line tools. Easily create highly dynamic CLI interfaces using shared, easily testable components.
Go
311
star
22

go-vnc

VNC client and server library for Go.
Go
283
star
23

colorstring

Go (golang) library for colorizing strings for terminal output.
Go
276
star
24

reflectwalk

reflectwalk is a Go library for "walking" complex structures, similar to walking a filesystem.
Go
274
star
25

virtualbox

[ABANDONED] Create and modify virtual machines in VirtualBox using pure ruby.
Ruby
244
star
26

protoc-gen-go-json

Protobuf compiler plugin to generate Go JSON Marshal/Unmarshal implementations for messages using jsonpb.
Go
225
star
27

pointerstructure

Go library for addressing and reading/writing a specific value within any Go structure using a string syntax.
Go
214
star
28

zig-overlay

Nix flake for the Zig compiler.
Nix
195
star
29

zig-js

Access the JS host environment from Zig compiled to WebAssembly.
Zig
178
star
30

dotfiles

My personal dotfiles.
Batchfile
176
star
31

protostructure

Encode and decode Go (golang) struct types via protocol buffers.
Go
172
star
32

consulstructure

Decode Consul data into Go (Golang) structures and watch for updates
Go
172
star
33

packer-ubuntu-12.04-docker

Packer template that builds images that are Docker-ready on Ubuntu 12.04.
Shell
157
star
34

zig-libgc

Zig-friendly library for interfacing with libgc (bdwgc) -- the Boehm-Demers-Weiser conservative garbage collector
Zig
156
star
35

zig-objc

Objective-C runtime bindings for Zig (Zig calling ObjC).
Zig
153
star
36

libflightplan

A library for reading and writing flight plans in various formats. Available as both a C and Zig library.
Zig
153
star
37

terraform-provider-multispace

Terraform Provider for cascading runs across multiple workspaces.
Go
147
star
38

multistep

multistep is a Go library for building up complex actions using discrete steps.
Go
146
star
39

go-z3

Go (golang) bindings to the Z3 SMT Solver
Go
138
star
40

go-sat

SAT solver written in Go (golang).
Go
136
star
41

go-wordwrap

A Go (golang) library for wrapping words in a string.
Go
107
star
42

vim-misc

My Vim configuration files.
Vim Script
99
star
43

middleware

Generalized middleware implementation for Ruby.
Ruby
94
star
44

go-fs

Filesystem library for Go, implementing FAT filesystems so far.
Go
88
star
45

zig-graph

Directed graph data structure for Zig
Zig
86
star
46

go-grpc-net-conn

Turn any gRPC stream into a Go `net.Conn` implementation.
Go
80
star
47

zig-libxml2

libxml2 built using Zig build system
Zig
76
star
48

lightcloud

Library for accessing Plurk's LightCloud distributed key-value store for Ruby
Ruby
75
star
49

tree-sitter-hcl

A tree-sitter grammar for HCL (HashiCorp Configuration Language), used by projects such as Terraform.
C
69
star
50

go-linereader

Golang package that reads lines from an io.Reader and puts them onto a channel.
Go
66
star
51

veewee-to-packer

A tool for converting Veewee templates into Packer templates.
Ruby
65
star
52

tree-sitter-proto

A tree-sitter grammar for protocol buffer files (proto3).
C
63
star
53

vagrant-rake

A Vagrant plugin to execute `rake` commands from the host in the VM
Ruby
62
star
54

libvirt-rb

[ABANDONED] A ruby client library providing an interface to libvirt via FFI.
Ruby
59
star
55

go-testing-interface

Go (golang) library to expose *testing.T as an interface.
Go
58
star
56

patchstructure

Go library for representing and applying patches to modify existing Go structures
Go
55
star
57

squire

Go
55
star
58

go-libucl

Bindings to libucl from Go (golang).
Go
54
star
59

go-finger

Finger protocol library
Go
54
star
60

go-bnet

Go (golang) client for the Battle.net API
Go
52
star
61

libssh2-ruby

libssh2 bindings for Ruby
Ruby
47
star
62

iochan

A Go library for turning `io.Reader` into channels.
Go
43
star
63

prefixedio

Golang library that demultiplexes line-oriented data from an io.Reader into multiple io.Readers based on a prefix.
Go
42
star
64

flask-nix-example

Dockerfile
36
star
65

tlaplus-radix-tree

TLA+ modules, specifications, and models for Radix trees.
TLA
33
star
66

caststructure

A Go library that provides functions for downcasting types, composing values dynamically, and more.
Go
32
star
67

virtuoso

Dead simple virtual machine management over many hypervisors.
Ruby
30
star
68

hash_ring

Consistent hashing in Ruby. Ported from Amir Sailhefendic's hash_ring python library.
Ruby
28
star
69

terraform-aws-dynamic-keys

Terraform module that dynamically generates a public/private keypair.
HCL
26
star
70

go-spdx

Golang library for listing and looking up licenses using SPDX IDs.
Go
23
star
71

ruburple

A ruby interface to libpurple. Copied for git.
C
20
star
72

iorpc

Golang io interfaces across an RPC connection.
Go
18
star
73

fusion-m1-514-repro

Makefile
17
star
74

zig-build-macos-sdk

macOS SDK package for Zig build.
C
15
star
75

omniconfig

Flexible configuration for your Ruby applications and libraries.
Ruby
14
star
76

zig-libuv

Zig bindings for libuv. Also a build script to build libuv from scratch using only Zig (for easy cross-compilation, integration with Zig, etc.).
Zig
13
star
77

terraform-aws-fastai

Terraform module to create Fast.ai course instance.
HCL
12
star
78

radar

Easily report errors in your libraries and applications any way you want!
Ruby
12
star
79

zig-build-libxml2

The libxml2 library built and packaged for the Zig build system. These are not Zig language bindings to the library.
C
11
star
80

tiad-demo

Demo for The Incredible Automation Day in Paris.
Shell
10
star
81

waypoint-helm

WIP
Smarty
9
star
82

boto-route53

Route53 API built on top of Boto
Python
8
star
83

fogli

An efficient, simple, and intuitive Facebook Open Graph library
Ruby
8
star
84

minitest-mark

Proof of concept minitest extension to add test marking.
Ruby
7
star
85

vagrant-downloads

The Vagrant downloads website.
Ruby
7
star
86

minitest-parallel

Proof of concept to run your minitest tests in parallel.
Ruby
6
star
87

goconf

This is a copy of http://code.google.com/p/goconf/
Go
6
star
88

packer-go-bootcamp

Packer templates for the Go Bootcamp images.
Shell
6
star
89

larubyconf-vagrant-examples

Examples of using Vagrant from LARubyConf
Ruby
6
star
90

xidl

Parses XIDL files into Ruby objects.
Ruby
5
star
91

bintray-download-site

Simple Rack app for creating easy downloads for your Bintray packages.
Ruby
5
star
92

terraform-aws-vpc

Temporary, testing something, ignore this.
HCL
5
star
93

minitest-speed

Proof of concept speed tests using minitest.
Ruby
5
star
94

zig-build-xcode-frameworks

Exposing hexops/xcode-frameworks to the Zig package manager to work around some bugs.
Zig
5
star
95

homebrew-gon

Homebrew Tap for Gon (github.com/mitchellh/gon)
Ruby
4
star
96

osext

Copy of https://bitbucket.org/kardianos/osext
Go
4
star
97

minitest-funcarg

Proof of concept showing funcargs (style of DI) in minitest.
Ruby
4
star
98

lifeguard-random

Data source plugin for Lifeguard that generates random numbers.
Shell
4
star
99

go-bootcamp-remotecmds

My solution for the remotecmds problem for the Go Bootcamp I'm helping to instruct.
Go
4
star
100

lifeguard-graphite

Data source plugin for Lifeguard to query data from Graphite.
Shell
4
star