Switch to custom role elasticsearch_kibana

- Use plugin version 3.0.0 and remove compatibility with MOS 6.1
- Leverage common tasks to configure disk and network
- Update README

Change-Id: I7f185de0cfbe3098c9fee2d0f7a792df5b0a95e0
This commit is contained in:
Swann Croiset 2015-09-08 10:26:33 +02:00
parent 4f37537423
commit fe2e8948af
29 changed files with 168 additions and 920 deletions

View File

@ -15,7 +15,7 @@ Requirements
| Requirement | Version/Comment |
|--------------------------------|-----------------|
| Mirantis OpenStack compatility | 6.1 or higher |
| Mirantis OpenStack compatility | 7.0 or higher |
Recommendations
---------------
@ -61,7 +61,7 @@ To install the Elasticsearch-Kibana plugin, follow these steps:
```
Please refer to the [Fuel Plugins wiki](https://wiki.openstack.org/wiki/Fuel/Plugins)
if you want to build the plugin by yourself. Version 2.0.0 (or higher) of the Fuel
if you want to build the plugin by yourself. Version 3.0.0 (or higher) of the Fuel
Plugin Builder is required.
User Guide
@ -71,12 +71,10 @@ User Guide
---------------------------------------------
1. Create a new environment with the Fuel UI wizard.
2. Add a node with the "Operating System" role.
3. Before applying changes or once changes applied, edit the name of the node by
clicking on "Untitled (xx:yy)" and modify it for "elasticsearch".
4. Click on the Settings tab of the Fuel web UI.
5. Scroll down the page, select the "Elasticsearch-Kibana Server plugin" checkbox
and fill-in the required fields.
2. Click on the Settings tab of the Fuel web UI.
3. Scroll down the page, select the "Elasticsearch-Kibana Server plugin" tab,
enable the plugin and fill-in the required fields.
4. Add a node with the "Elasticsearch Kibana" role.
### Heap sizing
By default, 1G of heap memory is allocated to the Elasticsearch process. In
@ -85,16 +83,13 @@ many cases this number will be too small. You can modify this value up to
Elasticsearch. If you set a value that is greater than the memory size of
the node, Elasticsearch won't start.
### Disks partitioning
The plugin uses:
### Disks partitionning
You can select up to 3 physical disks that will be mounted as a single logical
volume to store the Elasticsearch data. If you specify no disk, the data will
be stored on the root filesystem. In all cases, Elasticsearch data will be
located in the */opt/es-data* directory.
For each disk, you can also specify the allocated size (in GB). If you don't
specify a value, the plugin will use all the free space of the disk.
- 20% of the first disk for the operating system by honoring the range of
15GB minimum and 50GB maximum.
- 10GB for /var/log.
- at least 30GB for the Elasticsearch data (/opt/es-data).
Testing
-------
@ -146,7 +141,10 @@ Release Notes
**0.8.0**
*
* Add the "elasticsearch_kibana" role (instead of leveraging on the
"base-os" role)
* Add support for data curation
* Upgrade Elasticsearch to 1.4.5
**0.7.0**

View File

@ -14,32 +14,8 @@
$elasticsearch_kibana = hiera('elasticsearch_kibana')
if $elasticsearch_kibana['node_name'] == hiera('user_node_name') {
$roles = hiera('roles')
$blockdevices_array = split($::blockdevices, ',')
# Check that we're not colocated with other roles
if size($roles) > 1 {
fail('The Elasticsearch-Kibana plugin cannot be deployed with roles other than base-os.')
}
# Check that disk device(s) exist
if ($elasticsearch_kibana['disk1']) and !($elasticsearch_kibana['disk1'] in $blockdevices_array) {
fail("Disk device ${ elasticsearch_kibana['disk1'] } doesn't exist.")
}
if ($elasticsearch_kibana['disk2']) and !($elasticsearch_kibana['disk2'] in $blockdevices_array) {
fail("Disk device ${ elasticsearch_kibana['disk2'] } doesn't exist.")
}
if ($elasticsearch_kibana['disk3']) and !($elasticsearch_kibana['disk3'] in $blockdevices_array) {
fail("Disk device ${ elasticsearch_kibana['disk3'] } doesn't exist.")
}
# Check that JVM size doesn't exceed the physical RAM size
$jvmsize_mb = ($elasticsearch_kibana['jvm_heap_size'] + 0.0) * 1024
if $jvmsize_mb >= $::memorysize_mb {
fail("The configured JVM size (${ $elasticsearch_kibana['jvm_heap_size'] } GB) is greater than the total amount of RAM of the system (${ ::memorysize }).")
}
# Check that JVM size doesn't exceed the physical RAM size
$jvmsize_mb = ($elasticsearch_kibana['jvm_heap_size'] + 0.0) * 1024
if $jvmsize_mb >= $::memorysize_mb {
fail("The configured JVM size (${ $elasticsearch_kibana['jvm_heap_size'] } GB) is greater than the total amount of RAM of the system (${ ::memorysize }).")
}

View File

@ -14,51 +14,52 @@
#
$elasticsearch_kibana = hiera('elasticsearch_kibana')
if $elasticsearch_kibana['node_name'] == hiera('user_node_name') {
# Params related to Elasticsearch.
$es_dir = $elasticsearch_kibana['data_dir']
$es_instance = 'es-01'
$es_heap_size = $elasticsearch_kibana['jvm_heap_size']
# Params related to Elasticsearch.
$es_dir = $elasticsearch_kibana['data_dir']
$es_instance = 'es-01'
$es_heap_size = $elasticsearch_kibana['jvm_heap_size']
# Java
$java = $::operatingsystem ? {
CentOS => 'java-1.8.0-openjdk-headless',
Ubuntu => 'openjdk-7-jre-headless'
}
# Ensure that java is installed
package { $java:
ensure => installed,
}
# Install elasticsearch
class { 'elasticsearch':
datadir => ["${es_dir}/elasticsearch_data"],
init_defaults => {
'MAX_LOCKED_MEMORY' => 'unlimited',
'ES_HEAP_SIZE' => "${es_heap_size}g"
},
require => Package[$java],
}
# Start an instance of elasticsearch
elasticsearch::instance { $es_instance:
config => {
'threadpool.bulk.queue_size' => '1000',
'bootstrap.mlockall' => true,
'http.cors.allow-origin' => '/.*/',
'http.cors.enabled' => true
},
}
lma_logging_analytics::es_template { ['log', 'notification']:
number_of_replicas => 0 + $elasticsearch_kibana['number_of_replicas'],
require => Elasticsearch::Instance[$es_instance],
}
class { 'lma_logging_analytics::curator':
retention_period => $elasticsearch_kibana['retention_period'],
prefixes => ['log', 'notification'],
}
# Java
$java = $::operatingsystem ? {
CentOS => 'java-1.8.0-openjdk-headless',
Ubuntu => 'openjdk-7-jre-headless'
}
# Ensure that java is installed
package { $java:
ensure => installed,
}
file { $es_dir:
ensure => 'directory',
}
# Install elasticsearch
class { 'elasticsearch':
datadir => ["${es_dir}/elasticsearch_data"],
init_defaults => {
'MAX_LOCKED_MEMORY' => 'unlimited',
'ES_HEAP_SIZE' => "${es_heap_size}g"
},
require => [File[$es_dir], Package[$java]],
}
# Start an instance of elasticsearch
elasticsearch::instance { $es_instance:
config => {
'threadpool.bulk.queue_size' => '1000',
'bootstrap.mlockall' => true,
'http.cors.allow-origin' => '/.*/',
'http.cors.enabled' => true
},
}
lma_logging_analytics::es_template { ['log', 'notification']:
number_of_replicas => 0 + $elasticsearch_kibana['number_of_replicas'],
require => Elasticsearch::Instance[$es_instance],
}
class { 'lma_logging_analytics::curator':
retention_period => $elasticsearch_kibana['retention_period'],
prefixes => ['log', 'notification'],
}

View File

@ -12,49 +12,46 @@
# License for the specific language governing permissions and limitations
# under the License.
#
$elasticsearch_kibana = hiera('elasticsearch_kibana')
if $elasticsearch_kibana['node_name'] == hiera('user_node_name') {
class {'::firewall':}
class {'::firewall':}
firewall { '000 accept all icmp requests':
proto => 'icmp',
action => 'accept',
}
firewall { '001 accept all to lo interface':
proto => 'all',
iniface => 'lo',
action => 'accept',
}
firewall { '002 accept related established rules':
proto => 'all',
state => ['RELATED', 'ESTABLISHED'],
action => 'accept',
}
firewall {'020 ssh':
port => 22,
proto => 'tcp',
action => 'accept',
}
firewall { '100 elasticsearch':
port => 9200,
proto => 'tcp',
action => 'accept',
}
firewall { '101 kibana':
port => 80,
proto => 'tcp',
action => 'accept',
}
firewall { '999 drop all other requests':
proto => 'all',
chain => 'INPUT',
action => 'drop',
}
firewall { '000 accept all icmp requests':
proto => 'icmp',
action => 'accept',
}
firewall { '001 accept all to lo interface':
proto => 'all',
iniface => 'lo',
action => 'accept',
}
firewall { '002 accept related established rules':
proto => 'all',
state => ['RELATED', 'ESTABLISHED'],
action => 'accept',
}
firewall {'020 ssh':
port => 22,
proto => 'tcp',
action => 'accept',
}
firewall { '100 elasticsearch':
port => 9200,
proto => 'tcp',
action => 'accept',
}
firewall { '101 kibana':
port => 80,
proto => 'tcp',
action => 'accept',
}
firewall { '999 drop all other requests':
proto => 'all',
chain => 'INPUT',
action => 'drop',
}

View File

@ -14,8 +14,6 @@
#
$elasticsearch_kibana = hiera('elasticsearch_kibana')
if $elasticsearch_kibana['node_name'] == hiera('user_node_name') {
class { 'lma_logging_analytics::kibana':
number_of_replicas => 0 + $elasticsearch_kibana['number_of_replicas']
}
class { 'lma_logging_analytics::kibana':
number_of_replicas => 0 + $elasticsearch_kibana['number_of_replicas']
}

View File

@ -1,41 +0,0 @@
# Copyright 2015 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
$elasticsearch_kibana = hiera('elasticsearch_kibana')
if $elasticsearch_kibana['node_name'] == hiera('user_node_name') {
class { 'disk_management': }
if ($elasticsearch_kibana['disk1']) {
disk_management::partition { "/dev/${elasticsearch_kibana['disk1']}":
size => $elasticsearch_kibana['disk1_size'],
require => Class['disk_management'],
}
}
if ($elasticsearch_kibana['disk2']) {
disk_management::partition { "/dev/${elasticsearch_kibana['disk2']}":
size => $elasticsearch_kibana['disk2_size'],
require => Class['disk_management'],
}
}
if ($elasticsearch_kibana['disk3']) {
disk_management::partition { "/dev/${elasticsearch_kibana['disk3']}":
size => $elasticsearch_kibana['disk3_size'],
require => Class['disk_management'],
}
}
}

View File

@ -1,35 +0,0 @@
# Copyright 2015 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
$elasticsearch_kibana = hiera('elasticsearch_kibana')
if $elasticsearch_kibana['node_name'] == hiera('user_node_name') {
$directory = $elasticsearch_kibana['data_dir']
$disks = split($::unallocated_pvs, ',')
validate_array($disks)
if empty($disks) {
file { $directory:
ensure => 'directory',
}
} else {
disk_management::lvm_fs { $directory:
disks => $disks,
lv_name => 'es',
vg_name => 'data',
}
}
}

View File

@ -1,7 +0,0 @@
fixtures:
repositories:
stdlib:
repo: "git://github.com/puppetlabs/puppetlabs-stdlib"
ref: "4.7.0"
symlinks:
disk_management: "#{source_dir}"

View File

@ -1,3 +0,0 @@
spec/fixtures/modules/*
spec/fixtures/manifests/*
Gemfile.lock

View File

@ -1,24 +0,0 @@
# Copyright 2015 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
source 'https://rubygems.org'
group :development, :test do
gem 'rake'
gem "puppet", ENV['PUPPET_VERSION'] || '~> 3.4.0'
gem 'rspec'
gem 'rspec-puppet'
gem 'rspec-puppet-facts'
gem 'puppetlabs_spec_helper'
gem 'metadata-json-lint'
end

View File

@ -1,202 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -1,37 +0,0 @@
Disk management module for Puppet
=================================
Description
-----------
Puppet module for managing disks.
Usage
-----
```puppet
class {'disk_manage':
disks => ['/dev/sdb']
}
```
Limitations
-----------
None.
License
-------
Licensed under the terms of the Apache License, version 2.0.
Contact
-------
Guillaume Thouvenin, <gthouvenin@mirantis.com>
Support
-------
See the Contact section.

View File

@ -1,25 +0,0 @@
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
require 'puppet-syntax/tasks/puppet-syntax'
require 'metadata-json-lint/rake_task'
PuppetLint.configuration.fail_on_warnings = true
PuppetLint.configuration.send('disable_80chars')
PuppetLint.configuration.send('disable_class_inherits_from_params_class')
PuppetLint.configuration.send('disable_class_parameter_defaults')
exclude_paths = [
"pkg/**/*",
"vendor/**/*",
"spec/**/*",
]
PuppetLint.configuration.ignore_paths = exclude_paths
PuppetSyntax.exclude_paths = exclude_paths
desc "Run metadata_lint, lint, syntax, and spec tests."
task :test => [
:metadata_lint,
:lint,
:syntax,
:spec,
]

View File

@ -1,65 +0,0 @@
#!/bin/bash
# Copyright 2015 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# Use this script if you want to allocate a new partition.
# Ubuntu and CentOS are not configured the same way by Fuel. CentOS is doing
# RAID 1 with /boot on all disks so we need to deal with that.
# $1 -> The disk (example: "/dev/sdb")
# $2 -> Size of the partition (use all free space if not provided)
set -eux
DISK=$1
DISK_SIZE=${2:-""}
PARTED="$(which parted 2>/dev/null) -s -m"
if ${PARTED} "${DISK}" p | grep -q "unrecognised disk label"; then
# We need to create a new label
${PARTED} "${DISK}" mklabel gpt
fi
# We take the free space at the end of the disk.
FREESPACE=$(${PARTED} "${DISK}" unit B p free | grep "free" | tail -1)
if [[ -z "${FREESPACE}" ]]; then
echo "Failed to find free space"
exit 1
fi
BEGIN=$(echo "${FREESPACE}" | awk -F: '{print $2}')
if [ -z "${DISK_SIZE}" ]; then
END=$(echo "${FREESPACE}" | awk -F: '{print $3}')
else
END="$(( $(echo "$BEGIN" | rev | cut -c 2- | rev) + $(( DISK_SIZE*1024*1024*1024 )) ))B"
fi
# If you create a partition on a mounted disk, this command returns 1
# So we need a different way to catch the error
if ${PARTED} "${DISK}" unit B mkpart primary "${BEGIN}" "${END}" | grep -q "^Error"; then
echo "Failed to create a new primary partition"
exit 1
fi
# Get the ID of the partition and set flags to LVM
# Like when we create a new partition, if you run this command on a mounted
# FS the kernel failed to re-read the partition and the command returns 1
# event in case of success.
PARTID=$(${PARTED} "${DISK}" p | tail -1 | awk -F: '{print $1}')
if ${PARTED} "${DISK}" set "${PARTID}" lvm on | grep -q "^Error"; then
echo "Failed to set the lvm flag on partition ${PARTID}."
exit 1
fi

View File

@ -1,40 +0,0 @@
# Copyright 2015 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# Return the list of LVM disk partition that haven't been allocated yet
unallocated_pvs = []
# Enumerate disk devices
devices = Dir.entries('/sys/block/').select do |d|
File.exist?( "/sys/block/#{ d }/device" )
end
if Facter::Util::Resolution.which("parted") and Facter::Util::Resolution.which('pvs') then
devices.each do |device|
device = "/dev/#{ device }"
# Filter only partitions flagged as LVM
lvm_partitions = Facter::Util::Resolution.exec(
"parted -s -m #{ device } print 2>/dev/null").scan(/^(\d+):.+:lvm;$/).flatten
lvm_partitions.each do |x|
# Filter only partitions which haven't been created yet
pvs = Facter::Util::Resolution.exec(
"pvs --noheadings #{ device }#{ x } 2>/dev/null")
if pvs.nil? then
unallocated_pvs.push("#{ device }#{ x }")
end
end
end
end
Facter.add("unallocated_pvs") { setcode { unallocated_pvs.sort.join(',') } }

View File

@ -1,35 +0,0 @@
# Copyright 2015 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# Class disk_management
class disk_management (
$script = $disk_management::params::script,
$puppet_source = $disk_management::params::puppet_source,
$script_location = $disk_management::params::script_location,
) inherits disk_management::params {
package { 'parted':
ensure => installed,
}
file { $script_location:
ensure => 'file',
source => $puppet_source,
owner => 'root',
group => 'root',
mode => '0700',
require => Package['parted'],
}
}

View File

@ -1,52 +0,0 @@
# Copyright 2015 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# Define Resource Type: disk_management::lvm_fs
define disk_management::lvm_fs (
$disks,
$lv_name,
$vg_name,
$fstype = 'ext3',
$group = 'root',
$owner = 'root',
) {
$directory = $title
$device = "/dev/${vg_name}/${lv_name}"
# Creates the logical volume
lvm::volume { $lv_name:
ensure => present,
pv => $disks,
vg => $vg_name,
fstype => $fstype,
}
# create the directory
file { $directory:
ensure => directory,
group => $group,
owner => $owner,
}
# Mount the directory
mount { $directory:
ensure => mounted,
device => $device,
fstype => $fstype,
options => 'defaults',
require => [File[$directory], Lvm::Volume[$lv_name]],
}
}

View File

@ -1,21 +0,0 @@
# Copyright 2015 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# Class disk_management::params
class disk_management::params {
$script = 'add_partition.sh'
$puppet_source = "puppet:///modules/disk_management/${script}"
$script_location = "/usr/local/bin/${script}"
}

View File

@ -1,32 +0,0 @@
# Copyright 2015 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# Class that partition the disk
# If a disk is given as title we check for free space and allocated
# this free space by calling the script given as parameter.
define disk_management::partition (
$size = undef,
){
include disk_management::params
$disk = $title
$script = $disk_management::params::script_location
$cmd = "${script} ${disk} ${size}"
exec { $title:
command => $cmd,
}
}

View File

@ -1,25 +0,0 @@
{
"name": "disk_management",
"version": "1.0.0",
"author": "Guillaume Thouvenin <gthouvenin@mirantis.com>",
"summary": "Partition and configure disks",
"license": "Apache-2.0",
"source": "git://git.openstack.org/cgit/stackforge/fuel-plugin-elasticsearch-kibana.git",
"project_page": "none",
"issues_url": "none",
"operatingsystem_support": [
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": ["12.04", "14.04"]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": ["6"]
}
],
"description": "Puppet module for managing disks",
"dependencies": [
{"name": "puppetlabs/stdlib", "version_requirement": "4.x"},
{"name": "puppetlabs/lvm", "version_requirement": ">= 0.3.1"}
]
}

View File

@ -1,6 +0,0 @@
--format
s
--colour
--loadby
mtime
--backtrace

View File

@ -1,22 +0,0 @@
# Copyright 2015 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require 'rspec-puppet'
fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures'))
RSpec.configure do |c|
c.module_path = File.join(fixture_path, 'modules')
c.manifest_dir = File.join(fixture_path, 'manifests')
c.environmentpath = File.join(Dir.pwd, 'spec')
end

15
deployment_tasks.yaml Normal file
View File

@ -0,0 +1,15 @@
- id: elasticsearch_kibana
type: group
role: [elasticsearch_kibana]
tasks:
- hiera
- globals
- tools
- logging
- netconfig
required_for: [deploy_end]
requires: [deploy_start]
parameters:
strategy:
type: parallel

View File

@ -30,6 +30,7 @@ attributes:
type: "text"
# Parameter hidden in the UI on purpose
# this directory must match the mount point set in volumes.yaml
data_dir:
value: '/opt/es-data'
label: 'Elasticsearch directory'
@ -49,57 +50,3 @@ attributes:
regex:
source: '^([1-9]|[12][0-9]|3[0-2])$'
error: 'Enter a value between 1 and 32'
disk1:
value: ''
label: 'Disk 1'
description: 'Disk device used to store Elasticsearch data (for instance sda). Leave it empty to use "/".'
weight: 20
type: "text"
disk1_size:
value: ''
label: 'Size'
description: 'in GB. Leave it empty to use all free space.'
weight: 30
type: "text"
disk2:
value: ''
label: 'Disk 2'
description: 'Disk device used to store Elasticsearch data (for instance sdb).'
weight: 40
type: "text"
restrictions:
- condition: "settings:elasticsearch_kibana.disk1.value == ''"
action: "disable"
disk2_size:
value: ''
label: 'Size'
description: 'in GB. Leave it empty to use all free space.'
weight: 50
type: "text"
restrictions:
- condition: "settings:elasticsearch_kibana.disk1.value == ''"
action: "disable"
disk3:
value: ''
label: 'Disk 3'
description: 'Disk device used to store Elasticsearch data (for instance sdc).'
weight: 60
type: "text"
restrictions:
- condition: "settings:elasticsearch_kibana.disk2.value == ''"
action: "disable"
disk3_size:
value: ''
label: 'Size'
description: 'in GB. Leave it empty to use all free space.'
weight: 70
type: "text"
restrictions:
- condition: "settings:elasticsearch_kibana.disk2.value == ''"
action: "disable"

View File

@ -7,7 +7,7 @@ version: '0.8.0'
# Description
description: Deploy Elasticsearch server and the Kibana web interface (refer to the Elasticsearch-Kibana user guide for instructions).
# Required fuel version
fuel_version: ['6.1', '7.0']
fuel_version: ['7.0']
# Licences
licenses: ['Apache License Version 2.0']
# Specify author or company name
@ -23,16 +23,6 @@ releases:
mode: ['ha']
deployment_scripts_path: deployment_scripts/
repository_path: repositories/ubuntu
- os: ubuntu
version: 2014.2-6.1
mode: ['ha', 'multinode']
deployment_scripts_path: deployment_scripts/
repository_path: repositories/ubuntu
- os: centos
version: 2014.2-6.1
mode: ['ha', 'multinode']
deployment_scripts_path: deployment_scripts/
repository_path: repositories/centos
# Version of plugin package
package_version: '2.0.0'
package_version: '3.0.0'

13
node_roles.yaml Normal file
View File

@ -0,0 +1,13 @@
elasticsearch_kibana:
name: 'Elasticsearch Kibana'
description: 'Install Elasticsearch and Kibana'
has_primary: false
public_ip_required: false
weight: 100
limits:
max: 1
conflicts:
- controller
- compute
- cinder
- ceph-osd

View File

@ -1,5 +1,5 @@
# This task is executed before any real deployment task
- role: ['base-os']
- role: ['elasticsearch_kibana']
stage: post_deployment/8000
type: puppet
parameters:
@ -8,15 +8,7 @@
timeout: 300
# The following tasks are executed in the order they are declared
- role: ['base-os']
stage: post_deployment/8100
type: puppet
parameters:
puppet_manifest: puppet/manifests/netconfig.pp
puppet_modules: /etc/puppet/modules
timeout: 720
- role: ['base-os']
- role: ['elasticsearch_kibana']
stage: post_deployment/8100
type: puppet
parameters:
@ -24,29 +16,13 @@
puppet_modules: /etc/puppet/modules
timeout: 300
- role: ['base-os']
stage: post_deployment/8100
type: puppet
parameters:
puppet_manifest: puppet/manifests/setup_disks.pp
puppet_modules: puppet/modules
timeout: 600
- role: ['base-os']
- role: ['elasticsearch_kibana']
stage: post_deployment/8100
type: reboot
parameters:
timeout: 600
- role: ['base-os']
stage: post_deployment/8100
type: puppet
parameters:
puppet_manifest: puppet/manifests/setup_esdir.pp
puppet_modules: puppet/modules
timeout: 600
- role: ['base-os']
- role: ['elasticsearch_kibana']
stage: post_deployment/8100
type: puppet
parameters:
@ -54,7 +30,7 @@
puppet_modules: puppet/modules
timeout: 600
- role: ['base-os']
- role: ['elasticsearch_kibana']
stage: post_deployment/8100
type: puppet
parameters:

15
tox.ini
View File

@ -1,5 +1,5 @@
[tox]
envlist = lma_logging_analytics,disk_management
envlist = lma_logging_analytics
skipsdist = True
[testenv:lma_logging_analytics]
@ -14,16 +14,3 @@ commands =
mkdir -p {toxinidir}/.bundled_gems
bundle install
bundle exec rake test
[testenv:disk_management]
deps =
changedir = {toxinidir}/deployment_scripts/puppet/modules/{envname}
whitelist_externals =
bundle
mkdir
setenv =
GEM_HOME={toxinidir}/.bundled_gems
commands =
mkdir -p {toxinidir}/.bundled_gems
bundle install
bundle exec rake test

22
volumes.yaml Normal file
View File

@ -0,0 +1,22 @@
volumes:
- id: "elasticsearch"
type: "vg"
min_size:
generator: "calc_gb_to_mb"
generator_args: [30]
label: "Elasticsearch database"
volumes:
- mount: "/opt/es-data"
type: "lv"
name: "elasticsearch"
file_system: "ext4"
size:
generator: "calc_total_vg"
generator_args: ["elasticsearch"]
volumes_roles_mapping:
elasticsearch_kibana:
- {allocate_size: "min", id: "os"}
- {allocate_size: "min", id: "logs"}
- {allocate_size: "all", id: "elasticsearch"}