Skip to content

Instantly share code, notes, and snippets.

@skylerto
Created March 5, 2018 18:53
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 skylerto/71f31a8a73d02fbf5d60c85d3cd5c9bd to your computer and use it in GitHub Desktop.
Save skylerto/71f31a8a73d02fbf5d60c85d3cd5c9bd to your computer and use it in GitHub Desktop.
#!/bin/bash
SSL_PORT=8443
CHEF_DIR=$(pwd)/.chef
# docker run --privileged -t --name localhost -d -p $SSL_PORT:443 -e CONTAINER_NAME=localhost cbuisson/chef-server
if [ -d "$CHEF_DIR" ]; then
rm -rf $CHEF_DIR
fi
mkdir -p $CHEF_DIR
echo $CHEF_DIR
# curl -o /dev/null --silent --head --write-out '%{http_code}\n' https://localhost:$SSL_PORT
cd $CHEF_DIR && { curl -Ok https://localhost:$SSL_PORT/knife_admin_key.tar.gz ; cd -; }
cd $CHEF_DIR && { tar zxvf knife_admin_key.tar.gz ; cd -; }
cat <<- EOF > $CHEF_DIR/knife.rb
log_level :info
log_location STDOUT
cache_type 'BasicFile'
node_name 'admin'
client_key '$CHEF_DIR/admin.pem'
validation_client_name 'my_org-validator'
validation_key '$CHEF_DIR/my_org-validator.pem'
chef_server_url 'https://localhost:$SSL_PORT/organizations/my_org'
trusted_certs_dir '$CHEF_DIR/trusted_certs_dir'
EOF
chef exec knife ssl fetch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment