I need to create 10 tomcat instances on 5 different servers (2 instances on each server). The instances names are common across the 5 servers.
The Tomcat instances would need to be integrated with a monitoring tool AppD. Now, while integrating it needs a parameter to be added in the attribute file which is like mentioned below:
default['mw']['tomcat'][application_identifier]['java_opts'] = '$JAVA_HEAP $JAVA_PROPS_SYSTYPE -Dappd.agent.nodeName=<HostName>-instance_tc_primary
The requirement here is to not hardcode the ; whereas get it placed dynamically based on the host on which it is to be deployed.
E.g.
For host LDN001 it shall appear as:
default['mw']['tomcat'][application_identifier]['java_opts'] = '$JAVA_HEAP $JAVA_PROPS_SYSTYPE -Dappd.agent.nodeName=LDN001-instance_tc_primary
For host LDN002 it shall appear as -
default['mw']['tomcat'][application_identifier]['java_opts'] = '$JAVA_HEAP $JAVA_PROPS_SYSTYPE -Dappd.agent.nodeName=LDN002-instance_tc_primary
So how can I have the attribute file fetching the hostnames dynamically based on the host it will get deployed?
We tried changing the role file as given below thinking that it will override java_opts:
node.override['mw']['tomcat'][application_identifier]['java_opts'] =
"$JAVA_HEAP $JAVA_PROPS_SYSTYPE -Djava.awt.headless=true $JAVA_SYSTYPE_OPTS -Dappdynamics.agent.nodeName=#{host[hostname]}-instance_tc_primary
But that did not work.
This is done by overwriting the Receipe file as below:
So using
$(hostname -s)resolved the issue.