ravendb.ravendb.index module – Manage RavenDB indexes
Note
This module is part of the ravendb.ravendb collection (version 1.0.4).
You might already have this collection installed if you are using the ansible package.
It is not included in ansible-core.
To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install ravendb.ravendb.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: ravendb.ravendb.index.
New in ravendb.ravendb 1.0.0
Synopsis
Create, delete, update, or apply operational modes to RavenDB indexes.
Supports both single-map and multi-map index definitions (with optional reduce).
Supports check mode to simulate changes without applying them.
Can reconcile per-index configuration via
index_configuration.
Requirements
The below requirements are needed on the host that executes this module.
python >= 3.9
ravendb python client
ASP.NET Core Runtime
requests
Role ravendb.ravendb.ravendb_python_client_prerequisites must be installed before using this module.
Parameters
Parameter |
Comments |
|---|---|
Path to a trusted CA certificate file to verify the RavenDB server’s certificate. |
|
Path to a client certificate (PEM format) for secured communication. |
|
Whether to apply enable/disable operations cluster-wide. Choices:
|
|
Name of the database. Must be a valid name containing only letters, numbers, dashes, and underscores. |
|
Per-index configuration key/value pairs to reconcile. Keys and values are normalized to strings and compared against the current index definition’s configuration. If differences exist, the module updates the definition with the merged configuration. Default: |
|
Dictionary defining the index ( Required when creating a new index. When present for an existing index, differences are applied idempotently. |
|
Name of the index to create, delete, or modify. Must consist only of letters, numbers, dashes, and underscores. |
|
Operational mode to apply to an existing index (one of enable/disable/pause/resume/reset). If the index does not exist and only Choices:
|
|
Desired state of the index. If If If omitted ( If the index does not exist and only Choices:
|
|
URL of the RavenDB server. Must include the scheme (http or https), hostname, and port. |
Attributes
Attribute |
Support |
Description |
|---|---|---|
Support: full |
Can run in check_mode and return changed status prediction without modifying target. If not supported, the action will be skipped. |
Notes
Note
The role
ravendb.ravendb.ravendb_python_client_prerequisitesmust be applied before using this module.Requires the ASP.NET Core Runtime to be installed on the target system.
See Also
See also
- RavenDB documentation
Official RavenDB documentation
Examples
- name: Create a RavenDB index with map and reduce
ravendb.ravendb.index:
url: "http://{{ ansible_host }}:8080"
database_name: "my_database"
index_name: "UsersByName"
index_definition:
map:
- "from c in docs.Users select new { c.name, count = 5 }"
reduce: >
from result in results
group result by result.name
into g
select new
{
name = g.Key,
count = g.Sum(x => x.count)
}
state: present
- name: Create a RavenDB multi-map index
ravendb.ravendb.index:
url: "http://{{ ansible_host }}:8080"
database_name: "my_database"
index_name: "UsersAndOrdersByName"
index_definition:
map:
- "from c in docs.Users select new { Name = c.name, UserCount = 1, OrderCount = 0, TotalCount = 1 }"
- "from o in docs.Orders select new { Name = o.customer, UserCount = 0, OrderCount = 1, TotalCount = 1 }"
reduce: >
from result in results
group result by result.Name
into g
select new
{
Name = g.Key,
UserCount = g.Sum(x => x.UserCount),
OrderCount = g.Sum(x => x.OrderCount),
TotalCount = g.Sum(x => x.TotalCount)
}
state: present
- name: Reconcile per-index configuration (idempotent)
ravendb.ravendb.index:
url: "http://{{ ansible_host }}:8080"
database_name: "my_database"
index_name: "UsersByName"
index_configuration:
Indexing.MapBatchSize: "128"
- name: Disable a RavenDB index (cluster-wide)
ravendb.ravendb.index:
url: "http://{{ ansible_host }}:8080"
database_name: "my_database"
index_name: "Orders/ByCompany"
mode: disabled
cluster_wide: true
- name: Pause a RavenDB index (check mode)
ravendb.ravendb.index:
url: "http://{{ ansible_host }}:8080"
database_name: "my_database"
index_name: "Orders/ByCompany"
mode: paused
check_mode: yes
- name: Update an existing RavenDB index definition (idempotent update)
ravendb.ravendb.index:
url: "http://{{ ansible_host }}:8080"
database_name: "my_database"
index_name: "UsersByName"
index_definition:
map:
- "from c in docs.Users select new { c.name, count = 13 }"
reduce: >
from result in results
group result by result.name
into g
select new
{
name = g.Key,
count = g.Sum(x => x.count)
}
state: present
- name: Delete a RavenDB index
ravendb.ravendb.index:
url: "http://{{ ansible_host }}:8080"
database_name: "my_database"
index_name: "UsersByName"
state: absent
- name: Create index with rolling deployment
ravendb.ravendb.index:
url: "http://{{ ansible_host }}:8080"
database_name: "my_database"
index_name: "Orders/ByCompany"
state: present
index_definition:
map:
- "from o in docs.Orders select new { o.Company }"
deployment_mode: rolling
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
Indicates if any change was made (or would have been made in check mode). Returned: always Sample: |
|
Human-readable message describing the result or error. Returned: always Sample: |