Skip to content

Commit f45b8c7

Browse files
Addresses changes made to security demo config install tool (#233)
* Addresses changes made to security demo config install tool Signed-off-by: Darshit Chanpura <dchanp@amazon.com> * Fixes remainder admin occurences, adds version check for admin password determination and adds 2.12.0 to CI matrix Signed-off-by: Darshit Chanpura <dchanp@amazon.com> --------- Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
1 parent b80b528 commit f45b8c7

File tree

9 files changed

+37
-9
lines changed

9 files changed

+37
-9
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
strategy:
3535
matrix:
3636
logstash: [ "7.16.3", "7.17.1", "8.3.2", "8.12.1" ]
37-
opensearch: [ "1.3.4", "2.1.0" ]
37+
opensearch: [ "1.3.4", "2.1.0", "2.12.0" ]
3838
secure: [ true, false ]
3939

4040
name: Integration Test logstash-output-opensearch against OpenSearch

DEVELOPER_GUIDE.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,14 @@ Build the gem locally and install it using:
186186
## Configuration for Logstash Output OpenSearch Plugin
187187

188188
To run the Logstash Output Opensearch plugin, add following configuration in your logstash.conf file.
189+
Note: For logstash running with OpenSearch 2.12.0 and higher the admin password needs to be a custom strong password supplied during cluster setup.
189190

190191
```
191192
output {
192193
opensearch {
193194
hosts => ["hostname:port"]
194195
user => "admin"
195-
password => "admin"
196+
password => "<your-admin-password>"
196197
index => "logstash-logs-%{+YYYY.MM.dd}"
197198
}
198199
}

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ The logstash-output-opensearch plugin helps to ship events from Logstash to Open
3232
## Configuration for Logstash Output Opensearch Plugin
3333

3434
To run the Logstash Output Opensearch plugin, add following configuration in your logstash.conf file.
35+
Note: For logstash running with OpenSearch 2.12.0 and higher the admin password needs to be a custom strong password supplied during cluster setup.
36+
3537
```
3638
output {
3739
opensearch {
3840
hosts => ["hostname:port"]
3941
user => "admin"
40-
password => "admin"
42+
password => "<your-admin-password>"
4143
index => "logstash-logs-%{+YYYY.MM.dd}"
4244
}
4345
}
@@ -62,21 +64,24 @@ output {
6264
In addition to the existing authentication mechanisms, if we want to add new authentication then we will be adding them in the configuration by using auth_type.
6365

6466
Example Configuration for basic authentication:
67+
Note: For logstash running with OpenSearch 2.12.0 and higher the admin password needs to be a custom strong password supplied during cluster setup.
68+
6569
```
6670
output {
6771
opensearch {
6872
hosts => ["hostname:port"]
6973
auth_type => {
7074
type => 'basic'
7175
user => 'admin'
72-
password => 'admin'
76+
password => '<your-admin-password>'
7377
}
7478
index => "logstash-logs-%{+YYYY.MM.dd}"
7579
}
7680
}
7781
```
7882

7983
To ingest data into a `data stream` through logstash, we need to create the data stream and specify the name of data stream and the `op_type` of `create` in the output configuration. The sample configuration is shown below:
84+
Note: For logstash running with OpenSearch 2.12.0 and higher the admin password needs to be a custom strong password supplied during cluster setup.
8085

8186
```yml
8287
output {
@@ -85,7 +90,7 @@ output {
8590
auth_type => {
8691
type => 'basic'
8792
user => 'admin'
88-
password => 'admin'
93+
password => '<your-admin-password>'
8994
}
9095
index => "my-data-stream"
9196
action => "create"

release/docker/logstash-opensearch-sample.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ output {
1212
hosts => ["http://localhost:9200"]
1313
index => "%{[@metadata][beat]}-%{[@metadata][version]}-%{+YYYY.MM.dd}"
1414
#user => "admin"
15-
#password => "admin"
15+
#password => "<your-admin-password>"
1616
}
1717
}

scripts/logstash-run.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,16 @@ export PATH=$BUILD_DIR/gradle/bin:$PATH
66
SERVICE_URL="http://integration:9200"
77

88
if [[ "$SECURE_INTEGRATION" == "true" ]]; then
9-
SERVICE_URL="https://integration:9200 -k -u admin:admin"
9+
OPENSEARCH_REQUIRED_VERSION="2.12.0"
10+
# Starting in 2.12.0, security demo configuration script requires an initial admin password
11+
COMPARE_VERSION=`echo $OPENSEARCH_REQUIRED_VERSION $OPENSEARCH_VERSION | tr ' ' '\n' | sort -V | uniq | head -n 1`
12+
if [ -n "$OPENDISTRO_VERSION" ] || [ "$COMPARE_VERSION" != "$OPENSEARCH_REQUIRED_VERSION" ]; then
13+
CREDENTIAL="admin:admin"
14+
else
15+
CREDENTIAL="admin:myStrongPassword123!"
16+
fi
17+
18+
SERVICE_URL="https://integration:9200 -k -u $CREDENTIAL"
1019
fi
1120

1221
wait_for_es() {

scripts/opendistro/docker-compose.override.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ services:
77
environment:
88
- INTEGRATION=true
99
- SECURE_INTEGRATION=${SECURE_INTEGRATION:-false}
10+
- OPENDISTRO_VERSION=${OPENDISTRO_VERSION}
1011

1112
integration:
1213
build:

scripts/opensearch/docker-compose.override.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ services:
77
environment:
88
- INTEGRATION=true
99
- SECURE_INTEGRATION=${SECURE_INTEGRATION:-false}
10+
- OPENSEARCH_VERSION=${OPENSEARCH_VERSION:-latest}
1011

1112
integration:
1213
build:
@@ -19,6 +20,7 @@ services:
1920
environment:
2021
- discovery.type=single-node
2122
- bootstrap.memory_lock=true
23+
- OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123!
2224
ports:
2325
- "9200:9200"
2426
user: opensearch

spec/integration/outputs/index_spec.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
end
141141
describe "a secured indexer", :secure_integration => true do
142142
let(:user) { "admin" }
143-
let(:password) { "admin" }
143+
let(:password) { OpenSearchHelper.admin_password }
144144
let(:opensearch_url) {"https://integration:9200"}
145145
let(:config) do
146146
{
@@ -172,7 +172,8 @@
172172
:auth_type => {
173173
"type"=>"basic",
174174
"user" => "admin",
175-
"password" => "admin"}
175+
"password" => OpenSearchHelper.admin_password
176+
}
176177
} }
177178
let(:user) {options[:auth_type]["user"]}
178179
let(:password) {options[:auth_type]["password"]}

spec/opensearch_spec_helper.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ def self.check_version?(*requirement)
7272
end
7373
end
7474

75+
# set admin password based on version
76+
def self.admin_password
77+
if check_version?('< 2.12.0') || check_version?('> 7')
78+
"admin"
79+
else
80+
"myStrongPassword123!"
81+
end
82+
end
83+
7584
def clean(client)
7685
client.indices.delete_template(:name => "*")
7786
client.indices.delete_index_template(:name => "logstash*") rescue nil

0 commit comments

Comments
 (0)