Automate SOA Infra configuration

Automate SOA Infra configuration

For the last six months, I work on the fully automated Oracle Fusion Middleware platform delivery. We use Ansible as primary automation tool and OEM for most of the daily Ops routines. So we are completing the last 20% of the final 20%, and in theory, it would never end, so you can stop it because the rule 80/20 says:

«The first eighty percent of the project, take 20% of the time. The last 20% takes the rest.»

The same works for construction, software development, and many other things when you should trade between, time, money,  and quality. Well, let's go back to the point.
An essential part of the SOA Suite configuration is setting your server and callback URLs, especially, if your SOA server is behind a reverse proxy or load balancer. Oracle provides the only way to configure those properties: Oracle Enterprise Manager Fusion Middleware Control (see Figure 1).

Figure 1. Oracle SOA 12c Common Infrastructure properties

It works, especially if you are human and do it for life. You can make a step further and click on "More SOA Infra ..." and have all infrastructure configuration properties (Figure 2).

Figure 2. Oracle SOA 12c Common properties as MBean attributes

I have conducted intensive searches over the internet, Oracle Support and documentation of all main SOA Suite versions (11.1.x and 12.x ). You would be surprised how much information you can find in the previous releases documentation. For example, I still take Oracle Business Rules as 10g documentation as the best Rules SDK specification. 10g documentation as the best Rules SDK specification.
It's turned out that Oracle doesn't provide a custom WLST commands for the essential configuration properties, nor any other documented way to update those fields. Few factors didn't allow me to stop:

  • I hate to give up, and we still should complete the project;
  • Simple or Advanced EM console it's just the web interface for WebLogic JMX MBeans;

I turned my sight toward this way and start digging. After soa-infra MBean introspection I figure out that it does not: doesn't expose any commit, or save methods; Attribute's getter and setter methods  are not available.

Then I found old Paul Done's piece on WebLogic custom MBeans. Finally, I have seen the light and managed to create a worked solution.
Code excerpt below is a part of the Jinja2 template. Ansible turns templates into the final WLST code and then executes it to perform desired changes. The code below is self-explanatory, although some clarifications could be useful:

  • Script connects to the managed server port, not the admin one.
  • Since managed servers have no edit() section you don't need to start complete changes
  • WLST environment provides mbs object - the common interface to MBeans
  • MBean name is hardcoded and as far as I know it's the same for 11g and 12c
  • Sections {% if %} {% endif %} decides which part will go to the final script.
  • Ansible replaces {{ variable }} tokens with the actual variable values.
## {{ ansible_managed }}
{% if server_up %}
connect(userConfigFile="adminUser.cfg",userKeyFile="adminUser.key",url="t3s://{{ admin_host }}:{{ server_port }}")
custom()
#Get MBean object name 
oname=ObjectName("oracle.as.soainfra.config:name=soa-infra,type=SoaInfraConfig,Application=soa-infra")
{% if "absent" == state|lower %}
# Reset URLs
mbs.setAttribute(oname,Attribute("ServerURL",None))
mbs.setAttribute(oname,Attribute("CallbackServerURL",None))
mbs.setAttribute(oname,Attribute("HttpsServerURL",None))
{% else %}
# Configure URLs
mbs.setAttribute(oname,Attribute("ServerURL","https://{{ frontendHost }}:{{ frontendSPort }}"))
mbs.setAttribute(oname,Attribute("CallbackServerURL","https://{{ frontendHost }}:{{ frontendSPort }}"))
mbs.setAttribute(oname,Attribute("HttpsServerURL","https://{{ frontendHost }}:{{ frontendSPort }}"))
{% else %}
print("WARNING: Skip configuration: server %s is not available on %d." % ("{{ admin_host }}",{{ server_port }}))
{% endif %}
Ansible way of WLST scripting

Another proof to my axiom: there are at least two ways to do something with Oracle products.