Created
October 19, 2018 15:12
-
-
Save cdenneen/f4d912beb9033f570ed16300ecbd7903 to your computer and use it in GitHub Desktop.
ES testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# @summary | |
# elasticsearch profile | |
# | |
# @param es_instances | |
# @param instance_ports | |
# | |
class profile::elasticsearch( | |
Array[String] $es_instances = ['master', 'data'], | |
Array[Integer] $instance_ports = [9200, 9300, 9201, 9301], | |
) { | |
include java | |
include elasticsearch | |
include curator | |
$instance_ports.each |Integer $port| { | |
firewall { "100 - ES port ${port}": | |
action => 'accept', | |
proto => 'tcp', | |
dport => $port, | |
} | |
} | |
$instances = lookup('profile::elasticsearch::instances', Hash, 'deep', { $es_instances => {} }) | |
$instances.each |String $instance, Hash $instance_hash| { | |
elasticsearch::instance { $instance: | |
* => $instance_hash, | |
} | |
} | |
$templates = lookup('profile::elasticsearch::templates', Hash, 'deep', {}) | |
$templates.each |String $template, Hash $template_hash| { | |
elasticsearch::template { $template: | |
* => $template_hash, | |
} | |
} | |
$plugins = lookup('profile::elasticsearch::plugins', Hash, 'deep', {}) | |
$plugins.each |String $plugin, Hash $plugin_hash| { | |
elasticsearch::plugin { $plugin: | |
* => $plugin_hash, | |
} | |
} | |
$users = lookup('profile::elasticsearch::users', Hash, 'deep', {}) | |
$users.each |String $user, Hash $user_hash| { | |
elasticsearch::user { $user: | |
* => $user_hash, | |
} | |
} | |
$roles = lookup('profile::elasticsearch::roles', Hash, 'deep', {}) | |
$roles.each |String $role, Hash $role_hash| { | |
elasticsearch::role { $role: | |
* => $role_hash, | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe 'profile::elasticsearch' do | |
on_supported_os( | |
supported_os: [ | |
{ | |
'operatingsystem' => 'CentOS', | |
'operatingsystemrelease' => [ | |
'7', | |
], | |
}, | |
], | |
).each do |os, facts| | |
context "on #{os}" do | |
let(:facts) do | |
facts.merge( | |
puppetversion: Puppet.version, | |
node_type: 'fast', | |
rack_id: 'rack_num_1', | |
role: 'es_data_master', | |
) | |
end | |
# This setup is to work-around the Elasticsearch Template custom type as seen | |
# here: https://github.com/elastic/puppet-elasticsearch/blob/ | |
# eef10e8ac99d9295c4297234b684471bdad42014/lib/puppet/type/ | |
# elasticsearch_template.rb#L90-L109 | |
# | |
# where this custom type retrieves content from Puppet's FileServing | |
# indirection. | |
# | |
class Fake | |
def content | |
File.read('./site/modules/profile/files/logstash/logstash.json') | |
end | |
end | |
before(:each) do | |
allow(Puppet::FileServing::Metadata.indirection).to receive(:find). | |
and_call_original | |
allow(Puppet::FileServing::Metadata.indirection).to receive(:find). | |
with('puppet:///modules/profile/logstash/logstash.json').and_return(true) | |
allow(Puppet::FileServing::Content.indirection).to receive(:find). | |
and_call_original | |
allow(Puppet::FileServing::Content.indirection).to receive(:find). | |
with( | |
'puppet:///modules/profile/logstash/logstash.json', | |
hash_including(environment: instance_of(Puppet::Node::Environment)) | |
).and_return(Fake.new) | |
end | |
%w[profile::elasticsearch].each do |puppet_class| | |
it { is_expected.to contain_class(puppet_class) } | |
end | |
it { is_expected.to compile.with_all_deps } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment