By Mike Croft
Taking an environment from development through to production is often an afterthought and can all too often be too far down the list of priorities. Initially, there may not be any obvious problems or issues with manually configuring a new production environment to match an existing one in development or test. As some customers I have visited have found, however, this will only lead to bigger and bigger inconsistency between platforms with ad-hoc changes causing different environments to diverge.
What’s our end-game?
In this scenario, our “Nirvana” is to have a well-known Payara Server configuration which accurately reflects production – no matter how long it has been since it was set up or how many times the server or your application has been updated!
How do we get there?
Traditionally, businesses would manually configure their infrastructure to a set specification and then simply restrict configuration changes to a process whereby each change (however small) must go through the all-powerful CAB, or Change Approval Board.
This does address some problems in that we can be sure that ad-hoc changes are not just applied without thought to the consequences. Depending on the process, it also may ensure that various environments are kept in sync though it isn’t perfect.
However, it doesn’t fix the problem of different versions of environments. An upgraded version of your application may well require a new datasource or new JMS resources before it can be deployed; in rare circumstances, they may require a whole new version of Payara Server if you are intending to use a new feature.
Infrastructure as code
The solution to this problem, as provided by a majority of DevOps tools is to maintain the entire production infrastructure as a scripted, versioned environment. Any changes which then need to happen, should (if principles are followed correctly) only happen to the pre-existing configuration scripts.
These changes are then pushed out through configuration management tools which ensure that each environment is correct and up-to-date with the latest version of the configuration – exactly as you would with application versions and a continuous integration server.
This, then, solves the issue of needing different versions of environments. It also ensures that you can replicate the version from development in test (meaning that you are testing exactly what you think you are) and that the move from test to production involves recreating the environment you have tested, rather than something approximating what you have tested.
How does Payara Server help?
Payara Server has many features which can integrate with your DevOps tool of choice.The command-line interface (CLI) gives a way to script changes, either by passing commands directly to the asadmin tool, or by wrapping the commands in a shell or batch file. For any feature of Payara Server which does not have a dedicated command, there is a system of dotted names to refer to each aspect of the configuration.
We’ve also shown that Payara Server has a REST interface which maps to asadmin commands so that you can use your favourite programming language (or simply cURL!) to make the changes you need.
We also have example repositories for Vagrant and Docker on our GitHub. Both Vagrant and Docker can be used alongside DevOps tools to help ease the creation and reproduction of versioned environments, with a slightly different approach. There is even an example Ansible role kindly contributed by Barry Van Someren.
New in version 162 of Payara Server ( released in May) is an asadmin command recorder feature, which will output all the asadmin commands that correspond to changes you make in the admin console into a runnable file, making scripting much quicker to get started with!
We’re still working on improvements and new features that will help users of PayaraServer work with the platform and we’re always keen to hear new suggestions from the community (submit via GitHub or contact us)!
You can also subscribe to the blog to get the latest updates on what new things are coming to Payara Server and Payara Micro.