Skip to content

Instantly share code, notes, and snippets.

@backspace
Created December 4, 2019 16:51
Show Gist options
  • Save backspace/32a89b62cf1fc19d292eee5f3763d91a to your computer and use it in GitHub Desktop.
Save backspace/32a89b62cf1fc19d292eee5f3763d91a to your computer and use it in GitHub Desktop.
Exercising hashicorp/nomad#5944: UI: Change Run Job availability based on ACLs
namespace "list-only-namespace" {
capabilities = ["list-jobs"]
}
namespace "permissive-namespace" {
policy = "write"
}
namespace "wildcard-*" {
capabilities = ["list-jobs"]
}
agent {
policy = "read"
}
node {
policy = "read"
}
acl = {
enabled = true
}
export NOMAD_TOKEN=`nomad acl bootstrap | grep "Secret ID" | cut -d " " -f 7`
echo "Management token: $NOMAD_TOKEN"
export USER_NOMAD_TOKEN=`nomad acl token create -name=user -policy=user| grep "Secret ID" | cut -d " " -f 7`
echo "User token: $USER_NOMAD_TOKEN"
nomad acl policy apply anonymous anonymous-policy.hcl
nomad acl policy apply user user-policy.hcl
nomad namespace apply list-only-namespace
nomad namespace apply permissive-namespace
nomad namespace apply wildcard-something
nomad namespace apply wildcard-specific
nomad namespace apply other
# Now if you run the UI, you can try it out with the management token, the user token, and without a token (anonymous).
# Must be at least Nomad 0.10.2
nomad agent -dev -config=client-acl.hcl
namespace "list-only-namespace" {
capabilities = ["list-jobs"]
}
namespace "permissive-namespace" {
policy = "write"
}
namespace "wildcard-*" {
policy = "write"
}
namespace "wildcard-specific" {
capabilities = ["list-jobs"]
}
namespace "default" {
policy = "write"
}
agent {
policy = "read"
}
node {
policy = "read"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment