Skip to content

Instantly share code, notes, and snippets.

@cvializ
Last active August 29, 2015 14:00
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 cvializ/11294031 to your computer and use it in GitHub Desktop.
Save cvializ/11294031 to your computer and use it in GitHub Desktop.
curl -XDELETE 'http://localhost:9200/accesscontrol/'
curl -XPUT 'http://localhost:9200/accesscontrol/' -d '{
"mappings" : {
"group" : {
"properties" : {
"name" : { "type" : "string" },
"hosts" : { "type" : "string" }
}
},
"user" : {
"_parent" : { "type" : "group" },
"_routing" : { "required" : true, "path" : "group_id" },
"properties" : {
"name" : { "type" : "string" },
"group_id" : { "type" : "string" }
}
}
}
}'
# Create the user groups and specify which computers
# they may view logs for
curl -XPUT 'http://localhost:9200/accesscontrol/group/intern' -d '{
"name" : "intern",
"hosts" : ["computer1"]
}'
curl -XPUT 'http://localhost:9200/accesscontrol/group/admin' -d '{
"name" : "admin",
"hosts" : ["computer1","computer2","computer3"]
}'
# Create the users and specify the groups they belong to.
curl -XPUT 'http://localhost:9200/accesscontrol/user/cvializ?parent=intern' -d '{
"name" : "cvializ",
"group_id" : "intern"
}'
curl -XPUT 'http://localhost:9200/accesscontrol/user/frank?parent=admin' -d '{
"name" : "frank",
"group_id" : "admin"
}'
# Create the logstash alias for cvializ
curl -XPOST 'http://localhost:9200/_aliases' -d '
{
"actions" : [
{ "remove" : { "index" : "logstash-2014.04.25", "alias" : "cvializ-logstash-2014.04.25" } },
{
"add" : {
"index" : "logstash-2014.04.25",
"alias" : "cvializ-logstash-2014.04.25",
"filter": {
"terms" : {
"host" : {
"index" : "accesscontrol",
"type" : "user",
"id" : "cvializ",
"path" : "group.hosts"
},
"_cache_key" : "cvializ_hosts"
}
}
}
}
]
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment