diff --git a/Berksfile b/Berksfile index 2dd51f4..068a4ed 100644 --- a/Berksfile +++ b/Berksfile @@ -1,6 +1,6 @@ source "https://api.berkshelf.com" -cookbook "apache2", "= 1.10.4" +cookbook "apache2", "= 3.0.1" cookbook "apt", "= 2.4.0" cookbook "aws", "= 2.2.0" cookbook "build-essential", "= 2.0.2" @@ -13,7 +13,7 @@ cookbook "mysql", "= 5.2.10" cookbook "mysql-chef_gem", "= 0.0.2" cookbook "openssl", "= 1.1.0" cookbook "pacman", "= 1.1.1" -cookbook "php", "= 1.4.6" +cookbook "php", "= 1.5.0" cookbook "postgresql", "= 3.4.0" cookbook "windows", "= 1.31.0" cookbook "xfs", "= 1.1.0" diff --git a/Berksfile.lock b/Berksfile.lock index 85b38b9..af48bf7 100644 --- a/Berksfile.lock +++ b/Berksfile.lock @@ -1,5 +1,5 @@ DEPENDENCIES - apache2 (= 1.10.4) + apache2 (= 3.0.1) apt (= 2.4.0) aws (= 2.2.0) build-essential (= 2.0.2) @@ -12,7 +12,7 @@ DEPENDENCIES mysql-chef_gem (= 0.0.2) openssl (= 1.1.0) pacman (= 1.1.1) - php (= 1.4.6) + php (= 1.5.0) postgresql (= 3.4.0) windows (= 1.31.0) xfs (= 1.1.0) @@ -21,10 +21,9 @@ DEPENDENCIES yum-epel (= 0.3.6) GRAPH - apache2 (1.10.4) + apache2 (3.0.1) iptables (>= 0.0.0) logrotate (>= 0.0.0) - pacman (>= 0.0.0) apt (2.4.0) aws (2.2.0) build-essential (2.0.2) @@ -45,7 +44,7 @@ GRAPH mysql (>= 0.0.0) openssl (1.1.0) pacman (1.1.1) - php (1.4.6) + php (1.5.0) build-essential (>= 0.0.0) iis (>= 0.0.0) mysql (>= 0.0.0) diff --git a/Vagrantfile b/Vagrantfile index e728704..327ad2e 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,15 +1,15 @@ +%x(vagrant plugin install vagrant-berkshelf) unless Vagrant.has_plugin?('vagrant-berkshelf') Vagrant.configure("2") do |config| - + config.berkshelf.enabled = true # Load config JSON. config_json = JSON.parse(File.read("config.json")) # Prepare base box. - config.vm.box = "precise32" - config.vm.box_url = "http://files.vagrantup.com/precise32.box" + config.vm.box = "ubuntu/trusty64" + config.vm.box_url = "https://atlas.hashicorp.com/ubuntu/boxes/trusty64" # Configure networking. config.vm.network :private_network, ip: config_json["vm"]["ip"] - # Configure forwarded ports. config.vm.network "forwarded_port", guest: 35729, host: 35729, protocol: "tcp", auto_correct: true config.vm.network "forwarded_port", guest: 8983, host: 8983, protocol: "tcp", auto_correct: true @@ -18,7 +18,6 @@ Vagrant.configure("2") do |config| config.vm.network "forwarded_port", guest: port["guest_port"], host: port["host_port"], protocol: port["protocol"], auto_correct: true end - # Customize provider. config.vm.provider :virtualbox do |vb| # RAM. @@ -56,7 +55,10 @@ Vagrant.configure("2") do |config| # Run initial shell script. config.vm.provision :shell, :path => "chef/shell/initial.sh" + config.ssh.forward_agent = true + config.vm.boot_timeout = 120 + config.vm.box_download_insecure # Customize provisioner. config.vm.provision :chef_solo do |chef| chef.json = config_json @@ -65,7 +67,6 @@ Vagrant.configure("2") do |config| chef.roles_path = "chef/roles" chef.add_role "vdd" end - # Run final shell script. config.vm.provision :shell, :path => "chef/shell/final.sh", :args => config_json["vm"]["ip"] diff --git a/chef/cookbooks/berks/Berksfile.lock b/chef/cookbooks/berks/Berksfile.lock index 85b38b9..af48bf7 100644 --- a/chef/cookbooks/berks/Berksfile.lock +++ b/chef/cookbooks/berks/Berksfile.lock @@ -1,5 +1,5 @@ DEPENDENCIES - apache2 (= 1.10.4) + apache2 (= 3.0.1) apt (= 2.4.0) aws (= 2.2.0) build-essential (= 2.0.2) @@ -12,7 +12,7 @@ DEPENDENCIES mysql-chef_gem (= 0.0.2) openssl (= 1.1.0) pacman (= 1.1.1) - php (= 1.4.6) + php (= 1.5.0) postgresql (= 3.4.0) windows (= 1.31.0) xfs (= 1.1.0) @@ -21,10 +21,9 @@ DEPENDENCIES yum-epel (= 0.3.6) GRAPH - apache2 (1.10.4) + apache2 (3.0.1) iptables (>= 0.0.0) logrotate (>= 0.0.0) - pacman (>= 0.0.0) apt (2.4.0) aws (2.2.0) build-essential (2.0.2) @@ -45,7 +44,7 @@ GRAPH mysql (>= 0.0.0) openssl (1.1.0) pacman (1.1.1) - php (1.4.6) + php (1.5.0) build-essential (>= 0.0.0) iis (>= 0.0.0) mysql (>= 0.0.0) diff --git a/chef/cookbooks/berks/apache2/attributes/default.rb b/chef/cookbooks/berks/apache2/attributes/default.rb index b5df554..179bab3 100644 --- a/chef/cookbooks/berks/apache2/attributes/default.rb +++ b/chef/cookbooks/berks/apache2/attributes/default.rb @@ -53,7 +53,7 @@ when 'debian', 'ubuntu' default['apache']['user'] = 'www-data' default['apache']['group'] = 'www-data' default['apache']['binary'] = '/usr/sbin/apache2' - default['apache']['docroot_dir'] = '/var/www' + default['apache']['docroot_dir'] = '/var/www/html' default['apache']['cgibin_dir'] = '/usr/lib/cgi-bin' default['apache']['icondir'] = '/usr/share/apache2/icons' default['apache']['cache_dir'] = '/var/cache/apache2' @@ -110,7 +110,7 @@ else default['apache']['user'] = 'www-data' default['apache']['group'] = 'www-data' default['apache']['binary'] = '/usr/sbin/apache2' - default['apache']['docroot_dir'] = '/var/www' + default['apache']['docroot_dir'] = '/var/www/html' default['apache']['cgibin_dir'] = '/usr/lib/cgi-bin' default['apache']['icondir'] = '/usr/share/apache2/icons' default['apache']['cache_dir'] = '/var/cache/apache2' @@ -177,7 +177,7 @@ default['apache']['proxy']['allow_from'] = 'none' # Default modules to enable via include_recipe default['apache']['default_modules'] = %w[ - status alias auth_basic authn_file authz_default authz_groupfile authz_host authz_user autoindex + status alias auth_basic authn_file authz_groupfile authz_host authz_user autoindex dir env mime negotiation setenvif ] diff --git a/chef/cookbooks/berks/apache2/templates/default/apache2.conf.erb b/chef/cookbooks/berks/apache2/templates/default/apache2.conf.erb index 5bc6d3c..7fd5d3c 100644 --- a/chef/cookbooks/berks/apache2/templates/default/apache2.conf.erb +++ b/chef/cookbooks/berks/apache2/templates/default/apache2.conf.erb @@ -9,7 +9,7 @@ ServerRoot "<%= node['apache']['dir'] %>" # The accept serialization lock file MUST BE STORED ON A LOCAL DISK. # <% if %w[debian].include?(node['platform_family']) -%> -LockFile /var/lock/apache2/accept.lock +Mutex file:${APACHE_LOCK_DIR} default <% elsif %w[freebsd].include?(node['platform_family']) -%> LockFile /var/log/accept.lock <% else %> @@ -232,7 +232,7 @@ LogFormat "%{User-agent}i" agent # Include generic snippets of statements -Include <%= node['apache']['dir'] %>/conf.d/*.conf +Include <%= node['apache']['dir'] %>/conf-enabled/*.conf # Include the virtual host configurations: -Include <%= node['apache']['dir'] %>/sites-enabled/ +Include <%= node['apache']['dir'] %>/sites-enabled/*.conf diff --git a/chef/cookbooks/core/vdd/recipes/apache.rb b/chef/cookbooks/core/vdd/recipes/apache.rb index d84a66c..9bcedd4 100644 --- a/chef/cookbooks/core/vdd/recipes/apache.rb +++ b/chef/cookbooks/core/vdd/recipes/apache.rb @@ -23,7 +23,7 @@ group "www-data" do end -file "/var/www/index.html" do +file File.join(File.dirname(node['apache']['docroot_dir']), 'index.html') do action :delete end @@ -47,7 +47,6 @@ modules = [ "setenvif", "auth_basic", "authn_file", - "authz_default", "authz_groupfile", "authz_user" ] @@ -62,7 +61,7 @@ modules.each do |mod| end end -template "/etc/apache2/conf.d/vdd_apache.conf" do +template "/etc/apache2/conf-enabled/vdd_apache.conf" do source "vdd_apache.conf.erb" mode "0644" notifies :restart, "service[apache2]", :delayed diff --git a/chef/cookbooks/core/vdd/recipes/composer.rb b/chef/cookbooks/core/vdd/recipes/composer.rb index a05b18e..88407cb 100644 --- a/chef/cookbooks/core/vdd/recipes/composer.rb +++ b/chef/cookbooks/core/vdd/recipes/composer.rb @@ -4,4 +4,4 @@ bash "install-composer" do curl -sS https://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composer EOH -end \ No newline at end of file +end diff --git a/chef/cookbooks/core/vdd/recipes/php.rb b/chef/cookbooks/core/vdd/recipes/php.rb index e68290d..f87ddd9 100644 --- a/chef/cookbooks/core/vdd/recipes/php.rb +++ b/chef/cookbooks/core/vdd/recipes/php.rb @@ -1,12 +1,8 @@ -apt_repository "php54" do - uri "http://ppa.launchpad.net/ondrej/php5-oldstable/ubuntu" - distribution node['lsb']['codename'] - components ["main"] - keyserver "keyserver.ubuntu.com" - key "E5267A6C" -end - +# @todo Hack until https://github.com/opscode-cookbooks/php/pull/111 is +# included. +node.override['php']['ext_conf_dir'] = "/etc/php5/mods-available" include_recipe 'php' + include_recipe "apache2::mod_php5" pkgs = [ diff --git a/chef/cookbooks/core/vdd/recipes/phpmyadmin.rb b/chef/cookbooks/core/vdd/recipes/phpmyadmin.rb index 523b10d..e889860 100644 --- a/chef/cookbooks/core/vdd/recipes/phpmyadmin.rb +++ b/chef/cookbooks/core/vdd/recipes/phpmyadmin.rb @@ -8,6 +8,14 @@ bash "debconf" do code "debconf-set-selections #{deb_conf_file}" end +bash "enable_apache_module_authz_user" do + user "root" + code <<-EOH + a2enmod authz_user + EOH + not_if { File.exists?("/etc/apache2/mods-enabled/authz_user") } +end + package "phpmyadmin" do action :install end diff --git a/chef/cookbooks/core/vdd/recipes/uploadprogress.rb b/chef/cookbooks/core/vdd/recipes/uploadprogress.rb index 9823746..1cb6376 100644 --- a/chef/cookbooks/core/vdd/recipes/uploadprogress.rb +++ b/chef/cookbooks/core/vdd/recipes/uploadprogress.rb @@ -1,3 +1,10 @@ php_pear "uploadprogress" do action :install end + +# @todo Hack until https://github.com/opscode-cookbooks/php/pull/111 is +# included. +execute '/usr/sbin/php5enmod uploadprogress' do + action :run + notifies :restart, "service[apache2]", :delayed +end diff --git a/chef/cookbooks/core/vdd/recipes/vdd_help.rb b/chef/cookbooks/core/vdd/recipes/vdd_help.rb index c841ab3..26c7770 100644 --- a/chef/cookbooks/core/vdd/recipes/vdd_help.rb +++ b/chef/cookbooks/core/vdd/recipes/vdd_help.rb @@ -8,8 +8,7 @@ node["vm"]["synced_folders"].each do |folder| end end - -template "/var/www/index.html" do +template File.join(node['apache']['docroot_dir'], 'index.html') do source "vdd_help.html.erb" if nfs == 0 owner "vagrant" @@ -21,9 +20,11 @@ template "/var/www/index.html" do ) end +phpinfo_loc = File.join(node['apache']['docroot_dir'], 'phpinfo.php') + bash "phpinfo" do code <<-EOH - echo " /var/www/phpinfo.php + echo " #{phpinfo_loc} EOH - not_if { File.exists?("/var/www/phpinfo.php") } + not_if { File.exists?(phpinfo_loc) } end diff --git a/chef/cookbooks/core/vdd/recipes/webgrind.rb b/chef/cookbooks/core/vdd/recipes/webgrind.rb index 4e0fe89..52ed0d0 100644 --- a/chef/cookbooks/core/vdd/recipes/webgrind.rb +++ b/chef/cookbooks/core/vdd/recipes/webgrind.rb @@ -1,4 +1,4 @@ -git "/var/www/webgrind" do +git "/var/www/html/webgrind" do repository "https://github.com/jokkedk/webgrind.git" reference "master" action :sync diff --git a/chef/cookbooks/core/vdd/recipes/xdebug.rb b/chef/cookbooks/core/vdd/recipes/xdebug.rb index 5376928..9d55812 100644 --- a/chef/cookbooks/core/vdd/recipes/xdebug.rb +++ b/chef/cookbooks/core/vdd/recipes/xdebug.rb @@ -2,14 +2,19 @@ php_pear "xdebug" do action :install end -file "/etc/php5/conf.d/xdebug.ini" do +file File.join(node['php']['ext_conf_dir'], 'xdebug.ini') do action :delete notifies :restart, "service[apache2]", :delayed - only_if { File.exists?("/etc/php5/conf.d/xdebug.ini") } + only_if { File.exists?File.join(node['php']['ext_conf_dir'], 'xdebug.ini') } end -template "/etc/php5/conf.d/vdd_xdebug.ini" do +template File.join(node['php']['ext_conf_dir'], 'vdd_xdebug.ini') do source "vdd_xdebug.ini.erb" mode "0644" notifies :restart, "service[apache2]", :delayed end + +execute '/usr/sbin/php5enmod vdd_xdebug' do + action :run + notifies :restart, "service[apache2]", :delayed +end diff --git a/chef/cookbooks/core/vdd/templates/default/localhost.conf.erb b/chef/cookbooks/core/vdd/templates/default/localhost.conf.erb index 1204a6c..a8ce85b 100644 --- a/chef/cookbooks/core/vdd/templates/default/localhost.conf.erb +++ b/chef/cookbooks/core/vdd/templates/default/localhost.conf.erb @@ -1,11 +1,15 @@ - DocumentRoot /var/www + DocumentRoot /var/www/html ServerName localhost RewriteEngine On ErrorLog /var/log/apache2/error.log LogLevel warn CustomLog /var/log/apache2/access.log combined ServerSignature On + + AllowOverride All + Require all granted + <% @node["vdd"]["sites"].each do |index, site| %> @@ -20,6 +24,10 @@ LogLevel warn CustomLog /var/log/apache2/<%= index %>.access.log combined ServerSignature On + > + AllowOverride All + Require all granted + - <% end %> -<%- end -%> + <%- end -%> +<% end %> diff --git a/chef/shell/initial.sh b/chef/shell/initial.sh index f81153a..9e05f30 100644 --- a/chef/shell/initial.sh +++ b/chef/shell/initial.sh @@ -8,5 +8,9 @@ cat "$VAGRANT_DIR/chef/shell/vdd.txt" # Upgrade Chef. echo "Updating Chef to 11.12.4 version. This may take a few minutes..." apt-get update &> /dev/null -apt-get install build-essential ruby1.9.1-dev --no-upgrade --yes &> /dev/null -gem install chef --version 11.12.4 --no-rdoc --no-ri --conservative &> /dev/null +echo "sources updated" +echo "installing ruby and chef" +apt-get install build-essential ruby1.9.1-dev --no-upgrade --yes +update-ca-certificates +gem install chef --version="11.12.4" --no-rdoc --no-ri --conservative +echo "installed ruby and chef"