Skip to content

Commit 0b8ed93

Browse files
committed
Get the DO client ID and key from the nearest knife.rb rather than ENV for users that have more than one DO account.
Check to see if knife bootstrap succeeded and if not delete the server and the Chef client and node, so that's it's easie to try again.
1 parent 9f18138 commit 0b8ed93

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

contrib/digitalocean/provision-digitalocean-controller.sh

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ if ! $CONTRIB_DIR/check-deis-deps.sh; then
2424
fi
2525

2626
# connection details for using digital ocean's API
27-
client_id=$DIGITALOCEAN_CLIENT_ID
28-
api_key=$DIGITALOCEAN_API_KEY
27+
client_id=$(knife exec -E"puts Chef::Config[:knife][:digital_ocean_client_id]")
28+
api_key=$(knife exec -E"puts Chef::Config[:knife][:digital_ocean_api_key]")
2929

3030
# Check that client ID and API key was set
3131
if test -z $client_id; then
@@ -111,7 +111,23 @@ knife digital_ocean droplet create \
111111
--identity-file $ssh_key_path \
112112
--bootstrap \
113113
--run-list $run_list
114+
result=$?
114115
set +x
115116

116-
# Need Chef admin permission in order to add and remove nodes and clients
117-
echo -e "\033[35mPlease ensure that \"deis-controller\" is added to the Chef \"admins\" group.\033[0m"
117+
if [ $result -ne 0 ]; then
118+
echo_color "Knife botstrap failed."
119+
# Destroy droplet
120+
droplet_id=$(knife digital_ocean droplet list | grep deis-controller | awk '{print $1}')
121+
echo_color "Destroying Droplet $droplet_id..."
122+
knife digital_ocean droplet destroy -S $droplet_id
123+
# Remove node and client from Chef Server
124+
echo_color "Deleting Chef client..."
125+
knife client delete deis-controller
126+
echo_color "Deleting Chef node..."
127+
knife node delete deis-controller
128+
else
129+
echo_color "Knife bootstrap successful."
130+
# Need Chef admin permission in order to add and remove nodes and clients
131+
echo -e "\033[35mPlease ensure that \"deis-controller\" is added to the Chef \"admins\" group.\033[0m"
132+
fi
133+

0 commit comments

Comments
 (0)