Using YAML to manage WildFly deployments

This article will teach you how to use a YAML configuration to manage your WildFly deployments tasks. This will help you to include in a YAML idempotent configuration also applications.

YAML deployment made simple

Firstly, if you are new to configuring WildFly with YAML, we recommend taking a look at this article: How to configure WildFly with YAML files

Therefore, you should be aware that you can boot WildFly with a YAML configuration with the -y ( or --yaml) option as you can see from the helper command line:

 --yaml=[<paths>], -y=[<paths>]      The yaml configuration files for
                                        customizing the configuration. Paths
                                        can be absolute, relative to the
                                        current execution directory or relative
                                        to the standalone configuration
                                        directory.

In WildFly 33 you can include deployments as part of your YAML configuration. Let’s see an example:

wildfly-configuration:
    deployment:
        app1.war:
            content:
                - 
                    path: app1.war
                    relative-to: jboss.server.base.dir
                    archive: true
            enabled: true
        app2.war:
            content:
                - 
                    path: app2.war
                    relative-to: jboss.server.base.dir
                    archive: true

The above configuration will include into the configuration two deployments: app1.war and app2.war. The first deployment (app1.war) is enabled, the second one (app2.war) it’s not.

To run the above configuration, you need to place the two deployments in the jboss.server.base.dir

Then, start WildFly as follows (assuming the YAML file is deploy.yml):

./standalone.sh -y deploy.yml

From the Console logs you should see that the application app1.war has been deployed. The app2.war is in the deployment stage but it’s not available:

Conclusion

By following this tutorial, you’ve learned how to configure a WildFly application using YAML files. While WildFly natively uses XML, integrating YAML provides a more readable and flexible way to manage configuration, especially for developers familiar with YAML. This approach is particularly useful in modern cloud-based environments where configuration management often utilizes YAML.