Created
August 29, 2015 19:56
-
-
Save dblessing/8a6b2e856312d4cfda37 to your computer and use it in GitHub Desktop.
Poise Subresources
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
require 'poise' | |
module ApacheTomcatConfig | |
class Resource < Chef::Resource | |
include Poise(container: true, container_namespace: false) | |
poise_subresource :apache_tomcat_instance | |
provides :apache_tomcat_config | |
actions :create | |
attribute :name, equal_to: %w(server web context) | |
attribute :config, | |
option_collector: true, | |
template: true, | |
default_source: lazy { "#{name}.xml.erb" }, | |
default_options: { include_defaults: true } | |
end | |
class Provider < Chef::Provider | |
include Poise | |
provides :apache_tomcat_config | |
def action_create | |
notifying_block do | |
file "#{instance_config_dir}/#{new_resource.name}.xml" do | |
owner new_resource.parent.user | |
group new_resource.parent.group | |
mode '0640' | |
content new_resource.config_content | |
end | |
end | |
end | |
def instance_config_dir | |
"#{new_resource.parent.instance_dir}/conf" | |
end | |
end | |
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
require 'poise' | |
module ApacheTomcatEntity | |
class Resource < Chef::Resource | |
include Poise | |
poise_subresource :apache_tomcat_config | |
provides :apache_tomcat_entity | |
actions :create | |
attribute :name, kind_of: String | |
attribute :config, | |
option_collector: true, | |
template: true, | |
default_source: lazy { "#{name}.xml.erb" } | |
end | |
class Provider < Chef::Provider | |
include Poise | |
provides :apache_tomcat_entity | |
def action_create | |
notifying_block do | |
file "#{instance_config_dir}/#{new_resource.name}.xml" do | |
owner new_resource.parent.parent.user | |
group new_resource.parent.parent.group | |
mode '0640' | |
content new_resource.config_content | |
end | |
end | |
end | |
def instance_config_dir | |
"#{new_resource.parent.parent.instance_dir}/conf" | |
end | |
end | |
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
require 'poise' | |
module ApacheTomcatInstance | |
class Resource < Chef::Resource | |
include Poise(container: true, container_namespace: false) | |
provides :apache_tomcat_instance | |
actions :create | |
attribute :name, kind_of: String | |
attribute :prefix_root, kind_of: String, default: '/opt/tomcat' | |
attribute :user, kind_of: String, default: 'tomcat' | |
attribute :group, kind_of: String, default: 'tomcat' | |
attribute :catalina_home, | |
kind_of: String, | |
default: '/usr/share/tomcat' | |
attribute :setenv, | |
option_collector: true, | |
template: true, | |
default_source: 'setenv.sh.erb' | |
attribute :bundle_webapps_enabled, | |
kind_of: Array, | |
default: [] | |
attribute :bundle_webapps_managed, | |
kind_of: Array, | |
default: [] | |
def instance_dir | |
"#{prefix_root}/#{name}" | |
end | |
end | |
class Provider < Chef::Provider | |
include Poise | |
provides :apache_tomcat_instance | |
def action_create | |
... | |
end | |
... | |
end | |
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
apache_tomcat_instance 'instance1' do | |
apache_tomcat_config 'web' do | |
config_options do | |
include_defaults false | |
include_default_mime_types true | |
end | |
apache_tomcat_entity 'engine' do | |
config_options do | |
include_defaults false | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment