community.elastic.elastic_bulk (1.1.2) — module

Perform actions with documents using the Bulk API.

| "added in version" 0.0.1 of community.elastic"

Authors: Rhys Campbell (@rhysmeister)

Install collection

Install with ansible-galaxy collection install community.elastic:==1.1.2


Add to requirements.yml

  collections:
    - name: community.elastic
      version: 1.1.2

Description

Perform actions with documents using the Bulk API.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Use the actions key to include json inline
  community.elastic.elastic_bulk:
    index: myindex
    actions:
      index:
        - { "quote": "To be, or not to be: that is the question" }
        - { "quote": "This above all: to thine own self be true" }
        - { "quote": "Cowards die many times before their deaths; The valiant never taste of death but once." }
        - { "_id:": 1,  "hello": "I am a document that already exists" }
      create:
        - { "foo": "bar" }
      delete:
        - { "_id": 99 }
      update:
        - { "foo": "I am a new document that will be created" }
        - { "_id": 101, "foo": "I exist already and will be updated" }
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Provide a file with json data
  community.elastic.elastic_bulk:
    index: myindex
    src: /path/to/data.json

Inputs

    
src:
    description:
    - Path to a json file containing documents to bulk insert.
    type: str

index:
    description:
    - The index to copy documents to.
    required: true
    type: str

cafile:
    description:
    - Path to ca file
    type: str

actions:
    description:
    - Include json inline to insert, update or delete documents.
    - Acceptable subkeys are create, index, update & delete.
    type: dict

timeout:
    default: 30
    description:
    - Response timeout in seconds.
    type: int

chunk_size:
    default: 1000
    description:
    - Bulk insert batch size.
    type: int

login_port:
    default: 9200
    description:
    - The Elastic server port to login to.
    required: false
    type: int

login_user:
    description:
    - The Elastic user to login with.
    - Required when I(login_password) is specified.
    required: false
    type: str

stats_only:
    default: true
    description:
    - Report number of successful/failed operations instead of just number of successful
      and a list of error responses
    type: bool

auth_method:
    choices:
    - ''
    - http_auth
    default: ''
    description:
    - Authentication Method.
    type: str

auth_scheme:
    choices:
    - http
    - https
    default: http
    description:
    - Authentication scheme.
    type: str

login_hosts:
    default: localhost
    description:
    - The Elastic hosts to connect to.
    elements: str
    required: false
    type: list

login_password:
    description:
    - The password used to authenticate with.
    - Required when I(login_user) is specified.
    required: false
    type: str

connection_options:
    default: []
    description:
    - Additional connection options for Elasticsearch
    elements: dict
    type: list

Outputs

error_docs:
  description: Array of documents that failed
  returned: when stats_only is False
  type: dict
errors:
  description: Number of Bulk errors,
  returned: on success
  type: int
took:
  description: How long the Bulk API operation took.
  returned: on success
  type: int