Add new module elasticsearch for listsearch
[mirror/dsa-puppet.git] / 3rdparty / modules / elasticsearch / manifests / repo.pp
diff --git a/3rdparty/modules/elasticsearch/manifests/repo.pp b/3rdparty/modules/elasticsearch/manifests/repo.pp
new file mode 100644 (file)
index 0000000..326652d
--- /dev/null
@@ -0,0 +1,78 @@
+# == Class: elasticsearch::repo
+#
+# This class exists to install and manage yum and apt repositories
+# that contain elasticsearch official elasticsearch packages
+#
+#
+# === Parameters
+#
+# This class does not provide any parameters.
+#
+#
+# === Examples
+#
+# This class may be imported by other classes to use its functionality:
+#   class { 'elasticsearch::repo': }
+#
+# It is not intended to be used directly by external resources like node
+# definitions or other modules.
+#
+#
+# === Authors
+#
+# * Phil Fenstermacher <mailto:phillip.fenstermacher@gmail.com>
+# * Richard Pijnenburg <mailto:richard.pijnenburg@elasticsearch.com>
+#
+class elasticsearch::repo {
+
+  Exec {
+    path      => [ '/bin', '/usr/bin', '/usr/local/bin' ],
+    cwd       => '/',
+  }
+
+  case $::osfamily {
+    'Debian': {
+      if !defined(Class['apt']) {
+        class { 'apt': }
+      }
+
+      apt::source { 'elasticsearch':
+        location    => "http://packages.elasticsearch.org/elasticsearch/${elasticsearch::repo_version}/debian",
+        release     => 'stable',
+        repos       => 'main',
+        key         => 'D88E42B4',
+        key_source  => 'http://packages.elasticsearch.org/GPG-KEY-elasticsearch',
+        include_src => false,
+      }
+    }
+    'RedHat', 'Linux': {
+      yumrepo { 'elasticsearch':
+        descr    => 'elasticsearch repo',
+        baseurl  => "http://packages.elasticsearch.org/elasticsearch/${elasticsearch::repo_version}/centos",
+        gpgcheck => 1,
+        gpgkey   => 'http://packages.elasticsearch.org/GPG-KEY-elasticsearch',
+        enabled  => 1,
+      }
+    }
+    'Suse': {
+      exec { 'elasticsearch_suse_import_gpg':
+        command => 'rpmkeys --import http://packages.elasticsearch.org/GPG-KEY-elasticsearch',
+        unless  => 'test $(rpm -qa gpg-pubkey | grep -i "D88E42B4" | wc -l) -eq 1 ',
+        notify  => [ Zypprepo['elasticsearch'] ]
+      }
+
+      zypprepo { 'elasticsearch':
+        baseurl     => "http://packages.elasticsearch.org/elasticsearch/${elasticsearch::repo_version}/centos",
+        enabled     => 1,
+        autorefresh => 1,
+        name        => 'elasticsearch',
+        gpgcheck    => 1,
+        gpgkey      => 'http://packages.elasticsearch.org/GPG-KEY-elasticsearch',
+        type        => 'yum'
+      }
+    }
+    default: {
+      fail("\"${module_name}\" provides no repository information for OSfamily \"${::osfamily}\"")
+    }
+  }
+}