Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Commit

Permalink
revert back to not using use_inline_resources #79
Browse files Browse the repository at this point in the history
  • Loading branch information
paulczar committed Dec 28, 2014
1 parent af6ea9e commit 569d020
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 22 deletions.
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
license 'Apache 2.0'
description 'Installs/Configures kibana'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '1.3.2'
version '1.3.3'

%w(git nginx apache2 ark libarchive).each do |cb|
depends cb
Expand Down
23 changes: 14 additions & 9 deletions providers/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,66 +11,71 @@
require 'chef/mixin/language'
include Chef::Mixin::ShellOut

use_inline_resources

def load_current_resource
@kibana_resource = new_resource.clone
end

action :remove do
kb_args = kibana_resources

directory kb_args[:install_dir] do
res = directory kb_args[:install_dir] do
recursive true
action :delete
end
new_resource.updated_by_last_action(res.updated_by_last_action?)
end

action :create do
kb_args = kibana_resources

directory kb_args[:install_dir] do
res = directory kb_args[:install_dir] do
recursive true
owner kb_args[:user]
group kb_args[:group]
mode '0755'
end
new_resource.updated_by_last_action(res.updated_by_last_action?)

case kb_args[:install_type]
when 'git'
@run_context.include_recipe 'git::default'
git "#{kb_args[:install_dir]}/#{kb_args[:git_branch]}" do
res = git "#{kb_args[:install_dir]}/#{kb_args[:git_branch]}" do
repository kb_args[:git_url]
reference kb_args[:git_branch]
action kb_args[:git_type].to_sym
user kb_args[:user]
end
new_resource.updated_by_last_action(res.updated_by_last_action?)

link "#{kb_args[:install_dir]}/current" do
res = link "#{kb_args[:install_dir]}/current" do
to "#{kb_args[:install_dir]}/#{kb_args[:git_branch]}/src"
end
new_resource.updated_by_last_action(res.updated_by_last_action?)
node.set['kibana'][kb_args[:name]]['web_dir'] = "#{kb_args[:install_dir]}/current/src"

when 'file'
@run_context.include_recipe 'libarchive::default'
case kb_args[:file_type]
when 'tgz', 'zip'
remote_file "#{Chef::Config[:file_cache_path]}/kibana_#{kb_args[:name]}.tar.gz" do
res = remote_file "#{Chef::Config[:file_cache_path]}/kibana_#{kb_args[:name]}.tar.gz" do
checksum kb_args[:file_checksum]
source kb_args[:file_url]
action [:create_if_missing]
end
new_resource.updated_by_last_action(res.updated_by_last_action?)

libarchive_file "kibana_#{kb_args[:name]}.tar.gz" do
res = libarchive_file "kibana_#{kb_args[:name]}.tar.gz" do
path "#{Chef::Config[:file_cache_path]}/kibana_#{kb_args[:name]}.tar.gz"
extract_to kb_args[:install_dir]
owner kb_args[:user]
action [:extract]
end
new_resource.updated_by_last_action(res.updated_by_last_action?)

link "#{kb_args[:install_dir]}/current" do
res = link "#{kb_args[:install_dir]}/current" do
to "#{kb_args[:install_dir]}/kibana-#{kb_args[:file_version]}"
end
new_resource.updated_by_last_action(res.updated_by_last_action?)

node.set['kibana'][kb_args[:name]]['web_dir'] = "#{kb_args[:install_dir]}/current"
end
Expand Down
16 changes: 9 additions & 7 deletions providers/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,41 @@
require 'chef/mixin/language'
include Chef::Mixin::ShellOut

use_inline_resources

def load_current_resource
@user = new_resource.user
@group = new_resource.group || @user
@home = new_resource.home || "/home/#{@user}"
end

action :remove do

user @user do
res = user @user do
home @home
action :remove
end
new_resource.updated_by_last_action(res.updated_by_last_action?)

group @group do
res = group @group do
members @user
action :remove
end
new_resource.updated_by_last_action(res.updated_by_last_action?)
end

action :create do

user @user do
res = user @user do
home @home
system true
action :create
manage_home true
end
new_resource.updated_by_last_action(res.updated_by_last_action?)

group @group do
res = group @group do
members @user
append true
system true
end
new_resource.updated_by_last_action(res.updated_by_last_action?)

end
10 changes: 5 additions & 5 deletions providers/web.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
require 'chef/mixin/language'
include Chef::Mixin::ShellOut

use_inline_resources

def load_current_resource
lolno = new_resource.clone
@kibana_resource = new_resource.clone
end

action :remove do
Expand All @@ -36,7 +34,7 @@ def load_current_resource
@run_context.include_recipe recipe
end

wa = web_app resources[:name] do
res = web_app resources[:name] do
cookbook resources[:template_cookbook]
docroot resources[:docroot]
template resources[:template]
Expand All @@ -49,13 +47,14 @@ def load_current_resource
listen_port resources[:listen_port]
es_scheme resources[:es_scheme]
end
new_resource.updated_by_last_action(res.updated_by_last_action?)

when 'nginx'
node.set['nginx']['default_site_enabled'] = resources[:default_site_enabled]
node.set['nginx']['install_method'] = node['kibana']['nginx']['install_method']
@run_context.include_recipe 'nginx'

template "#{node['nginx']['dir']}/sites-available/#{resources[:name]}" do
res = template "#{node['nginx']['dir']}/sites-available/#{resources[:name]}" do
source resources[:template]
cookbook resources[:template_cookbook]
notifies :reload, 'service[nginx]'
Expand All @@ -70,6 +69,7 @@ def load_current_resource
es_scheme: resources[:es_scheme]
)
end
new_resource.updated_by_last_action(res.updated_by_last_action?)
nginx_site resources[:name]
when ''
# do nothing
Expand Down

0 comments on commit 569d020

Please sign in to comment.