Skip to content
Snippets Groups Projects
Commit a44cc480 authored by Paul Ilea's avatar Paul Ilea
Browse files

[TASK] Implement fallback to ubuntu_base configuration

parent f534b438
No related branches found
No related tags found
No related merge requests found
default['typo3_site']['ip_address'] = '' default['typo3_site']['ip_address'] = false
default['typo3_site']['hostname'] = false
default['typo3_site']['webroot'] = '/var/www' default['typo3_site']['webroot'] = '/var/www'
default['typo3_site']['site_configuration'] = 'SiteConfiguration.php' default['typo3_site']['site_configuration'] = 'SiteConfiguration.php'
default['typo3_site']['server_aliases'] = 'www.site.dev' default['typo3_site']['server_aliases'] = 'www.site.dev'
default['typo3_site']['hostname'] = 'site.dev'
default['typo3_site']['web_directory'] = '' default['typo3_site']['web_directory'] = ''
default['typo3_site']['allow_http2'] = false default['typo3_site']['allow_http2'] = false
default['typo3_site']['repository'] = '' default['typo3_site']['repository'] = ''
......
...@@ -24,16 +24,19 @@ ...@@ -24,16 +24,19 @@
data_bag = data_bag_item('apps', 'global') data_bag = data_bag_item('apps', 'global')
base_ip_address = node['typo3_site']['ip_address'] || node['ubuntu_base']['ip_address']
base_hostname = node['typo3_site']['hostname'] || node['ubuntu_base']['hostname']
########################## ##########################
### Add hostname entry ### ### Add hostname entry ###
########################## ##########################
hostsfile_entry node['typo3_site']['ip_address'] do hostsfile_entry node['ubuntu_base']['ip_address'] do
hostname node['typo3_site']['hostname'] hostname base_hostname
action :append action :append
end end
hostsfile_entry node['typo3_site']['ip_address'] do hostsfile_entry node['ubuntu_base']['ip_address'] do
hostname node['typo3_site']['server_aliases'] hostname node['typo3_site']['server_aliases']
action :append action :append
end end
...@@ -277,29 +280,35 @@ end ...@@ -277,29 +280,35 @@ end
# concatenate the additional optional domains in order to avoid missing index exceptions # concatenate the additional optional domains in order to avoid missing index exceptions
additional_domains = '' additional_domains = ''
if node.include?('xhprof') && node['xhprof'].include?('hostname') if node.include?('xhprof') && node['xhprof'].include?('hostname') && node['xhprof']['hostname']
additional_domains = additional_domains + ' ' + node['xhprof']['hostname'] additional_domains = additional_domains + ' ' + node['xhprof']['hostname']
else
additional_domains = additional_domains + ' xhprof.' + base_hostname
end end
if node.include?('webgrind') && node['webgrind'].include?('hostname') if node.include?('webgrind') && node['webgrind'].include?('hostname') && node['webgrind']['hostname']
additional_domains = additional_domains + ' ' + node['webgrind']['hostname'] additional_domains = additional_domains + ' ' + node['webgrind']['hostname']
else
additional_domains = additional_domains + ' webgrind.' + base_hostname
end end
if node.include?('mailhog') && node['mailhog'].include?('hostname') if node.include?('mailhog') && node['mailhog'].include?('hostname') && node['mailhog']['hostname']
additional_domains = additional_domains + ' ' + node['mailhog']['hostname'] additional_domains = additional_domains + ' ' + node['mailhog']['hostname']
else
additional_domains = additional_domains + ' mailhog.' + base_hostname
end end
bash 'Create Certificate' do bash 'Create Certificate' do
cwd '/etc/apache2/ssl/' cwd '/etc/apache2/ssl/'
code <<-EOF code <<-EOF
chmod 755 create_certificate_for_domain.sh chmod 755 create_certificate_for_domain.sh
./create_certificate_for_domain.sh #{node['typo3_site']['hostname']} #{node['typo3_site']['server_aliases']}#{additional_domains} ./create_certificate_for_domain.sh #{base_hostname} #{node['typo3_site']['server_aliases']}#{additional_domains}
EOF EOF
action :run action :run
end end
# create vHost directory # create vHost directory
directory "#{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}" do directory "#{node['typo3_site']['webroot']}/#{base_hostname}" do
owner 'vagrant' owner 'vagrant'
group data_bag['groupId'] group data_bag['groupId']
mode '0755' mode '0755'
...@@ -308,17 +317,17 @@ end ...@@ -308,17 +317,17 @@ end
# create web app with an own virtual host # create web app with an own virtual host
if node['platform_version'] == '16.04' if node['platform_version'] == '16.04'
web_app node['typo3_site']['hostname'] do web_app base_hostname do
template 'vHost-xenial.conf.erb' template 'vHost-xenial.conf.erb'
docroot "#{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}/#{node['typo3_site']['web_directory']}/" docroot "#{node['typo3_site']['webroot']}/#{base_hostname}/#{node['typo3_site']['web_directory']}/"
server_name node['typo3_site']['hostname'] server_name base_hostname
server_aliases node['typo3_site']['server_aliases'] server_aliases node['typo3_site']['server_aliases']
end end
else else
web_app node['typo3_site']['hostname'] do web_app base_hostname do
template 'vHost.conf.erb' template 'vHost.conf.erb'
docroot "#{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}/#{node['typo3_site']['web_directory']}/" docroot "#{node['typo3_site']['webroot']}/#{base_hostname}/#{node['typo3_site']['web_directory']}/"
server_name node['typo3_site']['hostname'] server_name base_hostname
server_aliases node['typo3_site']['server_aliases'] server_aliases node['typo3_site']['server_aliases']
server_aliases node['typo3_site']['server_aliases'] server_aliases node['typo3_site']['server_aliases']
end end
...@@ -351,7 +360,7 @@ if node['typo3_site']['repository'] != '' ...@@ -351,7 +360,7 @@ if node['typo3_site']['repository'] != ''
port node['typo3_site']['repository_port'] port node['typo3_site']['repository_port']
end end
git "#{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}" do git "#{node['typo3_site']['webroot']}/#{base_hostname}" do
repository node['typo3_site']['repository'] repository node['typo3_site']['repository']
remote 'origin' remote 'origin'
revision 'master' revision 'master'
...@@ -386,8 +395,8 @@ bash 'Setup TYPO3' do ...@@ -386,8 +395,8 @@ bash 'Setup TYPO3' do
-C #{node['typo3_site']['webroot']}/typo3_src-#{node['typo3_site']['typo3_version']}; -C #{node['typo3_site']['webroot']}/typo3_src-#{node['typo3_site']['typo3_version']};
fi fi
mkdir -p #{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}/#{node['typo3_site']['web_directory']} mkdir -p #{node['typo3_site']['webroot']}/#{base_hostname}/#{node['typo3_site']['web_directory']}
cd #{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}/#{node['typo3_site']['web_directory']} cd #{node['typo3_site']['webroot']}/#{base_hostname}/#{node['typo3_site']['web_directory']}
rm -f typo3_src rm -f typo3_src
ln -s ../typo3_src-#{node['typo3_site']['typo3_version']} typo3_src ln -s ../typo3_src-#{node['typo3_site']['typo3_version']} typo3_src
touch typo3conf/ENABLE_INSTALL_TOOL touch typo3conf/ENABLE_INSTALL_TOOL
...@@ -422,19 +431,19 @@ node['typo3_site']['sync_directories'].each do |sync_data| ...@@ -422,19 +431,19 @@ node['typo3_site']['sync_directories'].each do |sync_data|
group data_bag['groupId'] group data_bag['groupId']
timeout 3000000 timeout 3000000
only_if { only_if {
sync_data['sync'] or not ::File.exists?("#{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}/#{node['typo3_site']['web_directory']}/#{sync_data['local']}") sync_data['sync'] or not ::File.exists?("#{node['typo3_site']['webroot']}/#{base_hostname}/#{node['typo3_site']['web_directory']}/#{sync_data['local']}")
} }
if sync_data['hostname'] if sync_data['hostname']
code <<-EOF code <<-EOF
rsync --delete -auvz --progress -e "ssh -p #{sync_data['port']} -o StrictHostKeyChecking=no" \ rsync --delete -auvz --progress -e "ssh -p #{sync_data['port']} -o StrictHostKeyChecking=no" \
--no-o --no-g #{sync_data['user']}@#{sync_data['hostname']}:#{sync_data['remote']} \ --no-o --no-g #{sync_data['user']}@#{sync_data['hostname']}:#{sync_data['remote']} \
"#{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}/#{node['typo3_site']['web_directory']}/#{sync_data['local']}"; "#{node['typo3_site']['webroot']}/#{base_hostname}/#{node['typo3_site']['web_directory']}/#{sync_data['local']}";
EOF EOF
else else
code <<-EOF code <<-EOF
rsync --delete -auvz --progress --no-o --no-g #{sync_data['remote']} \ rsync --delete -auvz --progress --no-o --no-g #{sync_data['remote']} \
"#{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}/#{node['typo3_site']['web_directory']}/#{sync_data['local']}"; "#{node['typo3_site']['webroot']}/#{base_hostname}/#{node['typo3_site']['web_directory']}/#{sync_data['local']}";
EOF EOF
end end
action :run action :run
...@@ -460,13 +469,13 @@ end ...@@ -460,13 +469,13 @@ end
### Provide site specific configuration ### ### Provide site specific configuration ###
########################################### ###########################################
directory "#{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}/#{node['typo3_site']['web_directory']}/typo3conf/" do directory "#{node['typo3_site']['webroot']}/#{base_hostname}/#{node['typo3_site']['web_directory']}/typo3conf/" do
owner 'vagrant' owner 'vagrant'
mode '0755' mode '0755'
action :create action :create
end end
template "#{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}/#{node['typo3_site']['web_directory']}/typo3conf/#{node['typo3_site']['site_configuration']}" do template "#{node['typo3_site']['webroot']}/#{base_hostname}/#{node['typo3_site']['web_directory']}/typo3conf/#{node['typo3_site']['site_configuration']}" do
source 'SiteConfiguration.php.erb' source 'SiteConfiguration.php.erb'
owner 'vagrant' owner 'vagrant'
mode '0660' mode '0660'
...@@ -475,7 +484,7 @@ template "#{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}/#{n ...@@ -475,7 +484,7 @@ template "#{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}/#{n
}) })
end end
template "#{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}/#{node['typo3_site']['web_directory']}/typo3conf/AdditionalConfiguration.php" do template "#{node['typo3_site']['webroot']}/#{base_hostname}/#{node['typo3_site']['web_directory']}/typo3conf/AdditionalConfiguration.php" do
source 'AdditionalConfiguration.php' source 'AdditionalConfiguration.php'
owner 'vagrant' owner 'vagrant'
mode '0660' mode '0660'
...@@ -620,7 +629,7 @@ if node['typo3_site']['solr']['init'] ...@@ -620,7 +629,7 @@ if node['typo3_site']['solr']['init']
end end
execute 'solr-updateConnections' do execute 'solr-updateConnections' do
command "php #{node['typo3_site']['webroot']}/#{node['typo3_site']['hostname']}/#{node['typo3_site']['web_directory']}/typo3/cli_dispatch.phpsh extbase solr:updateconnections || true" command "php #{node['typo3_site']['webroot']}/#{base_hostname}/#{node['typo3_site']['web_directory']}/typo3/cli_dispatch.phpsh extbase solr:updateconnections || true"
user 'vagrant' user 'vagrant'
group data_bag['groupId'] group data_bag['groupId']
action :run action :run
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment