Manage JBoss 7 Application Server via CLI interface

2015.5.0 新版功能.

This state uses the script from a JBoss or Wildfly installation and parses its output to determine the execution result.

In order to run each state, a jboss_config dictionary with the following properties must be passed:

   cli_path: '/opt/jboss/jboss-7.0/bin/'
   cli_user: 'jbossadm'
   cli_password: 'jbossadm'

If the controller doesn't require a password, then the cli_user and cli_password parameters are optional.

Since same dictionary with configuration will be used in all the states, it may be more convenient to move JBoss configuration and other properties to the pillar.

Example of application deployment from local filesystem:

    - salt_source:
        target_file: '/tmp/webapp.war'
    - jboss_config: {{ pillar['jboss'] }}

For the sake of brevity, examples for each state assume that jboss_config is contained in the pillar.

salt.states.jboss7.bindings_exist(name, jboss_config, bindings, profile=None)

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.

Dict with connection properties (see state description)
Dict with bindings to set.
The profile name (domain mode only)


   - bindings:
      'java:global/sampleapp/environment': 'DEV'
      'java:global/sampleapp/configurationFile': '/var/opt/sampleapp/'
   - jboss_config: {{ pillar['jboss'] }}
salt.states.jboss7.datasource_exists(name, jboss_config, datasource_properties, recreate=False, profile=None)

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.

Datasource property name
Dict with connection properties (see state description)
Dict with datasource properties
recreate : False
If set to True and datasource exists it will be removed and created again. However, if there are deployments that depend on the datasource, it will not me possible to remove it.
profile : None
The profile name for this datasource (domain mode only)


   - 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'] }}
   - profile: full-ha
salt.states.jboss7.deployed(name, jboss_config, salt_source=None)

Ensures that the given application is deployed on server.

Dict with connection properties (see state description)
How to find the artifact to be deployed.
Where to look in the minion's file system for the artifact to be deployed (e.g. '/tmp/application-web-0.39.war'). When source is specified, also specifies where to save the retrieved file.
(optional) File on salt master (e.g. salt://application-web-0.39.war). If absent, no files will be retrieved and the artifact in target_file will be used for the deployment.
(optional) Regular expression to match against existing deployments. When present, if there is a deployment that matches the regular expression, it will be undeployed before the new artifact is deployed.


Deployment of a file from minion's local file system:

    - salt_source:
        target_file: '/tmp/webapp.war'
    - jboss_config: {{ pillar['jboss'] }}

It is assumed that /tmp/webapp.war was made available by some other means. No applications will be undeployed; if an existing deployment that shares that name exists, then it will be replaced with the updated version.

Deployment of a file from the Salt master's file system:

   - 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.

If the source parameter of salt_source is specified, it can use any protocol that the file states use. This includes not only downloading from the master but also HTTP, HTTPS, FTP, Amazon S3, and OpenStack Swift.

salt.states.jboss7.reloaded(name, jboss_config, timeout=60, interval=5)

Reloads configuration of jboss server.

Dict with connection properties (see state description)
Time to wait until jboss is back in running state. Default timeout is 60s.
Interval between state checks. Default interval is 5s. Decreasing the interval may slightly decrease waiting time but be aware that every status check is a call to jboss-cli which is a java process. If interval is smaller than process cleanup time it may easily lead to excessive resource consumption.

This step performs the following operations:

  • Ensures that server is in running or reload-required state (by reading server-state attribute)
  • Reloads configuration
  • Waits for server to reload and be in running state


    - jboss_config: {{ pillar['jboss'] }}