Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Add Bitbucket Server 4.0 Support #116

Merged
merged 8 commits into from
Oct 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ driver_config:
memory: 1024

platforms:
- name: centos-6
- name: centos-6.7
driver_config:
box: chef/centos-6.6
box: chef/centos-6.7
run_list:
- recipe[yum]
- name: centos-7
- name: centos-7.1
driver_config:
box: chef/centos-7.0
box: chef/centos-7.1
run_list:
- recipe[yum]
- name: ubuntu-12.04
Expand All @@ -34,8 +34,8 @@ platforms:
default_attributes: &DEFAULT_ATTRIBUTES
java:
install_flavor: oracle
java_home: /usr/lib/jvm/java-7-oracle
jdk_version: 7
java_home: /usr/lib/jvm/java-8-oracle
jdk_version: 8
oracle:
accept_oracle_download_terms: true

Expand Down
8 changes: 4 additions & 4 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ Vagrant.configure('2') do |config|
config.omnibus.chef_version = :latest

config.vm.define :centos6 do |centos6|
centos6.vm.box = 'chef/centos-6.6'
centos6.vm.box = 'chef/centos-6.7'
centos6.vm.hostname = "#{cookbook}-centos-6"
end

config.vm.define :centos7 do |centos7|
centos7.vm.box = 'chef/centos-7.0'
centos7.vm.box = 'chef/centos-7.1'
centos7.vm.hostname = "#{cookbook}-centos-7"
end

Expand Down Expand Up @@ -67,8 +67,8 @@ Vagrant.configure('2') do |config|
chef.json = {
'java' => {
'install_flavor' => 'oracle',
'java_home' => '/usr/lib/jvm/java-7-oracle',
'jdk_version' => '7',
'java_home' => '/usr/lib/jvm/java-8-oracle',
'jdk_version' => '8',
'oracle' => {
'accept_oracle_download_terms' => true
}
Expand Down
30 changes: 18 additions & 12 deletions attributes/default.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
set['build_essential']['compiletime'] = true
set['build-essential']['compile_time'] = true

default['stash']['home_path'] = '/var/atlassian/application-data/stash'
default['stash']['version'] = '4.0.1'
default['stash']['product'] = Chef::Version.new(node['stash']['version']) >= Chef::Version.new('4.0.0') ? 'bitbucket' : 'stash'

default['stash']['home_path'] = "/var/atlassian/application-data/#{node['stash']['product']}"
default['stash']['install_path'] = '/opt/atlassian'
default['stash']['install_type'] = 'standalone'
default['stash']['service_type'] = 'init'
default['stash']['url_base'] = 'http://www.atlassian.com/software/stash/downloads/binary/atlassian-stash'
default['stash']['user'] = 'stash'
default['stash']['version'] = '3.11.1'
default['stash']['url_base'] = "http://www.atlassian.com/software/stash/downloads/binary/atlassian-#{node['stash']['product']}"
default['stash']['user'] = node['stash']['product']

default['stash']['url'] = "#{node['stash']['url_base']}-#{node['stash']['version']}.tar.gz"
default['stash']['checksum'] =
Expand Down Expand Up @@ -114,6 +116,7 @@
when '3.10.0' then 'ab7fecb10e6650fb5b94a20b22463771d7ab0f69a0971272d1a066dd2430f048'
when '3.10.2' then '2597e9954397af5016c30c9f90befd09c6da71c4e7745813c77e60329427989e'
when '3.11.1' then '7db6327554e3481a8b351188991f5858d01aeebce3f9bc290da5ad9d0fbfe1e7'
when '4.0.1' then 'f59462077fa4ccc522b7bbf1ad6ebef4753cd0e41abf54bc0491d07eea40593d'
end

default['stash']['apache2']['access_log'] = ''
Expand Down Expand Up @@ -151,23 +154,25 @@
default['stash']['backup']['cron']['weekday'] = '*'

default['stash']['backup_client']['install_path'] = node['stash']['install_path']
default['stash']['backup_client']['password'] = 'changeit'
default['stash']['backup_client']['user'] = 'admin'
default['stash']['backup_client']['version'] = '1.9.1'
default['stash']['backup_client']['version'] = '2.0.0'
stash_backup_client_version = Chef::Version.new(node['stash']['backup_client']['version'])

default['stash']['backup_client']['url_base'] =
if stash_backup_client_version <= Chef::Version.new('1.2.1')
'http://downloads.atlassian.com/software/stash/downloads/stash-backup-client'
else
elsif stash_backup_client_version < Chef::Version.new('2.0.0')
'https://maven.atlassian.com/public/com/atlassian/stash/backup/stash-backup-distribution/'
else
'https://maven.atlassian.com/repository/public/com/atlassian/bitbucket/server/backup/bitbucket-backup-distribution/'
end

default['stash']['backup_client']['url'] =
if stash_backup_client_version <= Chef::Version.new('1.2.1')
"#{node['stash']['backup_client']['url_base']}-#{node['stash']['backup_client']['version']}.zip"
else
elsif stash_backup_client_version < Chef::Version.new('2.0.0')
"#{node['stash']['backup_client']['url_base']}/#{node['stash']['backup_client']['version']}/stash-backup-distribution-#{node['stash']['backup_client']['version']}.zip"
else
"#{node['stash']['backup_client']['url_base']}/#{node['stash']['backup_client']['version']}/bitbucket-backup-distribution-#{node['stash']['backup_client']['version']}.zip"
end

default['stash']['backup_client']['checksum'] =
Expand All @@ -188,6 +193,7 @@
when '1.8.2' then 'ff41c353f73fe90cb0e67860cff7b021833e23df6c49232d1b102a0eae575127'
when '1.9.0' then '620776f107a9c10f57f59e52be795621f0f0b8277805e28fff7dc664bbb48fb3'
when '1.9.1' then '3cdad3393611d2c8d151c7d265ebd04764cbaba4a4d745a8b534dd9b8cf77d7b'
when '2.0.0' then '2d9113ef6e173a65587b373ecc247b58ea8fab5ea826541b1d309ad0402a67be'
end

default['stash']['backup_diy']['install_path'] = "#{node['stash']['install_path']}/stash-diy-backup"
Expand All @@ -211,10 +217,10 @@
default['stash']['database']['version'] = nil

default['stash']['database']['host'] = '127.0.0.1'
default['stash']['database']['name'] = 'stash'
default['stash']['database']['name'] = node['stash']['product']
default['stash']['database']['password'] = 'changeit'
default['stash']['database']['testInterval'] = 2
default['stash']['database']['user'] = 'stash'
default['stash']['database']['user'] = node['stash']['product']

# See `libraries/stash.rb` for code to set actual default port
default['stash']['database']['port'] = nil
Expand Down
14 changes: 8 additions & 6 deletions libraries/stash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,17 @@ def self.default_database_port(type)

def self.check_for_old_attributes!(node)
backup_attrs = %w(backup_path baseurl password user cron)
show_warn = false
backup_attrs.each do |attr|
unless node['stash']['backup_client'][attr].nil?
node.default['stash']['backup_client'][attr] = node['stash']['backup'][attr]
Chef::Log.warn "node['stash']['backup_client']['#{attr}'] has been changed to node['stash']['backup']['#{attr}']"
end
next if node['stash']['backup_client'][attr].nil?

node.default['stash']['backup'][attr] = node['stash']['backup_client'][attr]
Chef::Log.warn "node['stash']['backup_client']['#{attr}'] has been changed to node['stash']['backup']['#{attr}']"
show_warn = true
end
Chef::Log.warn <<-EOH
Chef::Log.warn <<-EOH if show_warn
This renaming introduces the common approach for both of backup strategies:
'backup_client' and 'backup_diy'. Attributes metioned above will be gracefully
'backup_client' and 'backup_diy'. Attributes mentioned above will be gracefully
converted for you, but this warning and conversion will be removed in the next
major release of the 'stash' cookbook.
EOH
Expand Down
10 changes: 6 additions & 4 deletions recipes/backup_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
package 'unzip'
package 'rsync'

ark 'stash-backup-client' do
backup_client_install_path = "#{node['stash']['backup_client']['install_path']}/#{node['stash']['product']}-backup-client"

ark "#{node['stash']['product']}-backup-client" do
url node['stash']['backup_client']['url']
prefix_root node['stash']['backup_client']['install_path']
prefix_home node['stash']['backup_client']['install_path']
Expand All @@ -22,7 +24,7 @@
variables :backup => settings['backup']
end

link "#{node['stash']['backup_client']['install_path']}/stash-backup-client/backup-config.properties" do
link "#{backup_client_install_path}/backup-config.properties" do
to "#{node['stash']['home_path']}/backup-config.properties"
end

Expand All @@ -33,13 +35,13 @@
not_if { ::Dir.exist?(node['stash']['backup']['backup_path']) }
end

cron_d 'atlassian-stash-backup-client' do
cron_d "atlassian-#{node['stash']['product']}-backup-client" do
hour settings['backup']['cron']['hour']
minute settings['backup']['cron']['minute']
day settings['backup']['cron']['day']
month settings['backup']['cron']['month']
weekday settings['backup']['cron']['weekday']
command "java -jar #{node['stash']['backup_client']['install_path']}/stash-backup-client/stash-backup-client.jar"
command "java -jar #{backup_client_install_path}/#{node['stash']['product']}-backup-client.jar"
user node['stash']['user']
action(settings['backup']['cron']['enable'] ? :create : :delete)
end
20 changes: 15 additions & 5 deletions recipes/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,29 @@
# Config path changed to shared/ from 3.2.0
# https://confluence.atlassian.com/display/STASHKB/Upgrading+your+Stash+home+directory+for+Stash+3.2+manually
if stash_version >= Chef::Version.new('3.2.0')
config_path = 'shared/'
directory("#{node['stash']['home_path']}/#{config_path}") do
if node['stash']['product'] == 'stash'
config_path = 'shared/stash-config.properties'
else
config_path = 'shared/bitbucket.properties'

# delete old config file from stash, when both configs exist, bitbucket will not start
file "#{node['stash']['home_path']}/shared/stash-config.properties" do
action :delete
end
end

directory("#{node['stash']['home_path']}/shared") do
owner node['stash']['user']
group node['stash']['user']
mode '0755'
action :create
recursive true
end
else
config_path = '/'
config_path = '/stash-config.properties'
end

template "#{node['stash']['home_path']}/#{config_path}stash-config.properties" do
template "#{node['stash']['home_path']}/#{config_path}" do
source 'stash-config.properties.erb'
owner node['stash']['user']
mode '0644'
Expand All @@ -26,5 +36,5 @@
:plugin => settings['plugin'],
:properties => settings['properties']
)
notifies :restart, 'service[stash]', :delayed
notifies :restart, "service[#{node['stash']['product']}]", :delayed
end
2 changes: 1 addition & 1 deletion recipes/linux_standalone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
recursive true
end

ark 'stash' do
ark node['stash']['product'] do
url node['stash']['url']
prefix_root node['stash']['install_path']
prefix_home node['stash']['install_path']
Expand Down
24 changes: 20 additions & 4 deletions recipes/service_init.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
template '/etc/init.d/stash' do
source 'stash.init.erb'
template "/etc/init.d/#{node['stash']['product']}" do
if node['stash']['product'] == 'stash'
source 'stash.init.erb'
else
source 'bitbucket/bitbucket.init.erb'
end
mode '0755'
notifies :restart, 'service[stash]', :delayed
notifies :restart, "service[#{node['stash']['product']}]", :delayed
end

service 'stash' do
# disable stash service after upgrade to bitbucket 4.0
if node['stash']['product'] == 'bitbucket'
service 'stash' do
supports :status => true, :restart => true
action [:stop, :disable]
end

file '/etc/init.d/stash' do
action :delete
end
end

service node['stash']['product'] do
supports :status => true, :restart => true
action [:enable]
subscribes :restart, 'java_ark[jdk]'
Expand Down
36 changes: 25 additions & 11 deletions recipes/tomcat_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@
server_xml_path = "#{node['stash']['home_path']}/shared/server.xml"
end

template "#{node['stash']['install_path']}/stash/bin/setenv.sh" do
template "#{node['stash']['install_path']}/#{node['stash']['product']}/bin/setenv.sh" do
if stash_version < Chef::Version.new('3.8.0')
source 'setenv.sh.erb'
else
elsif node['stash']['product'] == 'stash'
source '3.8+/setenv.sh.erb'
else
source 'bitbucket/setenv.sh.erb'
end
owner node['stash']['user']
mode '0755'
notifies :restart, 'service[stash]', :delayed
notifies :restart, "service[#{node['stash']['product']}]", :delayed
end

template server_xml_path do
Expand All @@ -24,31 +26,43 @@
source 'server-tomcat7.xml.erb'
elsif stash_version < Chef::Version.new('3.8.0')
source 'server-tomcat8.xml.erb'
else
elsif node['stash']['product'] == 'stash'
source '3.8+/server.xml.erb'
else
source 'bitbucket/server.xml.erb'
end
owner node['stash']['user']
mode '0640'
variables :tomcat => settings['tomcat']
notifies :restart, 'service[stash]', :delayed
notifies :restart, "service[#{node['stash']['product']}]", :delayed
end

template "#{node['stash']['install_path']}/stash/conf/web.xml" do
template "#{node['stash']['install_path']}/#{node['stash']['product']}/conf/web.xml" do
if stash_version.major == 1
source 'web.xml.erb'
elsif stash_version < Chef::Version.new('3.8.0')
source 'web-tomcat7.xml.erb'
else
elsif node['stash']['product'] == 'stash'
source '3.8+/web.xml'
else
source 'bitbucket/web.xml'
end
owner node['stash']['user']
mode '0644'
notifies :restart, 'service[stash]', :delayed
notifies :restart, "service[#{node['stash']['product']}]", :delayed
end

directory '/var/run/stash' do
owner 'stash'
group 'stash'
directory "/var/run/#{node['stash']['product']}" do
owner node['stash']['user']
group node['stash']['user']
mode '0755'
action :create
end

template "#{node['stash']['install_path']}/bitbucket/bin/user.sh" do
source 'bitbucket/user.sh.erb'
owner node['stash']['user']
mode '0755'
notifies :restart, "service[#{node['stash']['product']}]", :delayed
only_if { node['stash']['product'] == 'bitbucket' }
end
Loading