salt.modules.elasticsearch

Elasticsearch - A distributed RESTful search and analytics server

Module to provide Elasticsearch compatibility to Salt (compatible with Elasticsearch version 1.5.2+)

2015.8.0 新版功能.

depends:

elasticsearch-py

configuration:

This module accepts connection configuration details either as parameters or as configuration settings in /etc/salt/minion on the relevant minions:

elasticsearch:
  host: '10.10.10.100:9200'

elasticsearch:
  hosts:
    - '10.10.10.100:9200'
    - '10.10.10.101:9200'
    - '10.10.10.102:9200'

elasticsearch:
  hosts:
    - '10.10.10.100:9200'
  number_of_shards: 1
  number_of_replicas: 0
  functions_blacklist:
    - 'saltutil.find_job'
    - 'pillar.items'
    - 'grains.items'

This data can also be passed into pillar. Options passed into opts will overwrite options passed into pillar.

salt.modules.elasticsearch.alias_create(indices, alias, hosts=None, body=None, profile=None)

Create an alias for a specific index/indices

CLI example:

salt myminion elasticsearch.alias_create testindex_v1 testindex
salt.modules.elasticsearch.alias_delete(indices, aliases, hosts=None, body=None, profile=None)

Delete an alias of an index

CLI example:

salt myminion elasticsearch.alias_delete testindex_v1 testindex
salt.modules.elasticsearch.alias_exists(aliases, indices=None, hosts=None, profile=None)

Return a boolean indicating whether given alias exists

CLI example:

salt myminion elasticsearch.alias_exists testindex
salt.modules.elasticsearch.alias_get(indices=None, aliases=None, hosts=None, profile=None)

Check for the existence of an alias and if it exists, return it

CLI example:

salt myminion elasticsearch.alias_get testindex
salt.modules.elasticsearch.document_create(index, doc_type, body=None, id=None, hosts=None, profile=None)

Create a document in a specified index

CLI example:

salt myminion elasticsearch.document_create testindex doctype1 '{}'
salt.modules.elasticsearch.document_delete(index, doc_type, id, hosts=None, profile=None)

Delete a document from an index

CLI example:

salt myminion elasticsearch.document_delete testindex doctype1 AUx-384m0Bug_8U80wQZ
salt.modules.elasticsearch.document_exists(index, id, doc_type='_all', hosts=None, profile=None)

Return a boolean indicating whether given document exists

CLI example:

salt myminion elasticsearch.document_exists testindex AUx-384m0Bug_8U80wQZ
salt.modules.elasticsearch.document_get(index, id, doc_type='_all', hosts=None, profile=None)

Check for the existence of a document and if it exists, return it

CLI example:

salt myminion elasticsearch.document_get testindex AUx-384m0Bug_8U80wQZ
salt.modules.elasticsearch.index_create(index, body=None, hosts=None, profile=None)

Create an index

CLI example:

salt myminion elasticsearch.index_create testindex
salt.modules.elasticsearch.index_delete(index, hosts=None, profile=None)

Delete an index

CLI example:

salt myminion elasticsearch.index_delete testindex
salt.modules.elasticsearch.index_exists(index, hosts=None, profile=None)

Return a boolean indicating whether given index exists

CLI example:

salt myminion elasticsearch.index_exists testindex
salt.modules.elasticsearch.index_get(index, hosts=None, profile=None)

Check for the existence of an index and if it exists, return it

CLI example:

salt myminion elasticsearch.index_get testindex
salt.modules.elasticsearch.index_template_create(name, body, hosts=None, profile=None)

Create an index template

CLI example:

salt myminion elasticsearch.index_template_create testindex_templ '{ "template": "logstash-*", "order": 1, "settings": { "number_of_shards": 1 } }'
salt.modules.elasticsearch.index_template_delete(name, hosts=None, profile=None)

Delete an index template (type) along with its data

CLI example:

salt myminion elasticsearch.index_template_delete testindex_templ user
salt.modules.elasticsearch.index_template_exists(name, hosts=None, profile=None)

Return a boolean indicating whether given index template exists

CLI example:

salt myminion elasticsearch.index_template_exists testindex_templ
salt.modules.elasticsearch.index_template_get(name, hosts=None, profile=None)

Retrieve template definition of index or index/type

CLI example:

salt myminion elasticsearch.index_template_get testindex_templ user
salt.modules.elasticsearch.mapping_create(index, doc_type, body, hosts=None, profile=None)

Create a mapping in a given index

CLI example:

salt myminion elasticsearch.mapping_create testindex user '{ "user" : { "properties" : { "message" : {"type" : "string", "store" : true } } } }'
salt.modules.elasticsearch.mapping_delete(index, doc_type, hosts=None, profile=None)

Delete a mapping (type) along with its data

CLI example:

salt myminion elasticsearch.mapping_delete testindex user
salt.modules.elasticsearch.mapping_get(index, doc_type, hosts=None, profile=None)

Retrieve mapping definition of index or index/type

CLI example:

salt myminion elasticsearch.mapping_get testindex user