Skip to content
This repository has been archived by the owner on Sep 29, 2020. It is now read-only.

Commit

Permalink
Merge pull request #56 from Rud5G/check-apache24
Browse files Browse the repository at this point in the history
Check apache24
  • Loading branch information
Rud5G committed Apr 2, 2015
2 parents eaf1893 + 71fde53 commit 14a3a74
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 59 deletions.
8 changes: 4 additions & 4 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# vm config
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'
#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'

#config.vm.box = 'opscode-ubuntu-14.04'
#config.vm.box_url = 'http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-14.04_chef-provisionerless.box'
config.vm.box = 'opscode-ubuntu-14.04'
config.vm.box_url = 'http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-14.04_chef-provisionerless.box'

config.vm.network :private_network, :ip => '33.33.33.77'

Expand Down
8 changes: 7 additions & 1 deletion attributes/php.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
# limitations under the License.
#

default['php']['set_version'] = '5.4'
default['php']['set_version'] = 'latest'

# only if PHP 5.4 >=
force_default['php']['ext_conf_dir'] = '/etc/php5/mods-available'
default['php']['php5enmod'] = '/usr/sbin/php5enmod'

# default php packages
default['php']['packages'] = %w(
curl libxml2-utils
php-pear php-apc
Expand Down
19 changes: 15 additions & 4 deletions recipes/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@
# limitations under the License.
#

# need for secure_password
::Chef::Node.send(:include, Opscode::OpenSSL::Password)


begin
data_bag('databases').each do |database|
databasedata = data_bag_item('databases', database)[node.chef_environment]

Chef::Log.debug(databasedata.inspect)
Chef::Log.debug("Cookbook #{cookbook_name} in the recipe: #{recipe_name}.")
database_bagitem = data_bag_item('databases', database)
databasedata = database_bagitem[node.chef_environment]

Chef::Log.info("Cookbook #{cookbook_name} in the recipe: #{recipe_name}.")
Chef::Log.info(databasedata.to_hash)

begin
database_connection = {
Expand Down Expand Up @@ -52,6 +56,13 @@
action :drop
end

# set the secure_passwords
if databasedata['password'].nil?
database_bagitem[node.chef_environment]['password'] = secure_password
database_bagitem.save unless Chef::Config[:solo]
databasedata['password'] = database_bagitem[node.chef_environment]['password']
end

mysql_database_user databasedata['username'] do
connection database_connection
host '%'
Expand Down
79 changes: 40 additions & 39 deletions recipes/mailcatcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,44 +20,45 @@
# Never enable on production
unless node.chef_environment == 'production'

# This is a dependency of MailCatcher
case node['platform_family']
when 'debian'
package 'sqlite'
package 'libsqlite3-dev'
when 'rhel', 'fedora', 'suse'
package 'libsqlite3-dev'
else
# type code here
Chef::Log.warn('Unsupported platform_family: '+ node['platform_family'])
end

# Install MailCatcher
gem_package 'mailcatcher'

#bash 'install_mailcatcher' do
# #not_if 'which mailcatcher'
# code 'gem install mailcatcher --no-ri --no-rdoc'
#end

# Generate the startmailcatchcommand
startmailcatchcommand = sprintf('mailcatcher --http-ip %s --http-port %s --smtp-ip %s --smtp-port %s', node['mailcatcher']['http-ip'], node['mailcatcher']['http-port'], node['mailcatcher']['smtp-ip'], node['mailcatcher']['smtp-port'])

Chef::Log.info("start mailcatch command = #{startmailcatchcommand}")

# Start MailCatcher
bash 'mailcatcher' do
not_if 'ps ax | grep -E "mailcatche[r]"'
code startmailcatchcommand
end

# Publish PHP configuration
template File.join(node['php']['ext_conf_dir'], 'mailcatcher.ini') do
source 'mailcatcher.ini.erb'
owner 'root'
group 'root'
mode '0644'
action :create
end
# This is a dependency of MailCatcher
case node['platform_family']
when 'debian'
package 'sqlite'
package 'libsqlite3-dev'
when 'rhel', 'fedora', 'suse'
package 'libsqlite3-dev'
else
# type code here
Chef::Log.warn('Unsupported platform_family: '+ node['platform_family'])
end

# Install MailCatcher
gem_package 'mailcatcher'

# Generate the startmailcatchcommand
startmailcatchcommand = sprintf('mailcatcher --http-ip %s --http-port %s --smtp-ip %s --smtp-port %s', node['mailcatcher']['http-ip'], node['mailcatcher']['http-port'], node['mailcatcher']['smtp-ip'], node['mailcatcher']['smtp-port'])

Chef::Log.info("start mailcatch command = #{startmailcatchcommand}")

# Start MailCatcher
bash 'mailcatcher' do
not_if 'ps ax | grep -E "mailcatche[r]"'
code startmailcatchcommand
end

# Publish PHP configuration
template File.join(node['php']['ext_conf_dir'], 'mailcatcher.ini') do
source 'mailcatcher.ini.erb'
owner 'root'
group 'root'
mode '0644'
action :create
end


bash 'php5enmod_mailcatcher' do
code 'php5enmod mailcatcher'
only_if { ::File.exists?(node['php']['php5enmod']) }
end

end
34 changes: 23 additions & 11 deletions templates/default/web_app.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@
<VirtualHost *:<%= @params[:server_port] || node['apache']['listen_ports'].first %>>
ServerName <%= @params[:server_name] %>
<% unless @params[:server_aliases].empty? -%>
ServerAlias <% @params[:server_aliases].each do |a| %><%= a %> <% end %>
ServerAlias <%= @params[:server_aliases].join " " %>
<% end -%>
RewriteEngine On

SetEnv APP_ENV "<%= node.chef_environment %>"

DocumentRoot <%= @params[:docroot] %>
<Directory <%= @params[:docroot] %>>
Options <%= [@params[:directory_options] || "FollowSymLinks" ].flatten.join " " %>
AllowOverride <%= [@params[:allow_override] || "None" ].flatten.join " " %>
<% if node['apache']['version'] == '2.4' -%>
Require all granted
<% else -%>
Order allow,deny
Allow from all
<% end -%>
</Directory>

<Directory />
Expand All @@ -25,31 +28,40 @@
<Location /server-status>
SetHandler server-status

<% if node['apache']['version'] == '2.4' -%>
Require local
<% else -%>
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
<% end -%>
</Location>

RewriteEngine On
<%- if node['apache']['version'] == '2.4' -%>
LogLevel info rewrite:trace1
<%- else -%>
LogLevel info
RewriteLog <%= node['apache']['log_dir'] %>/<%= @application_name %>-rewrite.log
RewriteLogLevel 0
<%- end -%>

ErrorLog <%= node['apache']['log_dir'] %>/<%= @params[:name] %>-error.log
CustomLog <%= node['apache']['log_dir'] %>/<%= @params[:name] %>-access.log combined

<% if @params[:directory_index] -%>
DirectoryIndex <%= [@params[:directory_index]].flatten.join " " %>
<% end -%>

RewriteEngine On
RewriteLog <%= node['apache']['log_dir'] %>/<%= @application_name %>-rewrite.log
RewriteLogLevel 0
<% if @params[:canonical_host] -%>
<% if @params[:directory_index] -%>
DirectoryIndex <%= [@params[:directory_index]].flatten.join " " %>
<% end -%>

<% if @params[:canonical_host] -%>
# Canonical host, <%= @params[:server_name] %>
RewriteCond %{HTTP_HOST} !^<%= @params[:server_name] %> [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*)$ http://<%= @params[:server_name] %>/$1 [L,R=301]
<% end -%>
<% end -%>

RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /system/maintenance.html [L]
RewriteRule ^.*$ /system/maintenance.html [L,R=503]
</VirtualHost>

0 comments on commit 14a3a74

Please sign in to comment.