Skip to content

Commit 878e769

Browse files
committed
Added a script to help create the vagrant static formation.
1 parent 5bcae3f commit 878e769

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

contrib/vagrant/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ This script will:
2020
- Run `vagrant up` to create a Deis controller and 2 static nodes
2121
- Register the controller with Chef and install Deis and supporting software
2222

23+
4. Register a user
24+
25+
5. Run the script to create a static formation:
26+
```console
27+
$ ./contrib/vagrant/create-static-formation.sh
28+
```
29+
30+
Notes
31+
-----
2332

2433
Mac OS X: if you see an error such as
2534
"failed to open /dev/vboxnetctl", try restarting VirtualBox:
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env bash
2+
3+
function echo_color {
4+
echo -e "\033[1m$1\033[0m"
5+
}
6+
7+
# Require a command-line arg for the formation name
8+
if [ -z $1 ]; then
9+
echo usage: $0 [formation]
10+
exit 1
11+
fi
12+
formation=$1
13+
14+
# Create a "static" formation, where nodes must be added manually
15+
deis formations:create $formation --flavor=static
16+
17+
# Update the layer to SSH as "vagrant", and retrieve its SSH public key
18+
echo_color "Updating the runtime layer to SSH as \"vagrant\"..."
19+
ssh_key=$(deis layers:update $formation runtime --ssh_username=vagrant |
20+
grep -Eo '\"ssh_public_key\"\: \"(.*)\"' | cut -d\" -f4)
21+
authfile=.ssh/authorized_keys
22+
tmpfile=/tmp/authorized_keys.tmp
23+
24+
# SSH into deis-node-1 and authorize the SSH public key
25+
echo_color "Adding the layer's public key to deis-node-1..."
26+
vagrant ssh deis-node-1 -c "echo $ssh_key|cat - $authfile > $tmpfile && mv $tmpfile $authfile"
27+
28+
# Add deis-node-1 to the formation
29+
echo_color "Adding node deis-node-1 to formation and provisioning..."
30+
deis nodes:create $formation deis-node-1.local --layer=runtime
31+
32+
# SSH into deis-node-2 and authorize the SSH public key
33+
echo_color "Adding the layer's public key to deis-node-2..."
34+
vagrant ssh deis-node-2 -c "echo $ssh_key|cat - $authfile > $tmpfile && mv $tmpfile $authfile"
35+
36+
# Add deis-node-1 to the formation
37+
echo_color "Adding node deis-node-2 to formation and provisioning..."
38+
deis nodes:create $formation deis-node-2.local --layer=runtime
39+
40+
echo_color "Done. Now run \"deis create --formation=$formation\" in your app repository."

0 commit comments

Comments
 (0)