Reverse engineer your JBoss AS-WildFly configuration to CLI

Exporting your WildFly / JBoss EAP configuration to a CLI script is something you are going to need one day or another. No worries, the project Profile Cloner comes to rescue! (Updated to work with WildFly 26 and Java 11)

I’ve cloned ProfileCloner!

The original  Profile Cloner Project allows to create a clone of your Profile (or part of it) and export it to a CLI script. The project has not been updated in the last years so to make it run with more recent versions of WildFly and JDK it needs some changes in the configuration files.

For this purpose, I have created my own fork of it: https://github.com/fmarchioni/profilecloner

Firstly, clone or download a copy of the project on your local drive:

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

Next, move the the profilecloner folder:

cd profilecloner

Then, build the project to generate the profilecloner.jar file:

mvn install

Finally, set your JBOSS_HOME so that the launch script can pickup the jboss-cli-client.jar:

export JBOSS_HOME=/opt/jboss/

Generating the CLI script from a standalone.xml

We are now ready to reverse engineer the standalone.xml configuration from a WildFly server.
Firstly, start WildFly server:
./standalone.sh

We will assume that there’s an available management user with credentials (admin/admin). To learn more about User Management check this article: How to Add an User in WildFly

Next, execute the profilecloner.sh script passing as argument the output script name (save-script.cli) the controller host address (localhost), the user credentials and the profile to clone. You can use the markerplace “profile” to clone the default server profile:
./profilecloner.sh -f save-script.cli  --controller=localhost --username=admin --password=admin profile

We are done! Check the save-script.cli to see your XML configuration as a set of CLI batch scripts:

batch
/subsystem="logging":add()
/subsystem="logging"/console-handler="CONSOLE":add(level="INFO",name="CONSOLE",named-formatter="COLOR-PATTERN")
/subsystem="logging"/logger="com.arjuna":add(category="com.arjuna",level="WARN")
/subsystem="logging"/logger="io.jaegertracing.Configuration":add(category="io.jaegertracing.Configuration",level="WARN")
/subsystem="logging"/logger="org.jboss.as.config":add(category="org.jboss.as.config",level="DEBUG")
/subsystem="logging"/logger="sun.rmi":add(category="sun.rmi",level="WARN")
/subsystem="logging"/pattern-formatter="PATTERN":add(pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n")
/subsystem="logging"/pattern-formatter="COLOR-PATTERN":add(pattern="%K{level}%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n")
/subsystem="logging"/periodic-rotating-file-handler="FILE":add(append="true",autoflush="true",file={"relative-to" => "jboss.server.log.dir","path" => "server.log"},name="FILE",named-formatter="PATTERN",suffix=".yyyy-MM-dd")
/subsystem="logging"/root-logger="ROOT":add(handlers=["CONSOLE","FILE"],level="INFO")
run-batch
batch
/subsystem="batch-jberet":add(default-job-repository="in-memory",default-thread-pool="batch")
. . . .

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 infinispan subsystem you can run:

./profilecloner.sh -f save-script.cli  --controller=localhost --username=admin --password=admin /subsystem=infinispan infinispan

Running Profile Cloner in Domain mode

To run Profile Cloner in Domain mode requires you to add the domain profile that you want to clone. For example, if you were to clone the full-ha profile of your Domain configuration you can run:

./profilecloner.sh -f save-script.cli  --controller=localhost --username=admin --password=admin /profile=full-ha full-ha

Now your save-script.cli contains all the CLI configuration for your profile:

batch
/profile="full-ha":add()
/profile="full-ha"/subsystem="logging":add()
/profile="full-ha"/subsystem="logging"/logger="com.arjuna":add(category="com.arjuna",level="WARN")
/profile="full-ha"/subsystem="logging"/logger="io.jaegertracing.Configuration":add(category="io.jaegertracing.Configuration",level="WARN")
/profile="full-ha"/subsystem="logging"/logger="org.jboss.as.config":add(category="org.jboss.as.config",level="DEBUG")
/profile="full-ha"/subsystem="logging"/logger="sun.rmi":add(category="sun.rmi",level="WARN")
/profile="full-ha"/subsystem="logging"/pattern-formatter="PATTERN":add(pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n")
/profile="full-ha"/subsystem="logging"/pattern-formatter="COLOR-PATTERN":add(pattern="%K{level}%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n")

Enjoy Profile Cloner!

Found the article helpful? if so please follow us on Socials