From 2bf5503422cca4a87d5b65e7b6e5d935bee283f4 Mon Sep 17 00:00:00 2001 From: Rudger Gravestein Date: Sun, 14 Dec 2014 12:51:38 +0100 Subject: [PATCH 1/5] Remove usused library --- libraries/virtualhost.rb | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 libraries/virtualhost.rb diff --git a/libraries/virtualhost.rb b/libraries/virtualhost.rb deleted file mode 100644 index 13f6f14..0000000 --- a/libraries/virtualhost.rb +++ /dev/null @@ -1,37 +0,0 @@ -# -# Cookbook Name:: zf2 -# Library:: virtualhost -# -# Copyright (C) 2013 Triple-networks -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -class Chef::Recipe::Virtualhost - def self.settings(node) - if Chef::Config[:solo] - begin - settings = Chef::DataBagItem.load('virtualhost', 'virtualhost')['local'] - rescue - Chef::Log.info('No virtualhost data bag found') - end - else - begin - settings = Chef::EncryptedDataBagItem.load('virtualhost', 'virtualhost')[node.chef_environment] - rescue - Chef::Log.info('No virtualhost encrypted data bag found') - end - end - settings ||= node['virtualhost'] - end -end From 5d7cd20b182c2025bf11ab420ca36fc52bae1f37 Mon Sep 17 00:00:00 2001 From: Rudger Gravestein Date: Sun, 14 Dec 2014 14:00:28 +0100 Subject: [PATCH 2/5] Update virtualhost databag, add environment --- Vagrantfile | 8 ++-- data_bags/virtualhosts/zf2tutorial.json | 63 ++++++++++++++++++++----- recipes/apache2.rb | 10 ++-- 3 files changed, 59 insertions(+), 22 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 60e4cc1..222d2fa 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -50,15 +50,15 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.hostmanager.manage_host = true config.hostmanager.ignore_private_ip = false config.hostmanager.include_offline = true - config.hostmanager.aliases = %w(zf2.dev zf2tutorial.zf2.dev) + # config.hostmanager.aliases = %w(zf2tutorial.zf2.dev) else puts "WARN: Vagrant-hostmanager plugin not detected. Please install the plugin with\n 'vagrant plugin install vagrant-hostmanager' from any other directory\n before continuing." end # Add additional virtualhost aliases Dir[Pathname(__FILE__).dirname.join('data_bags','virtualhosts','*.json')].each do |databagfile| - config.hostmanager.aliases << JSON.parse(Pathname(__FILE__).dirname.join('data_bags','virtualhosts',databagfile).read)['server_name'] - JSON.parse(Pathname(__FILE__).dirname.join('data_bags','virtualhosts',databagfile).read)['server_aliases'].each do |serveralias| + config.hostmanager.aliases << JSON.parse(Pathname(__FILE__).dirname.join('data_bags','virtualhosts',databagfile).read)['development']['server_name'] + JSON.parse(Pathname(__FILE__).dirname.join('data_bags','virtualhosts',databagfile).read)['development']['server_aliases'].each do |serveralias| config.hostmanager.aliases << serveralias end end @@ -68,7 +68,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # vm config - config.vm.hostname = 'zf2.dev' + config.vm.hostname = 'zf2tutorial.zf2.dev' config.vm.box = 'opscode-ubuntu-12.04' config.vm.box_url = 'https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_provisionerless.box' diff --git a/data_bags/virtualhosts/zf2tutorial.json b/data_bags/virtualhosts/zf2tutorial.json index 0eeb7ad..90ebc60 100644 --- a/data_bags/virtualhosts/zf2tutorial.json +++ b/data_bags/virtualhosts/zf2tutorial.json @@ -1,15 +1,56 @@ { "id": "zf2tutorial", - "enable": true, - "create_docroot": false, - "server_name": "zf2tutorial.zf2.dev", - "server_aliases": [ - "zf2tutorial.dev" - ], - "docroot": "/srv/www/zf2tutorial/public", - "directory_index": [ "index.php", "index.html" ], - "directory_options": [ "Indexes", "FollowSymLinks" ], - "template": "web_app.conf.erb", - "allow_override": "all", + "development": { + "enable": true, + "create_docroot": false, + "server_name": "zf2tutorial.zf2.dev", + "server_aliases": [ + "zf2tutorial.dev" + ], + "docroot": "/srv/www/zf2tutorial/public", + "directory_index": [ "index.php", "index.html" ], + "directory_options": [ "Indexes", "FollowSymLinks" ], + "template": "web_app.conf.erb", + "allow_override": "all" + }, + "testing": { + "enable": true, + "create_docroot": false, + "server_name": "zf2tutorial.zf2.dev", + "server_aliases": [ + "zf2tutorial.dev" + ], + "docroot": "/srv/www/zf2tutorial/public", + "directory_index": [ "index.php", "index.html" ], + "directory_options": [ "Indexes", "FollowSymLinks" ], + "template": "web_app.conf.erb", + "allow_override": "all" + }, + "acceptance": { + "enable": true, + "create_docroot": false, + "server_name": "zf2tutorial.zf2.dev", + "server_aliases": [ + "zf2tutorial.dev" + ], + "docroot": "/srv/www/zf2tutorial/public", + "directory_index": [ "index.php", "index.html" ], + "directory_options": [ "Indexes", "FollowSymLinks" ], + "template": "web_app.conf.erb", + "allow_override": "all" + }, + "production": { + "enable": true, + "create_docroot": false, + "server_name": "zf2tutorial.zf2.dev", + "server_aliases": [ + "zf2tutorial.dev" + ], + "docroot": "/srv/www/zf2tutorial/public", + "directory_index": [ "index.php", "index.html" ], + "directory_options": [ "Indexes", "FollowSymLinks" ], + "template": "web_app.conf.erb", + "allow_override": "all" + }, "comment": "zf2tutorial Virtualhost" } diff --git a/recipes/apache2.rb b/recipes/apache2.rb index f591a76..3a42dc6 100644 --- a/recipes/apache2.rb +++ b/recipes/apache2.rb @@ -8,15 +8,11 @@ # include_recipe 'apache2' -# include_recipe 'apache2::mod_deflate' -# include_recipe 'apache2::mod_expires' -# include_recipe 'apache2::mod_headers' -# include_recipe 'apache2::mod_php5' -# include_recipe 'apache2::mod_rewrite' + begin data_bag('virtualhosts').each do |virtualhost| - hostdata = data_bag_item('virtualhosts', virtualhost) + hostdata = data_bag_item('virtualhosts', virtualhost)[node.chef_environment] if hostdata['create_docroot'] directory hostdata['docroot'] do @@ -35,7 +31,7 @@ #webappname = '000-'+hostdata['id'] - web_app hostdata['id'] do + web_app hostdata['server_name'] do enable hostdata['enable'] server_name hostdata['server_name'] server_aliases hostdata['server_aliases'] From 68ba672b6540172e487d4109854c58190cd00a8e Mon Sep 17 00:00:00 2001 From: Rudger Gravestein Date: Sun, 14 Dec 2014 14:04:35 +0100 Subject: [PATCH 3/5] Add COMPOSER_HOME environment var to bash --- recipes/projects.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/recipes/projects.rb b/recipes/projects.rb index 959717e..98d8c81 100644 --- a/recipes/projects.rb +++ b/recipes/projects.rb @@ -82,6 +82,7 @@ # install composer.phar bash 'composer_installer' do + environment 'COMPOSER_HOME' => parentprojectdir.to_path user projectdata['owner'] cwd projectdata['projectdir'] code <<-EOH @@ -92,6 +93,7 @@ # composer install (uses: .lock file) bash 'install_composer' do + environment 'COMPOSER_HOME' => parentprojectdir.to_path user projectdata['owner'] cwd projectdata['projectdir'] code <<-EOH From 3153165b98f2d890d3558cdac470677d9e370a11 Mon Sep 17 00:00:00 2001 From: Rudger Gravestein Date: Sun, 14 Dec 2014 14:09:07 +0100 Subject: [PATCH 4/5] Fix vagrantfile --- Vagrantfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Vagrantfile b/Vagrantfile index 222d2fa..5eca053 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -50,7 +50,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.hostmanager.manage_host = true config.hostmanager.ignore_private_ip = false config.hostmanager.include_offline = true - # config.hostmanager.aliases = %w(zf2tutorial.zf2.dev) + config.hostmanager.aliases = %w(zf2tutorial.zf2.dev) else puts "WARN: Vagrant-hostmanager plugin not detected. Please install the plugin with\n 'vagrant plugin install vagrant-hostmanager' from any other directory\n before continuing." end From e49e0764d2f18ed139b9de9238ae2354b2eabac4 Mon Sep 17 00:00:00 2001 From: Rudger Gravestein Date: Sun, 14 Dec 2014 14:09:20 +0100 Subject: [PATCH 5/5] Bump version: 5.0.0 changed API for virtualhosts --- metadata.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/metadata.rb b/metadata.rb index a400199..b5191f9 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,9 +4,9 @@ license 'Apache 2.0' description 'Installs/Configures ZF2' long_description 'Installs/Configures ZF2' -version '0.4.7' +version '0.5.0' -depends 'baseserver', '~> 0.7.8' +depends 'baseserver', '~> 0.7.9' depends 'mysql', '~> 5.2.12' depends 'apache2', '~> 1.11.0'