Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

Commit

Permalink
Added rspec tests for multisite clustering
Browse files Browse the repository at this point in the history
  • Loading branch information
jorritfolmer committed Feb 11, 2017
1 parent 9066018 commit 43a48f5
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 12 deletions.
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ env:
- PUPPET_GEM_VERSION=2.7.14
- PUPPET_GEM_VERSION=3.8.5
- PUPPET_GEM_VERSION=4.6.2
- PUPPET_GEM_VERSION=4.9.2
matrix:
fast_finish: true
notifications:
Expand All @@ -17,7 +18,13 @@ matrix:
exclude:
- rvm: 1.8.7
env: PUPPET_GEM_VERSION=4.6.2
- rvm: 1.8.7
env: PUPPET_GEM_VERSION=4.9.2
- rvm: 1.9.3
env: PUPPET_GEM_VERSION=4.9.2
- rvm: 2.0.0
env: PUPPET_GEM_VERSION=2.7.14
- rvm: 2.0.0
env: PUPPET_GEM_VERSION=4.9.2
- rvm: 2.1
env: PUPPET_GEM_VERSION=2.7.14
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This Puppet module can be used to create and arrange Splunk instances into simpl
## Principles

1. **Splunk above Puppet.** Puppet is only used to configure the running skeleton of a Splunk constellation. It tries to keep away from Splunk administration as much as possible. For example, why deploy Splunk apps to forwarders through Puppet if you can use Splunk's multi-platform deployment server?
2. **Power to the Splunkers.** A Splunk installation should typically not be administered by the IT or IT-infra teams. This Puppet module should smooth the path to implementing segregation of duties between administrators and watch(wo)men.
2. **Power to the Splunkers.** A Splunk installation should typically not be administered by the IT or IT-infra teams. This Puppet module should smooth the path to implementing segregation of duties between administrators and watch(wo)men (ISO 27002 12.4.3 or BIR 10.10.3).
3. **Secure by default**.
- Splunk runs as user splunk instead of root.
- No services are listening by default except the bare minimum (8089/tcp)
Expand Down Expand Up @@ -662,6 +662,17 @@ node 'splunk-idx2.internal.corp.tld',
- `search_factor`
- `cm` (points to cluster master in case of searchhead or slave)

For multisite indexer clustering:

- `thissite` (assigns this node to a site, value can be site1..site63. `site` is a reserved word in Puppet 4.x hence the choice for `thissite`)

For cluster masters of multisite indexer clusters:

- `available_sites` (e.g. 'site1,site2')
- `site_replication_factor` (e.g. 'origin:1, total:2')
- `site_search_factor` (e.g. 'origin:1, total:2')


#### `shclustering`

Optional. Used to configure Splunk search head clustering. This is a hash with 4 members:
Expand Down
9 changes: 6 additions & 3 deletions manifests/server/clustering.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
'master': {
$replication_factor = $clustering[replication_factor]
$search_factor = $clustering[search_factor]
$site = $clustering[site]
# site is a reserved word in Puppet 4.x, switching to thissite
$thissite = $clustering[thissite]
$multisite = $clustering[multisite]
$available_sites = $clustering[available_sites]
$site_replication_factor = $clustering[site_replication_factor]
Expand Down Expand Up @@ -63,7 +64,8 @@
}
'slave': {
$cm = $clustering[cm]
$site = $clustering[site]
# site is a reserved word in Puppet 4.x, switching to thissite
$thissite = $clustering[thissite]
file { [
"${splunk_home}/etc/apps/${splunk_app_name}_master_base",
"${splunk_home}/etc/apps/${splunk_app_name}_searchhead_base", ]:
Expand Down Expand Up @@ -102,7 +104,8 @@
}
'searchhead': {
$cm = $clustering[cm]
$site = $clustering[site]
# site is a reserved word in Puppet 4.x, switching to thissite
$thissite = $clustering[thissite]
file { [
"${splunk_home}/etc/apps/${splunk_app_name}_master_base",
"${splunk_home}/etc/apps/${splunk_app_name}_slave_base", ]:
Expand Down
15 changes: 15 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,19 @@
it { should contain_file('/opt/splunk/etc/apps/puppet_search_shcluster_pass4symmkey_base/local/server.conf').with_content(/pass4SymmKey = SHCsecret/) }
end

context 'with multisite indexer clustering' do
let(:params) {
{
:clustering => { 'mode' => 'master', 'thissite' => 'site1', 'available_sites' => 'site1,site2', 'site_replication_factor' => 'origin:1, total:2', 'site_search_factor' => 'origin:1, total:2'},
:admin => { 'hash' => 'zzzz', 'fn' => 'yyyy', 'email' => 'wwww', },
:dontruncmds => true,
}
}
it { should contain_class('splunk::installed') }
it { should contain_package('splunk') }
it { should contain_file('/opt/splunk/etc/apps/puppet_indexer_cluster_master_base/local/server.conf').with_content(/multisite = true/) }
it { should contain_file('/opt/splunk/etc/apps/puppet_indexer_cluster_master_base/local/server.conf').with_content(/available_sites = site1,site2/) }
it { should contain_file('/opt/splunk/etc/apps/puppet_indexer_cluster_master_base/local/server.conf').with_content(/\[general\]\nsite = site1/) }
end

end
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<% if @site != nil -%>
<% if @thissite != nil -%>
[general]
site = <%= @site %>
site = <%= @thissite %>
<% end -%>

[clustering]
<% if @site != nil -%>
<% if @thissite != nil -%>
multisite = true
available_sites = <%= @available_sites %>
site_replication_factor = <%= @site_replication_factor %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<% if @site != nil -%>
<% if @thissite != nil -%>
[general]
site = <%= @site %>
site = <%= @thissite %>
<% end -%>

[clustering]
<% if @site != nil -%>
<% if @thissite != nil -%>
multisite = true
<% end -%>
mode = searchhead
Expand Down
4 changes: 2 additions & 2 deletions templates/puppet_indexer_cluster_slave_base/local/server.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% if @site != nil -%>
<% if @thissite != nil -%>
[general]
site = <%= @site %>
site = <%= @thissite %>

<% end -%>
[clustering]
Expand Down

0 comments on commit 43a48f5

Please sign in to comment.