Skip to content

Instantly share code, notes, and snippets.

@keithchambers
Last active August 29, 2015 14:17
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 keithchambers/5081243bad64a6fa051d to your computer and use it in GitHub Desktop.
Save keithchambers/5081243bad64a6fa051d to your computer and use it in GitHub Desktop.
Consul check for ACL
#!/bin/bash
set -e
MASTER_TOKEN="$1"
AGENT_TOKEN="$2"
create_acl() {
curl -X PUT "http://localhost:8500/v1/acl/create?token=$MASTER_TOKEN" \
-d '{"Name": "agent_policy", "Type": "client", "Rules": "service \"\" {policy = \"write\"}"}'
}
if [[ -z "$AGENT_TOKEN" ]]; then
create_acl
elif [[ "$(curl http://localhost:8500/v1/acl/info/$AGENT_TOKEN?token=$MASTER_TOKEN)" == "null" ]]; then
create_acl
else
echo "{ "ID":\""$AGENT_TOKEN\"" }"
fi
# EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment