Skip to content

Instantly share code, notes, and snippets.

@mindovermiles262
Created December 11, 2018 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mindovermiles262/5964d590101b80b5a21b8306e44e0383 to your computer and use it in GitHub Desktop.
Save mindovermiles262/5964d590101b80b5a21b8306e44e0383 to your computer and use it in GitHub Desktop.
#!/bin/bash
apt-get update
apt-get -y install curl
# create staging directories
if [ ! -d /drop ]; then
mkdir /drop
fi
if [ ! -d /downloads ]; then
mkdir /downloads
fi
# download the Chef server package
if [ ! -f /downloads/chef-server-core_12.17.33_amd64.deb ]; then
echo "Downloading the Chef server package..."
wget -nv -P /downloads https://packages.chef.io/files/stable/chef-server/12.17.33/ubuntu/16.04/chef-server-core_12.17.33-1_amd64.deb
fi
# install Chef server
if [ ! $(which chef-server-ctl) ]; then
echo "Installing Chef server..."
dpkg -i /downloads/chef-server-core_12.17.33-1_amd64.deb
chef-server-ctl reconfigure
echo "Waiting for services..."
until (curl -D - http://localhost:8000/_status) | grep "200 OK"; do sleep 15s; done
while (curl http://localhost:8000/_status) | grep "fail"; do sleep 15s; done
echo "Creating initial user and organization..."
chef-server-ctl user-create chefadmin Chef Admin admin@4thcoffee.com insecurepassword --filename /drop/chefadmin.pem
chef-server-ctl org-create 4thcoffee "Fourth Coffee, Inc." --association_user chefadmin --filename 4thcoffee-validator.pem
fi
echo "Your Chef server is ready!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment