Skip to content

Commit 5b98c0a

Browse files
committed
Merge pull request #601 from opdemand/fix-rackspace-provider
LGTM.
2 parents 1f8e06f + 1e8395d commit 5b98c0a

7 files changed

Lines changed: 108 additions & 138 deletions

File tree

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ gem 'foodcritic'
66
gem "berkshelf", "~> 2.0.10"
77

88
gem 'knife-ec2'
9-
gem 'knife-rackspace'
9+
gem 'knife-rackspace', '~> 0.9.0'
1010
gem 'knife-digital_ocean'

Gemfile.lock

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ GEM
2525
buff-config (0.4.0)
2626
buff-extensions (~> 0.3)
2727
varia_model (~> 0.1)
28-
buff-extensions (1.0.0)
28+
buff-extensions (0.5.0)
2929
buff-ignore (1.1.1)
3030
buff-ruby_engine (0.1.0)
3131
buff-shell_out (0.1.1)
@@ -66,22 +66,21 @@ GEM
6666
winrm (~> 1.1.2)
6767
erubis (2.7.0)
6868
eventmachine (1.0.3)
69-
excon (0.25.3)
69+
excon (0.31.0)
7070
faraday (0.8.9)
7171
multipart-post (~> 1.2.0)
7272
faraday_middleware (0.9.0)
7373
faraday (>= 0.7.4, < 0.9)
7474
ffi (1.9.3)
75-
fog (1.15.0)
75+
fog (1.20.0)
7676
builder
77-
excon (~> 0.25.0)
77+
excon (~> 0.31.0)
7878
formatador (~> 0.2.0)
7979
mime-types
8080
multi_json (~> 1.0)
8181
net-scp (~> 1.1)
8282
net-ssh (>= 2.1.3)
83-
nokogiri (~> 1.5)
84-
ruby-hmac
83+
nokogiri (>= 1.5.11)
8584
foodcritic (0.2.0)
8685
formatador (0.2.4)
8786
gssapi (1.0.3)
@@ -101,13 +100,12 @@ GEM
101100
chef (>= 10.18)
102101
digital_ocean (~> 1.3.0)
103102
highline
104-
knife-ec2 (0.6.6)
103+
knife-ec2 (0.6.4)
105104
chef (>= 0.10.10)
106-
fog (~> 1.15.0)
107-
knife-windows (>= 0.5.12)
108-
knife-rackspace (0.8.4)
105+
fog (~> 1.6)
106+
knife-rackspace (0.9.0)
109107
chef (>= 0.10.10)
110-
fog (~> 1.12)
108+
fog (~> 1.16)
111109
knife-windows
112110
knife-windows (0.5.15)
113111
em-winrm (~> 0.5, >= 0.5.4)
@@ -174,7 +172,6 @@ GEM
174172
solve (>= 0.4.4)
175173
varia_model (~> 0.1)
176174
winrm (~> 1.1.0)
177-
ruby-hmac (0.4.0)
178175
rubyntlm (0.1.1)
179176
savon (0.9.5)
180177
akami (~> 1.0)
@@ -214,4 +211,4 @@ DEPENDENCIES
214211
foodcritic
215212
knife-digital_ocean
216213
knife-ec2
217-
knife-rackspace
214+
knife-rackspace (~> 0.9.0)

contrib/rackspace/README.md

Lines changed: 56 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,54 +6,76 @@ Provision a Deis Controller on Rackspace
66
```console
77
$ cd $HOME/projects/deis
88
$ gem install knife-rackspace
9-
Fetching: knife-rackspace-0.8.1.gem (100%)
10-
Successfully installed knife-rackspace-0.8.1
9+
Fetching: knife-rackspace-0.9.0.gem (100%)
10+
Successfully installed knife-rackspace-0.9.0
1111
1 gem installed
12-
Installing ri documentation for knife-rackspace-0.8.1...
13-
Installing RDoc documentation for knife-rackspace-0.8.1...
12+
Installing ri documentation for knife-rackspace-0.9.0...
13+
Installing RDoc documentation for knife-rackspace-0.9.0...
1414
```
1515

16-
1. Export your Rackspace credentials as environment variables and edit knife.rb to read them:
16+
2. Export your Rackspace credentials as environment variables and edit knife.rb to read them:
1717

1818
```console
1919
$ cat <<'EOF' >> $HOME/.bash_profile
2020
export RACKSPACE_USERNAME=<your_rackspace_username>
2121
export RACKSPACE_API_KEY=<your_rackspace_api_key>
22+
source $HOME/.rackspacerc
23+
EOF
24+
$ cat <<'EOF' > $HOME/.rackspacerc
25+
export OS_AUTH_URL="https://identity.api.rackspacecloud.com/v2.0/"
26+
export OS_USERNAME=$RACKSPACE_USERNAME
27+
export OS_PASSWORD=$RACKSPACE_API_KEY
28+
export OS_TENANT_NAME=$RACKSPACE_USERNAME
29+
export OS_TENANT_ID=<your_rackspace_tenant_id>
30+
export OS_REGION_NAME=<your_rackspace_region_name>
31+
export OS_AUTH_SYSTEM="rackspace"
2232
EOF
2333
$ source $HOME/.bash_profile
34+
$ source $HOME/.rackspacerc
2435
$ cat <<'EOF' >> $HOME/.chef/knife.rb
2536
knife[:rackspace_api_username] = "#{ENV['RACKSPACE_USERNAME']}"
2637
knife[:rackspace_api_key] = "#{ENV['RACKSPACE_API_KEY']}"
38+
knife[:rackspace_ssh_keypair] = "deis"
39+
knife[:rackspace_region] = #{ENV['OS_REGION_NAME']}
2740
EOF
2841
$ knife rackspace server list
2942
Instance ID Name Public IP Private IP Flavor Image State
3043
```
3144

32-
1. Prepare a new server
45+
3. Now you can follow the standard deis setup:
46+
```bash
47+
bundle install # Installs gem files like the knife tool
48+
berks install # Downloads the relevant cookbooks
49+
# '--ssl-verify' is only needed when using a self-hosted Chef Server
50+
# hint: you can also set that at $HOME/.berkshelf/config.json
51+
berks upload [--ssl-verify=false] # Upload the cookbooks to the Chef Server
52+
```
53+
54+
4. Prepare a new server
3355
1. Create a server named `deis-prepare-image` using the Ubuntu 12.04 LTS image, performance1-2, 1GB performance server
34-
1. SSH in as root with the password shown
35-
1. Install the 3.11 kernel with: ```apt-get update && apt-get install -yq linux-image-generic-lts-saucy linux-headers-generic-lts-saucy && reboot```
36-
1. After reboot is complete, SSH back in as root and `uname -r` to confirm kernel is `3.11.0-17-generic`
37-
1. Run the `prepare-controller-image.sh` script to optimize the image for fast boot times
56+
2. SSH in as root with the password shown
57+
3. Install the 3.11 kernel with: ```apt-get update && apt-get install -yq linux-image-generic-lts-saucy linux-headers-generic-lts-saucy && reboot```
58+
4. After reboot is complete, SSH back in as root and `uname -r` to confirm kernel is `3.11.0-17-generic`
59+
5. Run the `prepare-node-image.sh` script to optimize the image for fast boot times
3860

3961
```console
40-
$ \curl -sSL https://raw2.github.com/opdemand/deis/master/contrib/rackspace/prepare-controller-image.sh | bash
62+
$ ssh root@ip-address 'bash -s' < contrib/rackspace/prepare-node-image.sh
4163
Reading package lists... Done
4264
Building dependency tree
4365
Reading state information... Done
4466
...
4567
```
4668

47-
1. Create a new image from the `deis-prepare-image` server named `deis-node-image`.
69+
5. Create a new image from the `deis-prepare-image` server named `deis-node-image`.
4870
1. In the server list in the Control Panel click the action cog for `deis-prepare-image`
49-
1. Select "Create New Image" name that image `deis-node-image`
50-
1. (optionally) Distribute the image to other regions
51-
1. (optionally) Create/update your Deis flavors to use your new images
71+
2. Select "Create New Image" name that image `deis-node-image`
72+
3. (optionally) Distribute the image to other regions
73+
4. (optionally) Create/update your Deis flavors to use your new images
5274

53-
1. Make sure to add the 'deis-controller' and the '<your_username>-validator' usernames to the Chef 'admins' group.
75+
6. Make sure to add the `deis-controller` and the `<your_username>-validator` usernames to the Chef 'admins' group.
5476
* If you are using hosted Chef, you may need to use the older console to do this: <https://manage.opscode.com/groups/admins/edit>
5577

56-
1. Back on your machine with deis cloned and the deis CLI installed, run the provisioning script to create a new Deis controller:
78+
7. Back on your machine with deis cloned and the deis CLI installed, run the provisioning script to create a new Deis controller:
5779
* Change ```<region>``` to match the region your image is in (we will add SYD and HKG as soon as performance flavors are available there):
5880
* dfw
5981
* ord
@@ -62,20 +84,28 @@ Provision a Deis Controller on Rackspace
6284

6385
```console
6486
$ cd deis
65-
$ ./bundle install # if you have not already done so
87+
$ bundle install # if you have not already done so
6688
$ ./contrib/rackspace/provision-rackspace-controller.sh <region>
6789
Provisioning a deis controller on Rackspace...
68-
Creating new SSH key: deis-controller
69-
+ ssh-keygen -f /home/myuser/.ssh/deis-controller -t rsa -N '' -C deis-controller
90+
Creating new SSH key: id_rsa
91+
+ ssh-keygen -f /home/deis/.ssh/id_rsa -t rsa -N '' -C deis
7092
+ set +x
71-
Saved to /home/myuser/.ssh/deis-controller
93+
Saved to /home/deis/.ssh/id_rsa
7294
Created data_bag[deis-formations]
7395
Created data_bag[deis-apps]
74-
Provisioning deis-controller with knife rackspace...
75-
+ knife rackspace server create -y --server-create-timeout 1200 --server-name deis-controller --image 4b7c635d-89e1-44be-a15f-2877b5a660d1 --rackspace-region <region> --flavor 4 --identity-file /home/myuser/.ssh/deis-controller --bootstrap-version 11.4.4 --node-name deis-controller --run-list 'recipe[deis::controller]'
76-
Instance ID: de17ca36-f186-4cdd-8969-4be58e7108ea
77-
Name: deis-controller
78-
Flavor: 2GB Standard Instance
96+
Provisioning deis-controller-H7WVl with knife rackspace...
97+
+ knife rackspace server create --bootstrap-version 11.8.2 --rackspace-region ord --image f569b831-afe5-44f5-85eb-3bf9e1d0d336 --flavor performance1-2 --rackspace-metadata '{"Name": "deis-controller-H7WVl"}' --rackspace-disk-config MANUAL --server-name deis-controller-H7WVl --node-name deis-controller-H7WVl --run-list 'recipe[deis::controller]'
98+
Instance ID: cf7aeadd-4bb1-4f69-9238-7a0586a863b9
99+
Name: deis-controller-H7WVl
100+
Flavor: 2 GB Performance
101+
Image: deis-node-image
102+
Metadata: [ <Fog::Compute::RackspaceV2::Metadatum
103+
key="Name",
104+
value="deis-controller-H7WVl"
105+
>]
106+
RackConnect Wait: no
107+
ServiceLevel Wait: no
108+
SSH Key: deis
79109
...
80110
```
81111

contrib/rackspace/prepare-controller-image.sh

Lines changed: 0 additions & 76 deletions
This file was deleted.

contrib/rackspace/prepare-node-image.sh

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
#!/bin/bash -ex
22

33
#
4-
# Prepare a Deis Node image for Rackspace.
4+
# Prepare a Deis image for Rackspace.
55
#
66
# Instructions:
77
#
8-
# 1. Launch a vanilla Ubuntu 12.04.3 droplet (64-bit)
9-
# 2. Run this script (as root!) to optimize the image for faster provisioning
10-
# 3. Create a new snapshot named "deis-node-image" from this droplet
8+
# 1. Create a server using the Ubuntu 12.04 LTS image,
9+
# performance1-2, 2GB performance server
10+
# 2. SSH in as root with the password shown, then install the 3.11 kernel with:
11+
# apt-get update && apt-get install -yq linux-image-generic-lts-saucy linux-headers-generic-lts-saucy && reboot
12+
# 3. After reboot is complete, SSH in and `uname -r` to confirm kernel is 3.11
13+
# 4. Run this script (as root) to optimize the image for fast boot times
14+
# 5. Create a new image from the server named "deis-node-image".
15+
# 6. Distribute the image to other regions
16+
# 7. Create/update your Deis flavors to use your new images
1117
#
1218

