Created
July 12, 2016 08:56
-
-
Save anonymous/6552a5c36ba89853e2b7668ee3a94189 to your computer and use it in GitHub Desktop.
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
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