Skip to content

Commit 6c3581c

Browse files
committed
QAG-65: fix: Fix DDEV Elasticsearch plugin configuration and installation
- Implement automatic Elasticsearch plugin installation script - Replace broken manual plugin installation with environment variable configuration - Add proper restart handling for newly installed plugins - Update documentation with Elasticsearch configuration details - Update elasticsearch8.yml configuration comments Refs: .ddev/elasticsearch/, README.md
1 parent 01ac70a commit 6c3581c

File tree

6 files changed

+76
-14
lines changed

6 files changed

+76
-14
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: elasticsearch
22
repository: ddev/ddev-elasticsearch
33
version: v0.3.2
4-
install_date: "2024-08-13T10:51:11+03:00"
4+
install_date: "2025-03-21T10:53:19+02:00"
55
project_files:
6-
- elasticsearch/config/elasticsearch8.yml
6+
- elasticsearch/
77
- docker-compose.elasticsearch8.yaml
88
global_files: []
99
removal_actions: []

.ddev/config.yaml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,10 @@ hooks:
3333
post-start:
3434
- exec: "composer install"
3535
- exec: "npm ci"
36-
- exec: |
37-
plugins=(analysis-icu)
38-
for plugin in "${plugins[@]}"; do
39-
if ! elasticsearch-plugin list | grep -q "^$plugin\b"; then
40-
elasticsearch-plugin install "$plugin"
41-
else
42-
echo "Plugin $plugin is already installed"
43-
fi
44-
done
45-
service: elasticsearch
36+
- exec-host: "ddev exec -s elasticsearch /mnt/ddev_config/elasticsearch/elasticsearch-setup.sh"
37+
- exec-host: |
38+
if [ -f /tmp/elasticsearch_needs_restart ]; then
39+
echo "Restarting Elasticsearch to apply plugin changes..."
40+
ddev restart elasticsearch
41+
rm /tmp/elasticsearch_needs_restart
42+
fi

.ddev/docker-compose.elasticsearch8.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ services:
1414
- VIRTUAL_HOST=$DDEV_HOSTNAME
1515
- HTTP_EXPOSE=9200:9200
1616
- HTTPS_EXPOSE=9201:9200
17+
- ELASTICSEARCH_PLUGINS=analysis-icu
1718
labels:
1819
com.ddev.site-name: ${DDEV_SITENAME}
1920
com.ddev.approot: $DDEV_APPROOT

.ddev/elasticsearch/config/elasticsearch8.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#ddev-generated
21
# This file contains the configuration settings for Elasticsearch 8.
32
# For more information, see https://www.elastic.co/guide/en/elasticsearch/reference/current/settings.html
43

@@ -8,7 +7,8 @@ cluster.name: "docker-cluster"
87
# https://www.elastic.co/guide/en/elasticsearch/reference/current/important-settings.html#network.host
98
network.host: 0.0.0.0
109

11-
# Security settings
10+
# Disable security features
11+
# https://www.elastic.co/guide/en/elasticsearch/reference/current/security-settings.html#general-security-settings
1212
xpack.security.enabled: false
1313
xpack.security.autoconfiguration.enabled: false
1414
xpack.security.enrollment.enabled: false
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
# Exit if no plugins specified
4+
[ -z "$ELASTICSEARCH_PLUGINS" ] && echo "No plugins specified in ELASTICSEARCH_PLUGINS" && exit 0
5+
6+
echo "Installing Elasticsearch plugins: $ELASTICSEARCH_PLUGINS"
7+
needs_restart=false
8+
9+
# Process each plugin
10+
for plugin in $ELASTICSEARCH_PLUGINS; do
11+
# Skip if already installed
12+
if bin/elasticsearch-plugin list | grep -q "$plugin"; then
13+
echo "✓ Plugin $plugin already installed"
14+
continue
15+
fi
16+
17+
# Install plugin
18+
echo "Installing $plugin plugin..."
19+
bin/elasticsearch-plugin install "$plugin" && \
20+
chown -R elasticsearch:root "/usr/share/elasticsearch/plugins/$plugin" && \
21+
chmod -R 755 "/usr/share/elasticsearch/plugins/$plugin" && \
22+
echo "✓ Plugin $plugin installed successfully" && \
23+
needs_restart=true
24+
done
25+
26+
# Signal for restart if needed
27+
[ "$needs_restart" = true ] && echo "New plugins were installed. Elasticsearch needs to be restarted." && touch /tmp/elasticsearch_needs_restart
28+
29+
exit 0

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,41 @@ For a complete list of all available services, URLs, and ports, use:
121121
- `ddev xdebug <mode>` - Configure Xdebug debugging modes
122122
- `ddev syncdb [environment]` - Sync database from remote environment (requires VPN and `ddev auth ssh`, see `scripts/syncdb.sh` for details)
123123

124+
<details>
125+
<summary>DDEV Elasticsearch configuration</summary>
126+
127+
#### DDEV Elasticsearch configuration
128+
129+
This project includes Elasticsearch with the `analysis-icu` plugin for Unicode/multilingual text processing support.
130+
131+
**Configuration and customization:**
132+
133+
Plugins are defined in `.ddev/docker-compose.elasticsearch8.yaml` as environment variables. You can install multiple plugins by adding them as space-separated values:
134+
135+
```yaml
136+
services:
137+
elasticsearch:
138+
environment:
139+
- ELASTICSEARCH_PLUGINS=analysis-icu analysis-ukrainian
140+
```
141+
142+
The installation process:
143+
1. Plugin names are defined as space-separated values
144+
2. A post-start hook installs missing plugins and sets permissions
145+
3. Elasticsearch restarts automatically if needed
146+
147+
**Useful commands:**
148+
149+
```bash
150+
# List installed plugins
151+
ddev exec -s elasticsearch "bin/elasticsearch-plugin list"
152+
153+
# View detailed plugin information
154+
ddev exec -s elasticsearch "curl -s localhost:9200/_nodes/plugins?pretty"
155+
```
156+
157+
</details>
158+
124159
<details>
125160
<summary>Lando environment</summary>
126161

0 commit comments

Comments
 (0)