Skip to content

Instantly share code, notes, and snippets.

@dgrstl
Last active March 2, 2016 17:11
Show Gist options
  • Save dgrstl/e9bda1e2e67dd589bfe4 to your computer and use it in GitHub Desktop.
Save dgrstl/e9bda1e2e67dd589bfe4 to your computer and use it in GitHub Desktop.
#!/bin/bash
echo "==> Delete the code-staging dir"
rm -rf /etc/puppetlabs/code-staging/environments
rm -rf /etc/puppetlabs/code-staging/.gitmodules
echo "==> Running r10k manually as pe-puppet to fetch new code"
sudo -u pe-puppet bash -c '/opt/puppetlabs/bin/r10k deploy environment -c /opt/puppetlabs/server/data/code-manager/r10k.yaml -p -v debug'
echo "==> Delete the code dir so file-sync can do its thing"
sudo rm -rf /etc/puppetlabs/code/*
# Set variables for the curl.
CERT="$(puppet agent --configprint hostcert)"
KEY="$(puppet agent --configprint hostprivkey)"
CACERT="$(puppet agent --configprint localcacert)"
echo "==> Hitting the file-sync commit endpoint at https://$(hostname -f):8140/file-sync/v1/commit"
/opt/puppetlabs/puppet/bin/curl -v -s --request POST \
--header "Content-Type: application/json" \
--data '{"commit-all": true}' \
--cert "$CERT" \
--key "$KEY" \
--cacert "$CACERT" \
"https://$(hostname -f):8140/file-sync/v1/commit" && echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment