This repository has been archived by the owner on Mar 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 65
Big cookbook refactoring #101
Open
cyberflow
wants to merge
18
commits into
realityforge:master
Choose a base branch
from
cyberflow:features/lwrp_install
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+940
−916
Open
Changes from 4 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
41f2f17
Big cookbook refactoring
cyberflow 2f80dd9
add support ngonx proxy for kibana 5
cyberflow a17da4f
fix configuration merge in resource provider
cyberflow fc35faa
fix service cofigure condition
cyberflow e1943f3
fix upstart config file permission to 0o0644
cyberflow e572d84
fix condition for upstart template
cyberflow 2ac5902
add support for centos 6 installs
9009b1c
fix rubocop warnings
0cb0da6
update README
eefce27
add version to package install
0ade5ee
fix conditional to regex to match all 4.x versions
cyberflow cc52f9a
Remove deprecated compact resource and matchers
gopisaba e563378
Merge pull request #1 from gopisaba/remove_compact_resource
chrisminton 1dfe993
Merge pull request #1 from chrisminton/lwrp_install-rhel
cyberflow d2dc5f0
Remove deprecated chef_nginx cookbook to enable Chef 13+ usage
ef21e53
Merge pull request #2 from chrisminton/remove-chef-nginx
cyberflow 750c78b
remove deprecated supports manage_home
gopisaba 73b17e5
Merge pull request #3 from gopisaba/chef-12-dep
cyberflow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
~FC057 | ||
~FC007 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,7 @@ test/* | |
features/* | ||
Guardfile | ||
Procfile | ||
test | ||
|
||
# SCM # | ||
####### | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
module KibanaCookbook | ||
# Helper methods included by various providers and passed to the template engine | ||
module Helpers | ||
def determine_version(new_resource, node) | ||
if new_resource.version | ||
new_resource.version.to_s | ||
elsif node['kibana'] && node['kibana']['version'] | ||
node['kibana']['version'].to_s | ||
else | ||
raise 'could not determine version of kibana to install' | ||
end | ||
end | ||
|
||
def determine_install_type(new_resource, node) | ||
if new_resource.type | ||
new_resource.type.to_s | ||
elsif node['kibana'] && node['kibana']['install_type'] | ||
node['kibana']['install_type'].to_s | ||
else | ||
raise 'could not determine how to install kibana (package? tarball?)' | ||
end | ||
end | ||
|
||
def determine_repository_url(new_resource, node) | ||
# TODO: add support version 5.x | ||
# platform_family = node['platform_family'] | ||
# url_string = nil | ||
if new_resource.repository_url | ||
# url_string = new_resource.repository_url | ||
new_resource.repository_url | ||
else | ||
# url_string = node['kibana']['repository_url'] | ||
node['kibana']['repository_url'] | ||
end | ||
end | ||
|
||
def determine_download_url(new_resource, node) | ||
# platform_family = node['platform_family'] | ||
install_type = determine_install_type(new_resource, node) | ||
version = determine_version(new_resource, node) | ||
arch = determine_arch | ||
ext = determine_ext | ||
|
||
# url_string = nil | ||
if new_resource.download_url | ||
new_resource.download_url | ||
elsif install_type.to_s == 'tar' || install_type.to_s == 'tarball' | ||
prefix = 'https://download.elastic.co/kibana/kibana/kibana-' | ||
suffix = "#{version}-#{node['os']}-#{arch}.#{ext}" | ||
prefix + suffix | ||
else | ||
raise 'could not determine url for install kibana' | ||
end | ||
|
||
# return url_string | ||
end | ||
|
||
def determine_download_checksum(new_resource, node) | ||
# platform_family = node['platform_family'] | ||
install_type = determine_install_type(new_resource, node) | ||
version = determine_version(new_resource, node) | ||
|
||
if new_resource.download_checksum | ||
new_resource.download_checksum | ||
elsif install_type.to_s == 'tar' || install_type.to_s == 'tarball' | ||
node && version && | ||
node['kibana'] && | ||
node['kibana']['checksums'] && | ||
node['kibana']['checksums'][version] && | ||
node['kibana']['checksums'][version]['tar'] | ||
end | ||
end | ||
|
||
def find_kb_resource(run_context, resource_type, resource) | ||
resource_name = resource.name | ||
|
||
# if we are truly given a specific name to find | ||
name_match = find_exact_resource(run_context, resource_type, resource_name) rescue nil | ||
return name_match if name_match | ||
|
||
# otherwise try the defaults | ||
name_default = find_exact_resource(run_context, resource_type, 'default') rescue nil | ||
name_kibana = find_exact_resource(run_context, resource_type, 'kibana') rescue nil | ||
|
||
# if we found exactly one default name that matched | ||
return name_default if name_default && !name_kibana | ||
return name_kibana if name_kibana && !name_default | ||
|
||
raise "Could not find exactly one #{resource_type} resource, and no specific resource or instance name was given" | ||
end | ||
|
||
# find exactly the resource name and type, but raise if there's multiple matches | ||
# see https://github.com/chef/chef/blob/master/lib/chef/resource_collection/resource_set.rb#L80 | ||
def find_exact_resource(run_context, resource_type, resource_name) | ||
rc = run_context.resource_collection | ||
result = rc.find(resource_type => resource_name) | ||
|
||
if result && result.is_a?(Array) | ||
str = '' | ||
str << "more than one #{resource_type} was found, " | ||
str << 'you must specify a precise resource name' | ||
raise str | ||
end | ||
|
||
result | ||
end | ||
|
||
# def find_instance_name_resource(run_context, resource_type, instance_name) | ||
# results = [] | ||
# rc = run_context.resource_collection | ||
|
||
# rc.each do |r| | ||
# next unless r.resource_name == resource_type | ||
# results << r | ||
# end | ||
|
||
# if !results.empty? && results.length > 1 | ||
# str = '' | ||
# str << "more than one #{resource_type} was found, " | ||
# str << 'you must specify a precise instance name' | ||
# raise str | ||
# elsif !results.empty? | ||
# return results.first | ||
# end | ||
|
||
# return nil # falsey | ||
# end | ||
|
||
def determine_ext | ||
case node['os'] | ||
when 'windows' | ||
'zip' | ||
else | ||
'tar.gz' | ||
end | ||
end | ||
|
||
def determine_arch | ||
return '' if node['os'] == 'windows' | ||
case node['kernel']['machine'] | ||
when 'x86_64' | ||
'x86_64' | ||
else | ||
'-x86' | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably need to make this conditional test a regex (
=~ /^4/
) to match all 4.x versions