Skip to content

Commit

Permalink
move elastic search libs to a local namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
cristifalcas committed Jan 13, 2017
1 parent 2b9579c commit a82ade6
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Bundler.require(:rake)
require 'rake/clean'

CLEAN.include('spec/fixtures/', 'doc', 'pkg')
CLEAN.include('lib/puppet_x/elastic/', '*')
CLEAN.include('lib/puppet_x/prometheus/', '*')
CLOBBER.include('.tmp', '.librarian')

require 'puppetlabs_spec_helper/rake_tasks'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Puppet_X
module Elastic
module Prometheus
# This ugly hack is required due to the fact Puppet passes in the
# puppet-native hash with stringified numerics, which causes the
# decoded JSON from the Elasticsearch API to be seen as out-of-sync
Expand Down
10 changes: 5 additions & 5 deletions lib/puppet_x/elastic/hash.rb → lib/puppet_x/prometheus/hash.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Puppet_X
module Elastic
module Prometheus
module SortedHash

# Upon extension, modify the hash appropriately to render
Expand All @@ -15,11 +15,11 @@ def self.extended(base)
base.clear
tmp.each do |key, val|
if val.is_a? base.class
val.extend Puppet_X::Elastic::SortedHash
val.extend Puppet_X::Prometheus::SortedHash
elsif val.is_a? Array
val.map do |elem|
if elem.is_a? base.class
elem.extend(Puppet_X::Elastic::SortedHash)
elem.extend(Puppet_X::Prometheus::SortedHash)
else
elem
end
Expand All @@ -40,11 +40,11 @@ def self.extended(base)
# problems with .class/.is_a?
base.merge! base do |_, ov, nv|
if ov.respond_to? :each_pair
ov.extend Puppet_X::Elastic::SortedHash
ov.extend Puppet_X::Prometheus::SortedHash
elsif ov.is_a? Array
ov.map do |elem|
if elem.respond_to? :each_pair
elem.extend Puppet_X::Elastic::SortedHash
elem.extend Puppet_X::Prometheus::SortedHash
else
elem
end
Expand Down
4 changes: 0 additions & 4 deletions manifests/alertmanager.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
# [*config_dir*]
# alert_manager configuration directory (default /etc/prometheus)
#
# [*purge_config_dir*]
# Purge config files no longer generated by Puppet
#
# [*manage_as*]
# How to manage the distribution service. Valid values are: service, container (default service)
#
Expand Down Expand Up @@ -67,7 +64,6 @@
$package_name = $::prometheus::alertmanager::params::package_name,
$package_ensure = $::prometheus::alertmanager::params::package_ensure,
$service_name = $::prometheus::alertmanager::params::service_name,
$purge_config_dir = $::prometheus::alertmanager::params::purge_config_dir,
$config_dir = $::prometheus::alertmanager::params::config_dir,
$manage_config = $::prometheus::alertmanager::params::manage_config,
$manage_as = $::prometheus::alertmanager::params::manage_as,
Expand Down
1 change: 0 additions & 1 deletion manifests/alertmanager/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
$package_ensure = 'installed'
$service_name = 'alertmanager'
$config_dir = '/etc/prometheus'
$purge_config_dir = false
$manage_config = true
$manage_as = 'service'
$container_image = 'docker.io/prom/alertmanager:latest'
Expand Down
4 changes: 0 additions & 4 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
# [*config_dir*]
# Prometheus configuration directory (default /etc/prometheus)
#
# [*purge_config_dir*]
# Purge config files no longer generated by Puppet
#
# [*manage_config*]
# If you manage the config from some other place (git, for ex.) set this to false (default true)
#
Expand Down Expand Up @@ -229,7 +226,6 @@
$user = $::prometheus::params::user,
$group = $::prometheus::params::group,
$config_dir = $::prometheus::params::config_dir,
$purge_config_dir = $::prometheus::params::purge_config_dir,
$manage_config = $::prometheus::params::manage_config,
$manage_as = $::prometheus::params::manage_as,
$container_image = $::prometheus::params::container_image,
Expand Down
1 change: 0 additions & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
$user = 'prometheus'
$group = 'prometheus'
$config_dir = '/etc/prometheus'
$purge_config_dir = false
$manage_config = true
$manage_as = 'service'
$container_image = 'docker.io/prom/prometheus:latest'
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cristifalcas-prometheus",
"version": "1.4.1",
"version": "1.5.0",
"author": "Cristian Falcas",
"summary": "Prometheus Puppet module",
"license": "Apache-2.0",
Expand Down
10 changes: 5 additions & 5 deletions templates/alertmanager.yml.erb
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# This file is managed by Puppet, any changes will be overwritten

<%-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),"..","..","..","lib"))
require 'puppet_x/elastic/deep_to_i'
require 'puppet_x/elastic/hash'
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),"..","lib"))
require 'puppet_x/prometheus/deep_to_i'
require 'puppet_x/prometheus/hash'

@yml_string = ''

if !scope['prometheus::alertmanager::config'].empty?

# Sort Hash and transform it into yaml
@yml_string += Puppet_X::Elastic::deep_to_i(
@yml_string += Puppet_X::Prometheus::deep_to_i(
scope['prometheus::alertmanager::config']
).extend(
Puppet_X::Elastic::SortedHash
Puppet_X::Prometheus::SortedHash
).to_yaml

# Puppet < 4 uses ZAML, which has some deviations from Puppet 4 YAML
Expand Down
10 changes: 5 additions & 5 deletions templates/prometheus.yml.erb
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# This file is managed by Puppet, any changes will be overwritten

<%-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),"..","..","..","lib"))
require 'puppet_x/elastic/deep_to_i'
require 'puppet_x/elastic/hash'
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),"..","lib"))
require 'puppet_x/prometheus/deep_to_i'
require 'puppet_x/prometheus/hash'

@yml_string = ''

if !scope['prometheus::config'].empty?

# Sort Hash and transform it into yaml
@yml_string += Puppet_X::Elastic::deep_to_i(
@yml_string += Puppet_X::Prometheus::deep_to_i(
scope['prometheus::config']
).extend(
Puppet_X::Elastic::SortedHash
Puppet_X::Prometheus::SortedHash
).to_yaml

# Puppet < 4 uses ZAML, which has some deviations from Puppet 4 YAML
Expand Down

0 comments on commit a82ade6

Please sign in to comment.