Skip to content

Instantly share code, notes, and snippets.

Created July 12, 2016 08:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/6552a5c36ba89853e2b7668ee3a94189 to your computer and use it in GitHub Desktop.
Save anonymous/6552a5c36ba89853e2b7668ee3a94189 to your computer and use it in GitHub Desktop.
include_recipe 'tar'
include_recipe 'aws'
splunk_deployment_apps_path = "/opt/splunk/etc/deployment-apps"
kg_apps = "/opt/splunk/kg-apps"
install_path = "#{kg_apps}/new"
tar_filename = "#{kg_apps}/apps.tar.gz"
directory "#{kg_apps}" do
owner 'splunk'
group 'splunk'
mode '0775'
recursive true
action :create
end
directory "#{install_path}" do
recursive true
action :delete
end
aws_s3_file tar_filename do
bucket node['bucket']['deployment']['name']
remote_path "#{node['environment']['name']}/#{node['project']['name']}/#{node['repository']['name']}/app.tar.gz"
end
directory "#{install_path}" do
recursive true
action :create
end
tar_extract tar_filename do
target_dir "#{install_path}"
creates "#{install_path}/REVISION"
action :extract_local
end
file tar_filename do
action :delete
end
directory "#{kg_apps}/old" do
recursive true
action :delete
end
ruby_block "Enable" do
block do
if Dir.exists?("#{kg_apps}/new")
if Dir.exists?("#{kg_apps}/current")
::File.rename("#{kg_apps}/current", "#{kg_apps}/old")
end
::File.rename("#{kg_apps}/new", "#{kg_apps}/current")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment