Switch Elasticsearch and Kibana to 5 version

Change-Id: I0e7fe750b177acfdbed0e69efe7c901a328a31ca
diff --git a/.releasenotes/notes/new-classes-es-kibana-59e86910979d52a4.yaml b/.releasenotes/notes/new-classes-es-kibana-59e86910979d52a4.yaml
new file mode 100644
index 0000000..d6e2ecd
--- /dev/null
+++ b/.releasenotes/notes/new-classes-es-kibana-59e86910979d52a4.yaml
@@ -0,0 +1,21 @@
+---
+summary: >
+  Added two new classes for Elasticsearch and Kibana
+
+features:
+  - |
+    Added two new classes to support Elasticsearch v2 and v5 and Kibana
+    v4 and v5.
+    Update the Elasticsearch and Kibana classes in the
+    ``classes/cluster/<cluster_name>/stacklight/server.yml`` file of
+    the Reclass model of your MCP deployment according to the required
+    versions:
+
+    #. For Elasticsearch, change the ``linux.system.repo.elasticsearch`` class
+       to ``linux.system.repo.elasticsearch.2`` or ``linux.system.repo.elasticsearch.5``.
+       To deploy Elasticsearch version 2, specify the ``elasticsearch_version: 2``
+       parameter in the same file.
+    #. For Kibana, change the ``linux.system.repo.kibana`` class to
+       ``linux.system.repo.kibana.4`` or ``linux.system.repo.kibana.5``.
+       To deploy Kibana version 4, specify the ``kibana_version: 4``
+       parameter in the same file.
diff --git a/.releasenotes/notes/switch-es-kibana-to-5-3ef55164a574e066.yaml b/.releasenotes/notes/switch-es-kibana-to-5-3ef55164a574e066.yaml
new file mode 100644
index 0000000..86692c7
--- /dev/null
+++ b/.releasenotes/notes/switch-es-kibana-to-5-3ef55164a574e066.yaml
@@ -0,0 +1,19 @@
+---
+summary: >
+  Updated Elasticsearch and Kibana to versions 5
+
+features:
+  - |
+    Updated Elasticsearch and Kibana to v5. Elasticsearch and Kibana v5
+    are now installed by default.
+
+    To upgrade existing Elasticsearch and Kibana installations to v5,
+    follow the procedures described in the MCP Operations Guide.
+
+    .. TODO: add a link to the upgrade procedure.
+
+    Kibana versions prior to 5.6.x are incompatible with Elasticsearch
+    5.x. Therefore, once you upgrade Elasticsearch to v5, you must also
+    upgrade Kibana to v5 as described in the MCP Operations Guide.
+
+    .. TODO: add a link to the upgrade procedure.
diff --git a/aptly/server/mirror/debian/elasticsearch5.yml b/aptly/server/mirror/debian/elasticsearch5.yml
new file mode 100644
index 0000000..75368ba
--- /dev/null
+++ b/aptly/server/mirror/debian/elasticsearch5.yml
@@ -0,0 +1,46 @@
+parameters:
+  _param:
+    aptly_mirror_elasticsearch-5x_source: https://artifacts.elastic.co/packages/5.x/apt
+    aptly_mirror_elasticsearch-5x_distribution: stable
+    aptly_mirror_elasticsearch-5x_components: main
+    aptly_mirror_elasticsearch-5x_gpgkeys:
+      - D88E42B4
+    aptly_mirror_elasticsearch-curator-5x_source: https://packages.elastic.co/curator/5/debian
+    aptly_mirror_elasticsearch-curator-5x_distribution: stable
+    aptly_mirror_elasticsearch-curator-5x_components: main
+  aptly:
+    server:
+      mirror:
+        elasticsearch-5x:
+          source: ${_param:mirror_elasticsearch-5x_source}
+          distribution: ${_param:mirror_elasticsearch-5x_distribution}
+          components: ${_param:mirror_elasticsearch-5x_components}
+          architectures: amd64
+          gpgkeys: ${_param:mirror_elasticsearch-5x_gpgkeys}
+          publisher:
+            component: elastic
+            distributions:
+              - trusty/${_param:apt_mk_version}
+              - xenial/${_param:apt_mk_version}
+        kibana-5x:
+          source: ${_param:aptly_mirror_elasticsearch-5x_source}
+          distribution: ${_param:aptly_mirror_elasticsearch-5x_distribution}
+          components: ${_param:aptly_mirror_elasticsearch-5x_components}
+          architectures: amd64
+          gpgkeys: ${_param:aptly_mirror_elasticsearch-5x_gpgkeys}
+          publisher:
+            component: elastic
+            distributions:
+              - trusty/${_param:apt_mk_version}
+              - xenial/${_param:apt_mk_version}
+        elasticsearch-curator-5x:
+          source: ${_param:aptly_mirror_elasticsearch-curator-5x_source}
+          distribution: ${_param:aptly_mirror_elasticsearch-curator-5x_distribution}
+          components: ${_param:aptly_mirror_elasticsearch-curator-5x_components}
+          architectures: amd64
+          gpgkeys: ${_param:aptly_mirror_elasticsearch-5x_gpgkeys}
+          publisher:
+            component: elastic
+            distributions:
+              - trusty/${_param:apt_mk_version}
+              - xenial/${_param:apt_mk_version}
diff --git a/elasticsearch/server/cluster.yml b/elasticsearch/server/cluster.yml
index 94b6d85..1bbe404 100644
--- a/elasticsearch/server/cluster.yml
+++ b/elasticsearch/server/cluster.yml
@@ -6,7 +6,7 @@
     java_environment_version: "8"
     java_environment_platform: openjdk
     elasticsearch_cluster_name: elasticsearch
-    elasticsearch_version: 2
+    elasticsearch_version: 5
   linux:
     system:
       sysctl:
diff --git a/elasticsearch/server/single.yml b/elasticsearch/server/single.yml
index ce7da36..419513d 100644
--- a/elasticsearch/server/single.yml
+++ b/elasticsearch/server/single.yml
@@ -3,7 +3,7 @@
 - service.elasticsearch.server.single
 parameters:
   _param:
-    elasticsearch_version: 2
+    elasticsearch_version: 5
   linux:
     system:
       sysctl:
diff --git a/kibana/server/single.yml b/kibana/server/single.yml
index e6a0a4d..745c07a 100644
--- a/kibana/server/single.yml
+++ b/kibana/server/single.yml
@@ -2,7 +2,7 @@
 - service.kibana.server.single
 parameters:
   _param:
-    kibana_version: 4
+    kibana_version: 5
   kibana:
     server:
       enabled: true
diff --git a/linux/system/repo/elasticsearch/5.yml b/linux/system/repo/elasticsearch/5.yml
new file mode 100644
index 0000000..1b9e3e6
--- /dev/null
+++ b/linux/system/repo/elasticsearch/5.yml
@@ -0,0 +1,45 @@
+parameters:
+  _param:
+    elasticsearch_gpg_key: |
+      -----BEGIN PGP PUBLIC KEY BLOCK-----
+      Version: GnuPG v2.0.14 (GNU/Linux)
+
+      mQENBFI3HsoBCADXDtbNJnxbPqB1vDNtCsqhe49vFYsZN9IOZsZXgp7aHjh6CJBD
+      A+bGFOwyhbd7at35jQjWAw1O3cfYsKAmFy+Ar3LHCMkV3oZspJACTIgCrwnkic/9
+      CUliQe324qvObU2QRtP4Fl0zWcfb/S8UYzWXWIFuJqMvE9MaRY1bwUBvzoqavLGZ
+      j3SF1SPO+TB5QrHkrQHBsmX+Jda6d4Ylt8/t6CvMwgQNlrlzIO9WT+YN6zS+sqHd
+      1YK/aY5qhoLNhp9G/HxhcSVCkLq8SStj1ZZ1S9juBPoXV1ZWNbxFNGwOh/NYGldD
+      2kmBf3YgCqeLzHahsAEpvAm8TBa7Q9W21C8vABEBAAG0RUVsYXN0aWNzZWFyY2gg
+      KEVsYXN0aWNzZWFyY2ggU2lnbmluZyBLZXkpIDxkZXZfb3BzQGVsYXN0aWNzZWFy
+      Y2gub3JnPokBOAQTAQIAIgUCUjceygIbAwYLCQgHAwIGFQgCCQoLBBYCAwECHgEC
+      F4AACgkQ0n1mbNiOQrRzjAgAlTUQ1mgo3nK6BGXbj4XAJvuZDG0HILiUt+pPnz75
+      nsf0NWhqR4yGFlmpuctgCmTD+HzYtV9fp9qW/bwVuJCNtKXk3sdzYABY+Yl0Cez/
+      7C2GuGCOlbn0luCNT9BxJnh4mC9h/cKI3y5jvZ7wavwe41teqG14V+EoFSn3NPKm
+      TxcDTFrV7SmVPxCBcQze00cJhprKxkuZMPPVqpBS+JfDQtzUQD/LSFfhHj9eD+Xe
+      8d7sw+XvxB2aN4gnTlRzjL1nTRp0h2/IOGkqYfIG9rWmSLNlxhB2t+c0RsjdGM4/
+      eRlPWylFbVMc5pmDpItrkWSnzBfkmXL3vO2X3WvwmSFiQbkBDQRSNx7KAQgA5JUl
+      zcMW5/cuyZR8alSacKqhSbvoSqqbzHKcUQZmlzNMKGTABFG1yRx9r+wa/fvqP6OT
+      RzRDvVS/cycws8YX7Ddum7x8uI95b9ye1/Xy5noPEm8cD+hplnpU+PBQZJ5XJ2I+
+      1l9Nixx47wPGXeClLqcdn0ayd+v+Rwf3/XUJrvccG2YZUiQ4jWZkoxsA07xx7Bj+
+      Lt8/FKG7sHRFvePFU0ZS6JFx9GJqjSBbHRRkam+4emW3uWgVfZxuwcUCn1ayNgRt
+      KiFv9jQrg2TIWEvzYx9tywTCxc+FFMWAlbCzi+m4WD+QUWWfDQ009U/WM0ks0Kww
+      EwSk/UDuToxGnKU2dQARAQABiQEfBBgBAgAJBQJSNx7KAhsMAAoJENJ9ZmzYjkK0
+      c3MIAIE9hAR20mqJWLcsxLtrRs6uNF1VrpB+4n/55QU7oxA1iVBO6IFu4qgsF12J
+      TavnJ5MLaETlggXY+zDef9syTPXoQctpzcaNVDmedwo1SiL03uMoblOvWpMR/Y0j
+      6rm7IgrMWUDXDPvoPGjMl2q1iTeyHkMZEyUJ8SKsaHh4jV9wp9KmC8C+9CwMukL7
+      vM5w8cgvJoAwsp3Fn59AxWthN3XJYcnMfStkIuWgR7U2r+a210W6vnUxU4oN0PmM
+      cursYPyeV0NX/KQeUeNMwGTFB6QHS/anRaGQewijkrYYoTNtfllxIu9XYmiBERQ/
+      qPDlGRlOgVTd9xUfHFkzB52c70E=
+      =92oX
+      -----END PGP PUBLIC KEY BLOCK-----
+  linux:
+    system:
+      repo:
+        elasticsearch:
+          source: "deb https://artifacts.elastic.co/packages/5.x/apt stable main"
+          architectures: amd64
+          key: ${_param:elasticsearch_gpg_key}
+        elasticsearch_curator:
+          source: "deb https://packages.elastic.co/curator/5/debian stable main"
+          architectures: amd64
+          key: ${_param:elasticsearch_gpg_key}
diff --git a/linux/system/repo/elasticsearch.yml b/linux/system/repo/elasticsearch/init.yml
similarity index 100%
rename from linux/system/repo/elasticsearch.yml
rename to linux/system/repo/elasticsearch/init.yml
diff --git a/linux/system/repo/elasticsearch5.yml b/linux/system/repo/elasticsearch5.yml
deleted file mode 100644
index 34699e8..0000000
--- a/linux/system/repo/elasticsearch5.yml
+++ /dev/null
@@ -1,12 +0,0 @@
-parameters:
-  linux:
-    system:
-      repo:
-        elasticsearch:
-          source: "deb https://artifacts.elastic.co/packages/5.x/apt stable main"
-          architectures: amd64
-          key_url: "https://artifacts.elastic.co/GPG-KEY-elasticsearch"
-        elasticsearch_curator:
-          source: "deb http://packages.elastic.co/curator/4/debian stable main"
-          architectures: amd64
-          key_url: "https://packages.elastic.co/GPG-KEY-elasticsearch"
diff --git a/linux/system/repo/kibana/5.yml b/linux/system/repo/kibana/5.yml
new file mode 100644
index 0000000..795f7d1
--- /dev/null
+++ b/linux/system/repo/kibana/5.yml
@@ -0,0 +1,40 @@
+parameters:
+  _param:
+    kibana_gpg_key: |
+      -----BEGIN PGP PUBLIC KEY BLOCK-----
+      Version: GnuPG v2.0.14 (GNU/Linux)
+
+      mQENBFI3HsoBCADXDtbNJnxbPqB1vDNtCsqhe49vFYsZN9IOZsZXgp7aHjh6CJBD
+      A+bGFOwyhbd7at35jQjWAw1O3cfYsKAmFy+Ar3LHCMkV3oZspJACTIgCrwnkic/9
+      CUliQe324qvObU2QRtP4Fl0zWcfb/S8UYzWXWIFuJqMvE9MaRY1bwUBvzoqavLGZ
+      j3SF1SPO+TB5QrHkrQHBsmX+Jda6d4Ylt8/t6CvMwgQNlrlzIO9WT+YN6zS+sqHd
+      1YK/aY5qhoLNhp9G/HxhcSVCkLq8SStj1ZZ1S9juBPoXV1ZWNbxFNGwOh/NYGldD
+      2kmBf3YgCqeLzHahsAEpvAm8TBa7Q9W21C8vABEBAAG0RUVsYXN0aWNzZWFyY2gg
+      KEVsYXN0aWNzZWFyY2ggU2lnbmluZyBLZXkpIDxkZXZfb3BzQGVsYXN0aWNzZWFy
+      Y2gub3JnPokBOAQTAQIAIgUCUjceygIbAwYLCQgHAwIGFQgCCQoLBBYCAwECHgEC
+      F4AACgkQ0n1mbNiOQrRzjAgAlTUQ1mgo3nK6BGXbj4XAJvuZDG0HILiUt+pPnz75
+      nsf0NWhqR4yGFlmpuctgCmTD+HzYtV9fp9qW/bwVuJCNtKXk3sdzYABY+Yl0Cez/
+      7C2GuGCOlbn0luCNT9BxJnh4mC9h/cKI3y5jvZ7wavwe41teqG14V+EoFSn3NPKm
+      TxcDTFrV7SmVPxCBcQze00cJhprKxkuZMPPVqpBS+JfDQtzUQD/LSFfhHj9eD+Xe
+      8d7sw+XvxB2aN4gnTlRzjL1nTRp0h2/IOGkqYfIG9rWmSLNlxhB2t+c0RsjdGM4/
+      eRlPWylFbVMc5pmDpItrkWSnzBfkmXL3vO2X3WvwmSFiQbkBDQRSNx7KAQgA5JUl
+      zcMW5/cuyZR8alSacKqhSbvoSqqbzHKcUQZmlzNMKGTABFG1yRx9r+wa/fvqP6OT
+      RzRDvVS/cycws8YX7Ddum7x8uI95b9ye1/Xy5noPEm8cD+hplnpU+PBQZJ5XJ2I+
+      1l9Nixx47wPGXeClLqcdn0ayd+v+Rwf3/XUJrvccG2YZUiQ4jWZkoxsA07xx7Bj+
+      Lt8/FKG7sHRFvePFU0ZS6JFx9GJqjSBbHRRkam+4emW3uWgVfZxuwcUCn1ayNgRt
+      KiFv9jQrg2TIWEvzYx9tywTCxc+FFMWAlbCzi+m4WD+QUWWfDQ009U/WM0ks0Kww
+      EwSk/UDuToxGnKU2dQARAQABiQEfBBgBAgAJBQJSNx7KAhsMAAoJENJ9ZmzYjkK0
+      c3MIAIE9hAR20mqJWLcsxLtrRs6uNF1VrpB+4n/55QU7oxA1iVBO6IFu4qgsF12J
+      TavnJ5MLaETlggXY+zDef9syTPXoQctpzcaNVDmedwo1SiL03uMoblOvWpMR/Y0j
+      6rm7IgrMWUDXDPvoPGjMl2q1iTeyHkMZEyUJ8SKsaHh4jV9wp9KmC8C+9CwMukL7
+      vM5w8cgvJoAwsp3Fn59AxWthN3XJYcnMfStkIuWgR7U2r+a210W6vnUxU4oN0PmM
+      cursYPyeV0NX/KQeUeNMwGTFB6QHS/anRaGQewijkrYYoTNtfllxIu9XYmiBERQ/
+      qPDlGRlOgVTd9xUfHFkzB52c70E=
+      =92oX
+      -----END PGP PUBLIC KEY BLOCK-----
+  linux:
+    system:
+      repo:
+        kibana:
+          source: "deb https://artifacts.elastic.co/packages/5.x/apt stable main"
+          key: ${_param:kibana_gpg_key}
diff --git a/linux/system/repo/kibana.yml b/linux/system/repo/kibana/init.yml
similarity index 100%
rename from linux/system/repo/kibana.yml
rename to linux/system/repo/kibana/init.yml
diff --git a/linux/system/repo/kibana5.yml b/linux/system/repo/kibana5.yml
deleted file mode 100644
index 0d6235b..0000000
--- a/linux/system/repo/kibana5.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-parameters:
-  linux:
-    system:
-      repo:
-        kibana:
-          source: "deb https://artifacts.elastic.co/packages/5.x/apt stable main"
-          key_url: "https://artifacts.elastic.co/GPG-KEY-elasticsearch"
\ No newline at end of file