Manage JBoss 7 Application Server via CLI interface
New in version 2015.5.0.
This state uses jboss-cli.sh script from JBoss installation and parses its output to determine execution result.
In order to run each state, jboss_config dictionary with the following properties must be passed:
jboss:
cli_path: '/opt/jboss/jboss-7.0/bin/jboss-cli.sh'
controller: 10.11.12.13:9999
cli_user: 'jbossadm'
cli_password: 'jbossadm'
If controller doesn't require password, then passing cli_user and cli_password parameters is not obligatory.
Example of application deployment:
application_deployed:
jboss7.deployed:
- artifact:
artifactory_url: http://artifactory.intranet.example.com/artifactory
repository: 'ext-release-local'
artifact_id: 'webcomponent'
group_id: 'com.company.application'
packaging: 'war'
version: '0.1'
target_dir: '/tmp'
- jboss_config:
cli_path: '/opt/jboss/jboss-7.0/bin/jboss-cli.sh'
controller: 10.11.12.13:9999
cli_user: 'jbossadm'
cli_password: 'jbossadm'
Since same dictionary with configuration will be used in all the states, it is much more convenient to move jboss configuration and other properties to pillar. For example, configuration of jboss server, artifactory address and application version could be moved to pillars:
application_deployed:
jboss7.deployed:
- artifact:
artifactory_url: {{ pillar['artifactory']['url'] }}
repository: {{ pillar['artifactory']['repository'] }}
artifact_id: 'webcomponent'
group_id: 'com.company.application'
packaging: 'war'
version: {{ pillar['webcomponent-artifact']['version'] }}
latest_snapshot: {{ pillar['webcomponent-artifact']['latest_snapshot'] }}
repository: {{ pillar['webcomponent-artifact']['repository'] }}
- jboss_config: {{ pillar['jboss'] }}
Configuration in pillars:
artifactory:
url: 'http://artifactory.intranet.example.com/artifactory'
repository: 'libs-snapshots-local'
webcomponent-artifact:
repository: 'libs-snapshots-local'
latest_snapshot: True
version: -1 #If latest_snapshot then version is ignored
For the sake of brevity, examples for each state assume that jboss_config is moved to pillars.
salt.states.jboss7.
bindings_exist
(name, jboss_config, bindings)¶Ensures that given JNDI binding are present on the server. If a binding doesn't exist on the server it will be created. If it already exists its value will be changed.
Example:
jndi_entries_created:
jboss7.bindings_exist:
- bindings:
'java:global/sampleapp/environment': 'DEV'
'java:global/sampleapp/configurationFile': '/var/opt/sampleapp/config.properties'
- jboss_config: {{ pillar['jboss'] }}
salt.states.jboss7.
datasource_exists
(name, jboss_config, datasource_properties, recreate=False)¶Ensures that a datasource with given properties exist on the jboss instance. If datasource doesn't exist, it is created, otherwise only the properties that are different will be updated.
Example:
sampleDS:
jboss7.datasource_exists:
- recreate: False
- datasource_properties:
driver-name: mysql
connection-url: 'jdbc:mysql://localhost:3306/sampleDatabase'
jndi-name: 'java:jboss/datasources/sampleDS'
user-name: sampleuser
password: secret
min-pool-size: 3
use-java-context: True
- jboss_config: {{ pillar['jboss'] }}
salt.states.jboss7.
deployed
(name, jboss_config, artifact=None, salt_source=None)¶Ensures that the given application is deployed on server.
The deployment consists of the following steps:
Examples:
Deployment of a file from Salt file system:
application_deployed:
jboss7.deployed:
- salt_source:
source: salt://application-web-0.39.war
target_file: '/tmp/application-web-0.39.war'
undeploy: 'application-web-.*'
- jboss_config: {{ pillar['jboss'] }}
Here, application-web-0.39.war file is downloaded from Salt file system to /tmp/application-web-0.39.war file on minion. Existing deployments are checked if any of them matches 'application-web-.*' regular expression, and if so then it is undeployed before deploying the application. This is useful to automate deployment of new application versions.
JBoss state is capable of deploying artifacts directly from Artifactory repository. Here are some examples of deployments:
application_deployed:
jboss7.deployed:
- artifact:
artifactory_url: http://artifactory.intranet.example.com/artifactory
repository: 'ext-release-local'
artifact_id: 'webcomponent'
group_id: 'com.company.application'
packaging: 'war'
version: '0.1'
target_dir: '/tmp'
- jboss_config: {{ pillar['jboss'] }}
This performs the following operations:
application_deployed:
jboss7.deployed:
- artifact:
artifactory_url: http://artifactory.intranet.example.com/artifactory
repository: 'ext-snapshot-local'
artifact_id: 'webcomponent'
group_id: 'com.company.application'
packaging: 'war'
version: '0.1-SNAPSHOT'
- jboss_config: {{ pillar['jboss'] }}
Deploying snapshot version involves an additional step of resolving the exact version of the artifact (including the timestamp), which is not necessary when deploying a release. In the example above first a request will be made to retrieve the update timestamp from: http://artifactory.intranet.example.com/artifactory/ext-snapshot-local/com/company/application/webcomponent/0.1-SNAPSHOT/maven-metadata.xml Then the artifact will be fetched from http://artifactory.intranet.example.com/artifactory/ext-snapshot-local/com/company/application/webcomponent/0.1-SNAPSHOT/webcomponent-RESOLVED_SNAPSHOT_VERSION.war
Note
In order to perform a snapshot deployment you have to:
If you need to deploy an exact version of the snapshot you may provide snapshot_version parameter.
application_deployed:
jboss7.deployed:
- artifact:
artifactory_url: http://artifactory.intranet.example.com/artifactory
repository: 'ext-snapshot-local'
artifact_id: 'webcomponent'
group_id: 'com.company.application'
packaging: 'war'
version: '0.1-SNAPSHOT'
snapshot_version: '0.1-20141023.131756-19'
- jboss_config: {{ pillar['jboss'] }}
In this example the artifact will be retrieved from: http://artifactory.intranet.example.com/artifactory/ext-snapshot-local/com/company/application/webcomponent/0.1-SNAPSHOT/webcomponent-0.1-20141023.131756-19.war
application_deployed:
jboss7.deployed:
- artifact:
artifactory_url: http://artifactory.intranet.example.com/artifactory
repository: 'ext-snapshot-local'
artifact_id: 'webcomponent'
group_id: 'com.company.application'
packaging: 'war'
latest_snapshot: True
- jboss_config: {{ pillar['jboss'] }}
Instead of providing an exact version of a snapshot it is sometimes more convenient to get the newest version. If artifact.latest_snapshot is set to True, then the newest snapshot will be downloaded from Artifactory. In this case it is not necessary to specify version. This is particulary useful when integrating with CI tools that will deploy the current snapshot to the Artifactory.
salt.states.jboss7.
reloaded
(name, jboss_config, timeout=60, interval=5)¶Reloads configuration of jboss server.
This step performs the following operations:
Example:
configuration_reloaded:
jboss7.reloaded:
- jboss_config: {{ pillar['jboss'] }}