1319
# Remove old kernel(s)
@@ -22,7 +28,7 @@ echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/dock
2228

2329
# upgrade to latest packages
2430
apt-get update
25-
apt-get upgrade -yq
31+
apt-get dist-upgrade -yq
2632

2733
# install required packages
2834
apt-get install lxc-docker-0.8.0 fail2ban curl git inotify-tools make python-setuptools python-pip -yq
@@ -32,8 +38,16 @@ while [ ! -e /var/run/docker.sock ] ; do
3238
inotifywait -t 2 -e create $(dirname /var/run/docker.sock)
3339
done
3440

35-
# pull docker images
36-
docker pull deis/slugrunner:latest
41+
# pull current docker images
42+
docker pull deis/data:latest
43+
docker pull deis/discovery:latest
44+
docker pull deis/registry:latest
45+
docker pull deis/cache:latest
46+
docker pull deis/logger:latest
47+
docker pull deis/database:latest
48+
docker pull deis/server:latest
49+
docker pull deis/worker:latest
50+
docker pull deis/builder:latest
3751

3852
# install chef 11.x deps
3953
apt-get install -yq ruby1.9.1 ruby1.9.1-dev make

contrib/rackspace/provision-rackspace-controller.sh

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,15 @@ if ! "$CONTRIB_DIR/check-deis-deps.sh"; then
2121
exit 1
2222
fi
2323

24-
# check for knife-rackspace
25-
if ! knife rackspace server list > /dev/null; then
26-
echo 'Please install the knife-rackspace Ruby gem and configure knife.rb.'
24+
if ! nova --version > /dev/null 2>&1; then
25+
echo "Please install nova using 'pip install python-novaclient'."
2726
exit 1
2827
fi
2928

3029
#################
3130
# chef settings #
3231
#################
33-
node_name=deis-controller
32+
node_name="deis-controller-$(LC_CTYPE=C tr -dc A-Za-z0-9 < /dev/urandom | head -c 5 | xargs)"
3433
run_list="recipe[deis::controller]"
3534
chef_version=11.8.2
3635

@@ -57,21 +56,28 @@ fi
5756
################
5857
# SSH settings #
5958
################
60-
key_name=deis-controller
59+
key_name=id_rsa
6160
ssh_key_path=~/.ssh/$key_name
62-
ssh_user="ubuntu" # doesn't work?
61+
ssh_user="root"
6362

6463
# create ssh keypair and store it
6564
if ! test -e $ssh_key_path; then
6665
echo_color "Creating new SSH key: $key_name"
6766
set -x
68-
ssh-keygen -f $ssh_key_path -t rsa -N '' -C "deis-controller" >/dev/null
67+
ssh-keygen -f $ssh_key_path -t rsa -N '' -C "$USER" >/dev/null
6968
set +x
7069
echo_color "Saved to $ssh_key_path"
7170
else
7271
echo_color "WARNING: SSH key $ssh_key_path exists"
7372
fi
7473

74+
# upload the user's SSH key to Rackspace.
75+
# if it fails, that means that it's already been uploaded.
76+
echo "uploading keypair to Rackspace, please wait"
77+
if ! nova keypair-add --pub-key $ssh_key_path.pub deis > /dev/null; then
78+
echo "keypair already uploaded to Rackspace. Skipping."
79+
fi
80+
7581
# create data bags
7682
knife data bag create deis-formations 2>/dev/null
7783
knife data bag create deis-apps 2>/dev/null
@@ -86,7 +92,6 @@ knife rackspace server create \
8692
--flavor $flavor \
8793
--rackspace-metadata "{\"Name\": \"$node_name\"}" \
8894
--rackspace-disk-config MANUAL \
89-
--identity-file $ssh_key_path \
9095
--server-name $node_name \
9196
--node-name $node_name \
9297
--run-list $run_list

0 commit comments

Comments
 (0)