You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Chef InSpec Elasticsearch resources allow you to audit and test the configuration, status, and security of Elasticsearch clusters.
19
+
20
+
## Support
21
+
22
+
The InSpec Elasticsearch resources were originally included as part of InSpec core through version 6. Starting with InSpec 7, they are distributed separately as a Ruby gem.
23
+
24
+
## Usage
25
+
26
+
To use these resources in an InSpec profile, add the `inspec-elasticsearch-resources` gem as a dependency in your `inspec.yml` file:
27
+
28
+
```yaml
29
+
depends:
30
+
- name: inspec-elasticsearch-resources
31
+
gem: inspec-elasticsearch-resources
32
+
```
33
+
34
+
## Elasticsearch resources
35
+
36
+
{{< inspec_resources_filter >}}
37
+
38
+
The following Chef InSpec Elasticsearch resources are available in this resource pack.
This resource first became available in v1.43.5 of InSpec.
28
-
29
16
## Syntax
30
17
31
-
describe elasticsearch do
32
-
its('property') { should cmp 'value' }
33
-
end
18
+
```ruby
19
+
describe elasticsearch do
20
+
its('property') { should cmp 'value' }
21
+
end
22
+
```
34
23
35
-
## Supported Resource Parameters
24
+
## Parameters
36
25
37
26
The `elasticsearch` resource accepts several optional resource parameters:
38
27
@@ -50,19 +39,25 @@ The `elasticsearch` resource accepts several optional resource parameters:
50
39
51
40
In addition, the `elasticsearch` resource allows for filtering the nodes returned by property before executing the tests:
52
41
53
-
describe elasticsearch.where { node_name == 'one-off-node' } do
54
-
its('version') { should eq '1.2.3' }
55
-
end
42
+
```ruby
43
+
describe elasticsearch.where { node_name =='one-off-node' } do
44
+
its('version') { should eq '1.2.3' }
45
+
end
46
+
```
56
47
57
-
describe elasticsearch.where { process.mlockall == false } do
58
-
its('count') { should cmp 0 }
59
-
end
48
+
```ruby
49
+
describe elasticsearch.where { process.mlockall ==false } do
50
+
its('count') { should cmp 0 }
51
+
end
52
+
```
60
53
61
54
To simply check if nodes exist that match the criteria, use the `exist` matcher:
62
55
63
-
describe elasticsearch.where { cluster_name == 'my_cluster' } do
64
-
it { should exist }
65
-
end
56
+
```ruby
57
+
describe elasticsearch.where { cluster_name =='my_cluster' } do
58
+
it { should exist }
59
+
end
60
+
```
66
61
67
62
## Properties
68
63
@@ -74,150 +69,196 @@ Since the `elasticsearch` resource is meant for use on a cluster, each property
74
69
75
70
The `build hash` property returns the build hash for each of the nodes.
76
71
77
-
its('build_hash') { should cmp 'b2f0c09' }
72
+
```ruby
73
+
its('build_hash') { should cmp 'b2f0c09' }
74
+
```
78
75
79
76
### cluster_name
80
77
81
78
The `cluster_name` property returns the cluster names of each of the nodes.
82
79
83
-
its('cluster_name') { should cmp 'my_cluster' }
80
+
```ruby
81
+
its('cluster_name') { should cmp 'my_cluster' }
82
+
```
84
83
85
84
### host
86
85
87
86
The `host` property returns the hostname of each of the nodes. This may return an IP address if the node is improperly performing DNS resolution or has no hostname set.
88
87
89
-
its('host') { should cmp 'my.hostname.mycompany.biz' }
88
+
```ruby
89
+
its('host') { should cmp 'my.hostname.mycompany.biz' }
90
+
```
90
91
91
92
### http
92
93
93
94
The `http` property returns a hash of HTTP-related settings for each of the nodes. In this example, the `first` method is used to grab only the first node's HTTP-related info and is a way of removing the item from the Array if only one node is being queried.
94
95
95
-
its('http.first.max_content_length_in_bytes') { should cmp 123456 }
96
+
```ruby
97
+
its('http.first.max_content_length_in_bytes') { should cmp 123456 }
98
+
```
96
99
97
100
### ingest
98
101
99
102
The `ingest` property returns ingest-related settings and capabilities, such as available processors.
100
103
101
-
its('ingest.first.processors.count') { should be >= 1 }
104
+
```ruby
105
+
its('ingest.first.processors.count') { should be >=1 }
106
+
```
102
107
103
108
### ip
104
109
105
110
The `ip` property returns the IP address of each of the nodes.
106
111
107
-
its('ip') { should cmp '192.168.1.100' }
112
+
```ruby
113
+
its('ip') { should cmp '192.168.1.100' }
114
+
```
108
115
109
116
### jvm
110
117
111
118
The `jvm` property returns Java Virtual Machine related parameters for each of the nodes.
112
119
113
-
its('jvm.first.version') { should cmp '1.8.0_141' }
120
+
```ruby
121
+
its('jvm.first.version') { should cmp '1.8.0_141' }
122
+
```
114
123
115
124
### module_list
116
125
117
126
The `module_list` property returns a list of enabled modules for each node in the cluster.
118
127
119
-
its('module_list.first') { should include 'my_module' }
128
+
```ruby
129
+
its('module_list.first') { should include'my_module' }
130
+
```
120
131
121
132
### modules
122
133
123
134
The `modules` property returns detailed information about each enabled module for each node in the cluster.
124
135
125
-
its('modules.first') { should include 'lang-groovy' }
136
+
```ruby
137
+
its('modules.first') { should include'lang-groovy' }
138
+
```
126
139
127
140
### node_name
128
141
129
142
The `node_name` property returns the node name for each node in the cluster.
130
143
131
-
its('node_name') { should cmp 'node1' }
144
+
```ruby
145
+
its('node_name') { should cmp 'node1' }
146
+
```
132
147
133
148
### node_id
134
149
135
150
The `node_id` property returns the node IDs of each of the nodes in the cluster.
136
151
137
-
its('node_id') { should include 'my_node_id' }
152
+
```ruby
153
+
its('node_id') { should include'my_node_id' }
154
+
```
138
155
139
156
### os
140
157
141
158
The `os` property returns OS-related information about each node in the cluster.
142
159
143
-
its('os.first.arch') { should cmp 'amd64' }
160
+
```ruby
161
+
its('os.first.arch') { should cmp 'amd64' }
162
+
```
144
163
145
164
### plugin_list
146
165
147
166
The `plugin_list` property returns a list of enabled plugins for each node in the cluster. For more additional information about each plugin, use the `plugins` property.
148
167
149
-
its('plugin_list.first') { should include 'my_plugin' }
168
+
```ruby
169
+
its('plugin_list.first') { should include'my_plugin' }
170
+
```
150
171
151
172
### plugins
152
173
153
174
The `plugins` property returns detailed information about each enabled plugin for each node in the cluster.
154
175
155
-
its('plugins.first') { should include 'my_plugin' }
176
+
```ruby
177
+
its('plugins.first') { should include'my_plugin' }
178
+
```
156
179
157
180
### process
158
181
159
182
The `process` property returns process information for each node in the cluster, such as the process ID.
160
183
161
-
its('process.first.mlockall') { should cmp true }
184
+
```ruby
185
+
its('process.first.mlockall') { should cmp true }
186
+
```
162
187
163
188
### roles
164
189
165
190
The `roles` property returns the role for each of the nodes in the cluster.
166
191
167
-
its('roles') { should include 'master' }
192
+
```ruby
193
+
its('roles') { should include'master' }
194
+
```
168
195
169
196
### settings
170
197
171
198
The `settings` property returns all the configuration settings for each node in the cluster. These settings usually include those set in the elasticsearch.yml as well as those set via `-Des.` or `-E` flags at startup. Use the `inspec shell` to explore the various setting keys that are available.
172
199
173
-
its('settings.first.path.home') { should cmp '/usr/share/elasticsearch' }
200
+
```ruby
201
+
its('settings.first.path.home') { should cmp '/usr/share/elasticsearch' }
202
+
```
174
203
175
204
### total_indexing_buffer
176
205
177
206
The `total_indexing_buffer` property returns the total indexing buffer for each node in the cluster.
178
207
179
-
its('total_indexing_buffer') { should cmp 123456 }
208
+
```ruby
209
+
its('total_indexing_buffer') { should cmp 123456 }
210
+
```
180
211
181
212
### transport
182
213
183
214
The `transport` property returns transport-related settings for each node in the cluster, such as the bound and published addresses.
184
215
185
-
its('transport.first.bound_address') { should cmp '1.2.3.4:9200' }
216
+
```ruby
217
+
its('transport.first.bound_address') { should cmp '1.2.3.4:9200' }
218
+
```
186
219
187
220
### transport_address
188
221
189
222
The `transport_address` property returns the bound transport address for each node in the cluster.
190
223
191
-
its('transport_address') { should cmp '1.2.3.4:9200' }
224
+
```ruby
225
+
its('transport_address') { should cmp '1.2.3.4:9200' }
226
+
```
192
227
193
228
### version
194
229
195
230
The `version` property returns the version of Elasticsearch running on each node of the cluster.
196
231
197
-
its('version') { should cmp '5.5.2' }
232
+
```ruby
233
+
its('version') { should cmp '5.5.2' }
234
+
```
198
235
199
236
## Examples
200
237
201
-
### Test to verify the specific module. Uses additional Ruby to find a specific module and assert a value. For a succinct list of the names of each of the modules enabled, use the `module_list` property.
238
+
This example demonstrates how to test a specific Elasticsearch module by using Ruby code to locate the module and verify its properties. This approach uses the `modules` property to get detailed module information, while the `module_list` property can be used for a simple list of enabled module names:
### Tests to verify the specific plugin. Uses additional Ruby to find a specific plugin and assert a value. For a succinct list of the names of each of the plugins enabled, use the `plugin_list` property.
250
+
This example shows how to verify the properties of a specific Elasticsearch plugin. Similar to modules, you can use the `plugins` property for detailed plugin information, or the `plugin_list` property for a simple list of enabled plugin names:
0 commit comments