Last active
August 29, 2015 14:04
-
-
Save cyberswat/a963b6def502356dee42 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use_inline_resources if defined?(use_inline_resources) | |
def whyrun_supported? | |
true | |
end | |
action :create do | |
template new_resource.name do | |
group new_resource.group | |
mode new_resource.mode | |
owner new_resource.owner | |
source new_resource.source | |
cookbook new_resource.cookbook | |
variables new_resource.variables | |
end | |
new_resource.updated_by_last_action(true) | |
end | |
action :delete do | |
directory new_resource.path do | |
action :delete | |
recursive false | |
end | |
new_resource.updated_by_last_action(true) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
actions :create, :delete | |
default_action :create | |
attribute :group, kind_of: String | |
attribute :mode, kind_of: Fixnum, default: 00644 | |
attribute :owner, kind_of: String | |
attribute :source, kind_of: String, default: 'web_app.conf.erb' | |
attribute :cookbook, kind_of: String, default: 'apache2' | |
attribute :variables, kind_of: Hash | |
attribute :enable, kind_of: TrueClass, default: false | |
def initialize(*args) | |
super | |
@action = :create | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include_recipe 'apache2::default' | |
name = 'basic_web_app' | |
name_clean = name.gsub('_', '-') | |
docroot = "#{node['apache_test']['root_dir']}/#{name}" | |
directory docroot do | |
action :create | |
end | |
file "#{docroot}/index.html" do | |
content "Hello #{name}" | |
action :create | |
end | |
template_variables = { | |
port: 80, | |
server_name: name_clean, | |
server_aliases: ["#{name_clean}.localhost.dev"], | |
docroot: docroot, | |
directories: { docroot => { | |
'Options' => 'FollowSymLinks', | |
'AllowOverride' => 'None', | |
'Order' => 'allow,deny', | |
'Allow' => 'from all' | |
}, | |
'/' => { | |
'Options' => 'FollowSymLinks', | |
'AllowOverride' => 'None' | |
} | |
}, | |
log_level: 'info', | |
error_log: "#{node['apache']['log_dir']}/#{name}-error.log", | |
custom_log: "#{node['apache']['log_dir']}/#{name}-access.log combined", | |
rewrite_engine: 'on', | |
rewrite_log: "#{node['apache']['log_dir']}/#{name}-rewrite.log", | |
rewrite_log_level: 0, | |
rewrite: [ | |
{ | |
'conditions' => [ | |
"%{HTTP_HOST} !^#{name_clean}.localhost.dev [NC]", | |
'%{HTTP_HOST} !^$' | |
], | |
'rules' => [ | |
"^/(.*)$ http://#{name_clean}.localhost.dev/$1 [L,R=301]" | |
] | |
} | |
] | |
} | |
apache2_web_app "#{node['apache']['dir']}/sites-available/#{name}.conf" do | |
variables template_variables | |
notifies :reload, 'service[apache2]' | |
end | |
apache_site "#{name}.conf" do | |
enable true | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Placing notifies on line 54 of the wrapper_recipe.rb works perfectly.