Myst has out of the box support for customising webtier routing rules and standard settings as described here. This approach takes the inputs from attributes defined in the MyST Platform Definition and uses these to generate the moduleconf\*.conf
files and httpd.conf
, admin.conf
and sshd.conf
. But what if you want full control over the files being created?
In this case, you may find it more fitting to define a template file for replacement when the webtier is configured at provision-time.
Let's say for instance, that you wanted to create a file called moduleconf/custom.conf
with the following:
<Location /customroute>
SetHandler weblogic-handler
WeblogicCluster osb02.acme:9011,osb02.acme:9011
DynamicServerList ON
RequestHeader set REQUESTORDN "%{SSL_CLIENT_S_DN}s"
Debug ERR
WLLogFile /u01/app/oracle/user_projects/instances/ohs_instance_osb_domain/diagnostics/logs/OHS/osb_domain/wlproxy_advies.log
DebugConfigInfo OFF
WLTempDir /tmp/_wl_proxy_12c
</Location>
Whilst the above could be achieved entirely through the Routing Rules construct in the MyST Platform Definition, it may be easier to use a template. Let's look at the templated version of our custom.conf
.
<Location /customroute>
SetHandler weblogic-handler
WeblogicCluster ${core.domain.cluster[osb].cluster-address}
DynamicServerList ON
RequestHeader set REQUESTORDN "%{SSL_CLIENT_S_DN}s"
Debug ERR
WLLogFile /u01/app/oracle/user_projects/instances/ohs_instance_${core.domain.name}/diagnostics/logs/OHS/${core.domain.name}/wlproxy_advies.log
DebugConfigInfo OFF
WLTempDir /tmp/_wl_proxy_12c
</Location>
Notice that we have replaced osb_domain
with ${core.domain.name}
so that it takes the value from the Platform Model. Similarly, we have replaced osb02.acme:9011,osb02.acme:9011
with ${core.domain.cluster[osb].cluster-address}
. This ensures that the template can be reusable across multiple Platform Instances.
We can register our template:
webtier-custom-router
but this can be anything you wantPlain text
ohs/custom.conf
which we will provide this value to our Platform Blueprint later
NOTE: Oracle Webtier will dynamically discover any files under moduleconf
with this extension and Myst will copy any files to moduleconf
that exist in the source directory.
${myst.workspace}/resources/custom/ohs
To apply the changes without doing a reprovision:
configure-webtier
as a custom action moduleconf
files have been replaced and automatically copied to all servers.Performing advanced customisations to httpd.conf
, admin.conf
and ssl.conf
is not as straight forward as defining custom routing rules under moduleconf
. For this reason, it is preferable to define all customisation via moduleconf
. In an event this approach is not feasible, it would be possible to customise these files using the combination of a template and a custom action which executes the template customisation.
To update these files you would need to:
Plain text
type at resources/custom/ohs/httpd.conf
)Plain text
type at resources/custom/ohs/ssl.conf
)Plain text
type at resources/custom/ohs/admin.conf
)webtier-update-conf
) which programmatically takes the template and writes it to the desired location action.configure-webtier.post=webtier-update-conf
)configure-webtier
as usual. This will result in configure-webtier
running and then the below custom action webtier-update-conf
overwriting the conf files with ones defined as Plain text
type in the custom action.Below is an example Jython Action for replacing httpd.conf
| ssl.conf
| admin.conf
with a template
from com.rubiconred.myst.config import ConfigUtils
from java.io import File
from java.util import Properties
import os
def myst(cfg):
webtier = cfg.configuration.getModel().getCore().getWebtier()
node_list = webtier.getNodeList()
if node_list:
nodes = node_list.getNodeArray()
for node in nodes:
ohs_node = node.getId()
props = Properties()
props.setProperty("ohs.instance.host",cfg["core.node["+ohs_node+"].host"])
props.setProperty("ohs.component.name",cfg["core.webtier.node["+ohs_node+"].component-name"])
props.setProperty("ohs.instance.home",cfg["core.webtier.node["+ohs_node+"].instance-home"])
for file in ["httpd.conf","ssl.conf","admin.conf"]:
#findAndReplaceFile(srcFile,properties,allowUnresolvedProperties)
replacedFile = ConfigUtils.findAndReplaceFile(File("resources/custom/ohs/" + file), props, 1)
LOG.info("Backup " + file + " with suffix .yyyymmdd-HHMM")
os.system('cp -p' + cfg['ohs.instance.home'] + '/' + file + ' ' + cfg['ohs.instance.home'] + '/' + file + '.`date "+%Y%m%d-%H%M"`')
LOG.info("Copying " + replacedFile.getAbsolutePath() " to " + cfg['ohs.instance.home'] + "/" + file)
os.system("cp -p" + replacedFile.getAbsolutePath() + " " + cfg['ohs.instance.home'] + "/" + file)
LOG.info("*****************************\n*****************************")
LOG.info("Oracle OHS requires the AdminServer to be restarted in order for the conf files to be pushed to OHS nodes.")
LOG.info("*****************************\n*****************************")