Skip to content

Commit f444af6

Browse files
authored
Merge pull request #13 from inspec/im/reorganize_resource_docs
Reorganize elasticsearch resource docs
2 parents 8fac04b + ee41e1b commit f444af6

File tree

4 files changed

+151
-65
lines changed

4 files changed

+151
-65
lines changed

docs-chef-io/content/_index.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
+++
2+
title = "About the Chef InSpec Elasticsearch resource pack"
3+
draft = false
4+
linkTitle = "Elasticsearch resource pack"
5+
summary = "Chef InSpec resources for auditing Elasticsearch."
6+
7+
[cascade]
8+
[cascade.params]
9+
platform = "elasticsearch"
10+
11+
[menu.elasticsearch]
12+
title = "About Elasticsearch resources"
13+
identifier = "inspec/resources/elasticsearch/about"
14+
parent = "inspec/resources/elasticsearch"
15+
weight = 10
16+
+++
17+
18+
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.
39+
40+
{{< inspec_resources section="elasticsearch" platform="elasticsearch" >}}
Lines changed: 106 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,27 @@
11
+++
22
title = "elasticsearch resource"
33
draft = false
4-
gh_repo = "inspec"
5-
platform = "linux"
64

7-
[menu]
8-
[menu.inspec]
5+
[menu.elasticsearch]
96
title = "elasticsearch"
10-
identifier = "inspec/resources/os/elasticsearch.md elasticsearch resource"
11-
parent = "inspec/resources/os"
7+
identifier = "inspec/resources/elasticsearch/elasticsearch.md elasticsearch resource"
8+
parent = "inspec/resources/elasticsearch"
129
+++
1310

1411
Use the `elasticsearch` resource to test the status of a node against a running
1512
Elasticsearch cluster. Chef InSpec retrieves the node list from the cluster node URL
1613
provided (defaults to `http://localhost:9200`) and provides the ability to query
1714
a variety of settings and statuses.
1815

19-
## Availability
20-
21-
### Install
22-
23-
{{< readfile file="content/inspec/reusable/md/inspec_installation.md" >}}
24-
25-
### Version
26-
27-
This resource first became available in v1.43.5 of InSpec.
28-
2916
## Syntax
3017

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+
```
3423

35-
## Supported Resource Parameters
24+
## Parameters
3625

3726
The `elasticsearch` resource accepts several optional resource parameters:
3827

@@ -50,19 +39,25 @@ The `elasticsearch` resource accepts several optional resource parameters:
5039

5140
In addition, the `elasticsearch` resource allows for filtering the nodes returned by property before executing the tests:
5241

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+
```
5647

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+
```
6053

6154
To simply check if nodes exist that match the criteria, use the `exist` matcher:
6255

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+
```
6661

6762
## Properties
6863

@@ -74,150 +69,196 @@ Since the `elasticsearch` resource is meant for use on a cluster, each property
7469

7570
The `build hash` property returns the build hash for each of the nodes.
7671

77-
its('build_hash') { should cmp 'b2f0c09' }
72+
```ruby
73+
its('build_hash') { should cmp 'b2f0c09' }
74+
```
7875

7976
### cluster_name
8077

8178
The `cluster_name` property returns the cluster names of each of the nodes.
8279

83-
its('cluster_name') { should cmp 'my_cluster' }
80+
```ruby
81+
its('cluster_name') { should cmp 'my_cluster' }
82+
```
8483

8584
### host
8685

8786
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.
8887

89-
its('host') { should cmp 'my.hostname.mycompany.biz' }
88+
```ruby
89+
its('host') { should cmp 'my.hostname.mycompany.biz' }
90+
```
9091

9192
### http
9293

9394
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.
9495

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+
```
9699

97100
### ingest
98101

99102
The `ingest` property returns ingest-related settings and capabilities, such as available processors.
100103

101-
its('ingest.first.processors.count') { should be >= 1 }
104+
```ruby
105+
its('ingest.first.processors.count') { should be >= 1 }
106+
```
102107

103108
### ip
104109

105110
The `ip` property returns the IP address of each of the nodes.
106111

107-
its('ip') { should cmp '192.168.1.100' }
112+
```ruby
113+
its('ip') { should cmp '192.168.1.100' }
114+
```
108115

109116
### jvm
110117

111118
The `jvm` property returns Java Virtual Machine related parameters for each of the nodes.
112119

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+
```
114123

115124
### module_list
116125

117126
The `module_list` property returns a list of enabled modules for each node in the cluster.
118127

119-
its('module_list.first') { should include 'my_module' }
128+
```ruby
129+
its('module_list.first') { should include 'my_module' }
130+
```
120131

121132
### modules
122133

123134
The `modules` property returns detailed information about each enabled module for each node in the cluster.
124135

125-
its('modules.first') { should include 'lang-groovy' }
136+
```ruby
137+
its('modules.first') { should include 'lang-groovy' }
138+
```
126139

127140
### node_name
128141

129142
The `node_name` property returns the node name for each node in the cluster.
130143

131-
its('node_name') { should cmp 'node1' }
144+
```ruby
145+
its('node_name') { should cmp 'node1' }
146+
```
132147

133148
### node_id
134149

135150
The `node_id` property returns the node IDs of each of the nodes in the cluster.
136151

137-
its('node_id') { should include 'my_node_id' }
152+
```ruby
153+
its('node_id') { should include 'my_node_id' }
154+
```
138155

139156
### os
140157

141158
The `os` property returns OS-related information about each node in the cluster.
142159

143-
its('os.first.arch') { should cmp 'amd64' }
160+
```ruby
161+
its('os.first.arch') { should cmp 'amd64' }
162+
```
144163

145164
### plugin_list
146165

147166
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.
148167

149-
its('plugin_list.first') { should include 'my_plugin' }
168+
```ruby
169+
its('plugin_list.first') { should include 'my_plugin' }
170+
```
150171

151172
### plugins
152173

153174
The `plugins` property returns detailed information about each enabled plugin for each node in the cluster.
154175

155-
its('plugins.first') { should include 'my_plugin' }
176+
```ruby
177+
its('plugins.first') { should include 'my_plugin' }
178+
```
156179

157180
### process
158181

159182
The `process` property returns process information for each node in the cluster, such as the process ID.
160183

161-
its('process.first.mlockall') { should cmp true }
184+
```ruby
185+
its('process.first.mlockall') { should cmp true }
186+
```
162187

163188
### roles
164189

165190
The `roles` property returns the role for each of the nodes in the cluster.
166191

167-
its('roles') { should include 'master' }
192+
```ruby
193+
its('roles') { should include 'master' }
194+
```
168195

169196
### settings
170197

171198
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.
172199

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+
```
174203

175204
### total_indexing_buffer
176205

177206
The `total_indexing_buffer` property returns the total indexing buffer for each node in the cluster.
178207

179-
its('total_indexing_buffer') { should cmp 123456 }
208+
```ruby
209+
its('total_indexing_buffer') { should cmp 123456 }
210+
```
180211

181212
### transport
182213

183214
The `transport` property returns transport-related settings for each node in the cluster, such as the bound and published addresses.
184215

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+
```
186219

187220
### transport_address
188221

189222
The `transport_address` property returns the bound transport address for each node in the cluster.
190223

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+
```
192227

193228
### version
194229

195230
The `version` property returns the version of Elasticsearch running on each node of the cluster.
196231

197-
its('version') { should cmp '5.5.2' }
232+
```ruby
233+
its('version') { should cmp '5.5.2' }
234+
```
198235

199236
## Examples
200237

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:
202239

203-
modules = elasticsearch.modules.first
204-
lang_groovy_module = modules.find { |mod| mod.name == 'lang-groovy' }
240+
```ruby
241+
modules = elasticsearch.modules.first
242+
lang_groovy_module = modules.find { |mod| mod.name == 'lang-groovy' }
205243

206-
describe 'lang-groovy module version' do
207-
subject { lang_groovy_module }
208-
its('version') { should cmp '5.5.2' }
209-
end
244+
describe 'lang-groovy module version' do
245+
subject { lang_groovy_module }
246+
its('version') { should cmp '5.5.2' }
247+
end
248+
```
210249

211-
### 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:
212251

213-
plugins = elasticsearch.plugins.first
214-
my_plugin = plugins.find { |plugin| plugin.name == 'my_plugin' }
252+
```ruby
253+
plugins = elasticsearch.plugins.first
254+
my_plugin = plugins.find { |plugin| plugin.name == 'my_plugin' }
215255

216-
describe 'my_plugin plugin version' do
217-
subject { my_plugin }
218-
its('version') { should cmp '1.2.3' }
219-
end
256+
describe 'my_plugin plugin version' do
257+
subject { my_plugin }
258+
its('version') { should cmp '1.2.3' }
259+
end
260+
```
220261

221262
## Matchers
222263

223-
{{< readfile file="content/inspec/reusable/md/inspec_matchers_link.md" >}}
264+
{{< readfile file="content/reusable/md/inspec_matchers_link.md" >}}

docs-chef-io/go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/inspec/inspec-elasticsearch-resources/docs-chef-io
2+
3+
go 1.17

docs-chef-io/hugo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# [params.inspec-elasticsearch-resources]
2+
# gh_path = "https://github.com/inspec/inspec-elasticsearch-resources/tree/main/docs-chef-io/content/"

0 commit comments

Comments
 (0)