Skip to content

Commit

Permalink
Use concat_native to generate server.xml
Browse files Browse the repository at this point in the history
  • Loading branch information
mcanevet committed Dec 16, 2013
1 parent 392bad7 commit 450b087
Show file tree
Hide file tree
Showing 10 changed files with 266 additions and 283 deletions.
1 change: 1 addition & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
fixtures:
repositories:
"stdlib": "git://github.com/puppetlabs/puppetlabs-stdlib.git"
"concat_native": "git://github.com/theforeman/puppet-concat.git"
"archive": "git://github.com/camptocamp/puppet-archive.git"
"sudo": "git://github.com/camptocamp/puppet-sudo.git"
symlinks:
Expand Down
9 changes: 9 additions & 0 deletions manifests/connector.pp
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,13 @@
require => $require,
}

concat_fragment { "server.xml_${instance}+03_connector_${name}":
content => " <!ENTITY connector-${name} SYSTEM \"connector-${name}.xml\">\n",
}

concat_fragment { "server.xml_${instance}+06_connector_${name}":
content => " <!-- See conf/connector-${name}.xml for this connector's config. -->
&connector-${name};\n",
}

}
9 changes: 9 additions & 0 deletions manifests/executor.pp
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,13 @@
replace => $manage,
}

concat_fragment { "server.xml_${instance}+02_executor_${name}":
content => " <!ENTITY executor-${name} SYSTEM \"executor-${name}.xml\">\n",
}

concat_fragment { "server.xml_${instance}+05_executor_${name}":
content => " <!-- See conf/executor-${name}.xml for this executor's config. -->
&executor-${name};\n",
}

}
24 changes: 21 additions & 3 deletions manifests/instance.pp
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,18 @@
# Instance directories
case $ensure {
present,installed,running,stopped: {
concat_build { "server.xml_${name}": }
concat_fragment { "server.xml_${name}+01_header":
content => '<?xml version=\'1.0\' encoding=\'utf-8\'?>
<!DOCTYPE server-xml [
',
}
concat_fragment { "server.xml_${name}+04_body1":
content => template("${module_name}/body1_${serverdotxml}"),
}
concat_fragment { "server.xml_${name}+07_body2":
content => template("${module_name}/body2_${serverdotxml}"),
}
file {
# Nobody usually write there
$basedir:
Expand Down Expand Up @@ -339,11 +351,17 @@
group => $group,
mode => $filemode,
source => $server_xml_file? {
'' => undef,
'' => $version ? {
5 => undef,
default => concat_output("server.xml_${name}"),
},
default => $server_xml_file,
},
content => $server_xml_file? {
'' => template("${module_name}/${serverdotxml}"),
'' => $version ? {
5 => template("${module_name}/${serverdotxml}"),
default => undef,
},
default => undef,
},
before => Service["tomcat-${name}"],
Expand All @@ -352,7 +370,7 @@
default => undef,
},
require => $server_xml_file? {
'' => undef,
'' => Concat_build["server.xml_${name}"],
default => Tomcat::Connector[$connectors],
},
replace => $manage;
Expand Down
57 changes: 57 additions & 0 deletions templates/body1_server.xml.tomcat6.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
]>
<% if @manage -%>
<!-- file managed by puppet -->
<% else -%>
<!-- file created (but not managed by puppet -->
<% end -%>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You 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.
-->
<!-- Note: A "Server" is not itself a "Container", so you may not
define subcomponents such as "Valves" at this level.
Documentation at /docs/config/server.html
-->
<Server port="<%= @server_port %>" shutdown="SHUTDOWN">

<!--APR library loader. Documentation at /docs/apr.html -->
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
<Listener className="org.apache.catalina.core.JasperListener" />
<!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

<!-- Global JNDI resources
Documentation at /docs/jndi-resources-howto.html
-->
<GlobalNamingResources>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users
-->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>

<!-- A "Service" is a collection of one or more "Connectors" that share
a single "Container" Note: A "Service" is not itself a "Container",
so you may not define subcomponents such as "Valves" at this level.
Documentation at /docs/config/service.html
-->
<Service name="Catalina">

62 changes: 62 additions & 0 deletions templates/body1_server.xml.tomcat7.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
]>
<% if @manage -%>
<!-- file managed by puppet -->
<% else -%>
<!-- file created (but not managed by puppet -->
<% end -%>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You 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.
-->
<!-- Note: A "Server" is not itself a "Container", so you may not
define subcomponents such as "Valves" at this level.
Documentation at /docs/config/server.html
-->
<Server port="<%= @server_port %>" shutdown="SHUTDOWN">
<!-- Security listener. Documentation at /docs/config/listeners.html
<Listener className="org.apache.catalina.security.SecurityListener" />
-->
<!--APR library loader. Documentation at /docs/apr.html -->
<!--
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
-->
<!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
<Listener className="org.apache.catalina.core.JasperListener" />
<!-- Prevent memory leaks due to use of particular java/javax APIs-->
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

<!-- Global JNDI resources
Documentation at /docs/jndi-resources-howto.html
-->
<GlobalNamingResources>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users
-->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>

<!-- A "Service" is a collection of one or more "Connectors" that share
a single "Container" Note: A "Service" is not itself a "Container",
so you may not define subcomponents such as "Valves" at this level.
Documentation at /docs/config/service.html
-->
<Service name="Catalina">

57 changes: 57 additions & 0 deletions templates/body2_server.xml.tomcat6.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<!-- An Engine represents the entry point (within Catalina) that processes
every request. The Engine implementation for Tomcat stand alone
analyzes the HTTP headers included with the request, and passes them
on to the appropriate Host (virtual host).
Documentation at /docs/config/engine.html -->

<!-- You should set jvmRoute to support load-balancing via AJP ie :
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
-->
<Engine name="Catalina" defaultHost="localhost">

<!--For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simple how to)
/docs/config/cluster.html (reference documentation) -->
<!--
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
-->

<!-- The request dumper valve dumps useful debugging information about
the request and response data received and sent by Tomcat.
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.valves.RequestDumperValve"/>
-->

<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>

<!-- Define the default virtual host
Note: XML Schema validation will not work with Xerces 2.2.
-->
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">

<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->

<!-- Access log processes all example.
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
-->

</Host>
</Engine>
</Service>
</Server>

50 changes: 50 additions & 0 deletions templates/body2_server.xml.tomcat7.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!-- An Engine represents the entry point (within Catalina) that processes
every request. The Engine implementation for Tomcat stand alone
analyzes the HTTP headers included with the request, and passes them
on to the appropriate Host (virtual host).
Documentation at /docs/config/engine.html -->

<!-- You should set jvmRoute to support load-balancing via AJP ie :
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
-->
<Engine name="Catalina" defaultHost="localhost">

<!--For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simple how to)
/docs/config/cluster.html (reference documentation) -->
<!--
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
-->

<!-- Use the LockOutRealm to prevent attempts to guess user passwords
via a brute-force attack -->
<Realm className="org.apache.catalina.realm.LockOutRealm">
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>

<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">

<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->

<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t &quot;%r&quot; %s %b" />

</Host>
</Engine>
</Service>
</Server>

Loading

0 comments on commit 450b087

Please sign in to comment.