diff --git a/metadata.rb b/metadata.rb index 675795a..a632777 100644 --- a/metadata.rb +++ b/metadata.rb @@ -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 diff --git a/providers/install.rb b/providers/install.rb index 2f551e0..a280a69 100644 --- a/providers/install.rb +++ b/providers/install.rb @@ -11,8 +11,6 @@ require 'chef/mixin/language' include Chef::Mixin::ShellOut -use_inline_resources - def load_current_resource @kibana_resource = new_resource.clone end @@ -20,57 +18,64 @@ def load_current_resource 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 diff --git a/providers/user.rb b/providers/user.rb index 41f3b68..cfc6e33 100644 --- a/providers/user.rb +++ b/providers/user.rb @@ -11,8 +11,6 @@ require 'chef/mixin/language' include Chef::Mixin::ShellOut -use_inline_resources - def load_current_resource @user = new_resource.user @group = new_resource.group || @user @@ -20,30 +18,34 @@ def load_current_resource 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 diff --git a/providers/web.rb b/providers/web.rb index 30103ff..fdf6891 100644 --- a/providers/web.rb +++ b/providers/web.rb @@ -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 @@ -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] @@ -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]' @@ -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