Skip to content

Instantly share code, notes, and snippets.

@garthk
Created February 6, 2013 04:30
Show Gist options
  • Save garthk/4720326 to your computer and use it in GitHub Desktop.
Save garthk/4720326 to your computer and use it in GitHub Desktop.
Puppet module to define elastic_template resource type. Doesn't ensure that the index is correct, but does ensure it's present.
define elastic_template($host='localhost', $port='9200', $prefix='', $require=undef) {
$es_templ = "${name}-template.json"
file { "/tmp/${es_templ}":
ensure => present,
source => "puppet:///modules/${module_name}/${prefix}${es_templ}",
require => $require,
}
$es_locn = "http://${host}:${port}/_template/${name}"
exec { "curl -s -XPUT ${es_locn} -d @/tmp/${es_templ}":
path => '/usr/local/bin:/usr/bin:/bin',
unless => "test $(curl -s '${es_locn}?pretty=true' | wc -l) -gt 1",
require => File["/tmp/${es_templ}"],
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment