Reverse engineer your JBoss AS-WildFly configuration to CLI

Today I was looking for a quick way to export my WildFly configuration to a CLI script and found a great project on github named "Profile Cloner".

The source of the Project is Maven based and it can be reached from https://github.com/tfonteyn/profilecloner . Basically this project allows to create a clone of your Profile (or part of it) and export it to a CLI script.

Start by cloning a copy of the project on your local drive:

git clone https://github.com/tfonteyn/profilecloner.git

Now move the the profilecloner folder:

cd profilecloner

And set your JBoss home so that launching the script will be easier:

export JBOSS_HOME=/opt/jboss/
Now execute the profile script passing as argument the script name to be created (save-script.cli) the controller host address localhost), the user (admin) and password (secret), the Profile path to be cloned (/profile=full-ha) and finally the profile to be generated (/profile=full-ha-copy)
./profilecloner.sh -f save-script.cli  --controller=localhost --username=admin --password=secret /profile=full-ha full-ha-copy

Mind that the application server is running as the script will reach its management interfaces. The output in save-script.cli will be the clone of full-ha profile. Here is the first part of it:

/profile="full-ha-copy":add()
/profile="full-ha-copy"/subsystem="logging":add()
/profile="full-ha-copy"/subsystem="logging"/console-handler="CONSOLE":add(formatter="%K{level}%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n",level="INFO",name="CONSOLE")
/profile="full-ha-copy"/subsystem="logging"/logger="com.arjuna":add(category="com.arjuna",level="WARN")
/profile="full-ha-copy"/subsystem="logging"/logger="org.apache.tomcat.util.modeler":add(category="org.apache.tomcat.util.modeler",level="WARN")
/profile="full-ha-copy"/subsystem="logging"/logger="org.jboss.as.config":add(category="org.jboss.as.config",level="DEBUG")
/profile="full-ha-copy"/subsystem="logging"/logger="sun.rmi":add(category="sun.rmi",level="WARN")
/profile="full-ha-copy"/subsystem="logging"/logger="jacorb":add(category="jacorb",level="WARN")
/profile="full-ha-copy"/subsystem="logging"/logger="jacorb.config":add(category="jacorb.config",level="ERROR")
/profile="full-ha-copy"/subsystem="logging"/periodic-rotating-file-handler="FILE":add(append="true",autoflush="true",file={"relative-to" => "jboss.server.log.dir","path" => "server.log"},formatter="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n",name="FILE",suffix=".yyyy-MM-dd")
/profile="full-ha-copy"/subsystem="logging"/root-logger="ROOT":add(handlers=["CONSOLE","FILE"],level="INFO")
. . . . . . . . . . . . . .

The awesome part of it is that you can create copy of single parts of your profile. For example here is how to reverse engineer the TCPPING stack to CLI (P.s. cast the first stone who has never added this section by hand in the XML file! :-))

./profilecloner.sh -f save-script-here.cli  --controller=localhost --username=admin --password=secret /profile=full-ha/subsystem=jgroups/stack=tcpping full-ha-copy

And here is the outcome of it:

batch
/subsystem="jgroups"/stack="tcpping":add()
/subsystem="jgroups"/stack="tcpping":add-protocol(type="TCPPING")
/subsystem="jgroups"/stack="tcpping"/protocol="TCPPING"/property="initial_hosts":add(value="192.168.10.1[7600],192.168.10.2[7600]")
/subsystem="jgroups"/stack="tcpping"/protocol="TCPPING"/property="port_range":add(value="10")
/subsystem="jgroups"/stack="tcpping"/protocol="TCPPING"/property="timeout":add(value="3000")
/subsystem="jgroups"/stack="tcpping"/protocol="TCPPING"/property="num_initial_members":add(value="2")
/subsystem="jgroups"/stack="tcpping":add-protocol(type="MERGE2")
/subsystem="jgroups"/stack="tcpping":add-protocol(socket-binding="jgroups-tcp-fd",type="FD_SOCK")
/subsystem="jgroups"/stack="tcpping":add-protocol(type="FD")
/subsystem="jgroups"/stack="tcpping":add-protocol(type="VERIFY_SUSPECT")
/subsystem="jgroups"/stack="tcpping":add-protocol(type="BARRIER")
/subsystem="jgroups"/stack="tcpping":add-protocol(type="pbcast.NAKACK")
/subsystem="jgroups"/stack="tcpping":add-protocol(type="UNICAST2")
/subsystem="jgroups"/stack="tcpping":add-protocol(type="pbcast.STABLE")
/subsystem="jgroups"/stack="tcpping":add-protocol(type="pbcast.GMS")
/subsystem="jgroups"/stack="tcpping":add-protocol(type="UFC")
/subsystem="jgroups"/stack="tcpping":add-protocol(type="MFC")
/subsystem="jgroups"/stack="tcpping":add-protocol(type="FRAG2")
/subsystem="jgroups"/stack="tcpping":add-protocol(type="RSVP")
/subsystem="jgroups"/stack="tcpping"/transport="TRANSPORT":add(socket-binding="jgroups-tcp",type="TCP")
run-batch

What else to say ? thanks to Tom Fonteyne for providing this awesome script to the Community! Works like a charm also on JBoss EAP 6.1 (or newer) as well!

Related articles available on mastertheboss.com

How do I get the list of MBeans with twiddle?

  JBoss provides a simple command line tool that allows for inte

How to count active session with twiddle ?

  There are some well known alternatives to count the number of

How do I run garbage collector from shell?

  You can suggest JBoss to run the garbage collector in differen

How do I check my application status from shell?

  This is a two process step: at first you need to retrieve the

How do you shut down multiple JBoss instances?

  Supposing you have configured 2 instances of JBoss, one on por

twiddle reference guide

Please note: twiddle is not available any more as default Command

Follow us on Twitter