mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Documentation fixes for jboss7 and artifactory states/modules
This commit is contained in:
parent
0cc716624e
commit
8101b2a8e7
6
doc/ref/modules/all/salt.modules.artifactory.rst
Normal file
6
doc/ref/modules/all/salt.modules.artifactory.rst
Normal file
@ -0,0 +1,6 @@
|
||||
===================
|
||||
salt.modules.artifactory
|
||||
===================
|
||||
|
||||
.. automodule:: salt.modules.artifactory
|
||||
:members:
|
6
doc/ref/modules/all/salt.modules.jboss7.rst
Normal file
6
doc/ref/modules/all/salt.modules.jboss7.rst
Normal file
@ -0,0 +1,6 @@
|
||||
===================
|
||||
salt.modules.jboss7
|
||||
===================
|
||||
|
||||
.. automodule:: salt.modules.jboss7
|
||||
:members:
|
6
doc/ref/modules/all/salt.modules.jboss7_cli.rst
Normal file
6
doc/ref/modules/all/salt.modules.jboss7_cli.rst
Normal file
@ -0,0 +1,6 @@
|
||||
===================
|
||||
salt.modules.jboss7_cli
|
||||
===================
|
||||
|
||||
.. automodule:: salt.modules.jboss7_cli
|
||||
:members:
|
@ -56,6 +56,7 @@ Full list of builtin state modules
|
||||
ini_manage
|
||||
ipset
|
||||
iptables
|
||||
jboss7
|
||||
keyboard
|
||||
keystone
|
||||
kmod
|
||||
|
6
doc/ref/states/all/salt.states.artifactory.rst
Normal file
6
doc/ref/states/all/salt.states.artifactory.rst
Normal file
@ -0,0 +1,6 @@
|
||||
========================
|
||||
salt.states.jboss7
|
||||
========================
|
||||
|
||||
.. automodule:: salt.states.artifactory
|
||||
:members:
|
6
doc/ref/states/all/salt.states.jboss7.rst
Normal file
6
doc/ref/states/all/salt.states.jboss7.rst
Normal file
@ -0,0 +1,6 @@
|
||||
========================
|
||||
salt.states.jboss7
|
||||
========================
|
||||
|
||||
.. automodule:: salt.states.jboss7
|
||||
:members:
|
@ -16,6 +16,7 @@ log = logging.getLogger(__name__)
|
||||
def get_latest_snapshot(artifactory_url, repository, group_id, artifact_id, packaging, target_dir='/tmp', target_file=None):
|
||||
'''
|
||||
Gets latest snapshot of the given artifact
|
||||
|
||||
artifactory_url
|
||||
URL of artifactory instance
|
||||
repository
|
||||
@ -43,7 +44,8 @@ def get_latest_snapshot(artifactory_url, repository, group_id, artifact_id, pack
|
||||
|
||||
def get_snapshot(artifactory_url, repository, group_id, artifact_id, packaging, version, snapshot_version=None, target_dir='/tmp', target_file=None):
|
||||
'''
|
||||
Gets latest snapshot of the desired version of the artifact
|
||||
Gets snapshot of the desired version of the artifact
|
||||
|
||||
artifactory_url
|
||||
URL of artifactory instance
|
||||
repository
|
||||
@ -73,6 +75,7 @@ def get_snapshot(artifactory_url, repository, group_id, artifact_id, packaging,
|
||||
def get_release(artifactory_url, repository, group_id, artifact_id, packaging, version, target_dir='/tmp', target_file=None):
|
||||
'''
|
||||
Gets the specified release of the artifact
|
||||
|
||||
artifactory_url
|
||||
URL of artifactory instance
|
||||
repository
|
||||
|
@ -1,12 +1,22 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
Module for running tasks specific for JBoss AS 7.
|
||||
Module for managing JBoss AS 7 through the CLI interface.
|
||||
|
||||
All module functions require a jboss_config dict object with the following properties set:
|
||||
cli_path: the path to jboss-cli script, for example: '/opt/jboss/jboss-7.0/bin/jboss-cli.sh'
|
||||
controller: the ip address and port of controller, for example: 10.11.12.13:9999
|
||||
cli_user: username to connect to jboss administration console if necessary
|
||||
cli_password: password to connect to jboss administration console if necessary
|
||||
In order to run each function, jboss_config dictionary with the following properties must be passed:
|
||||
* cli_path: the path to jboss-cli script, for example: '/opt/jboss/jboss-7.0/bin/jboss-cli.sh'
|
||||
* controller: the ip addres and port of controller, for example: 10.11.12.13:9999
|
||||
* cli_user: username to connect to jboss administration console if necessary
|
||||
* cli_password: password to connect to jboss administration console if necessary
|
||||
|
||||
Example:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
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'
|
||||
|
||||
'''
|
||||
|
||||
@ -77,13 +87,13 @@ def create_datasource(jboss_config, name, datasource_properties):
|
||||
Datasource name
|
||||
datasource_properties
|
||||
A dictionary of datasource properties to be created:
|
||||
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
|
||||
- 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
|
||||
|
||||
'''
|
||||
log.debug("======================== MODULE FUNCTION: jboss7.create_datasource, name=%s", name)
|
||||
@ -138,13 +148,13 @@ def update_datasource(jboss_config, name, new_properties):
|
||||
Datasource name
|
||||
new_properties
|
||||
A dictionary of datasource properties to be updated. For example:
|
||||
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
|
||||
- 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
|
||||
|
||||
'''
|
||||
log.debug("======================== MODULE FUNCTION: jboss7.update_datasource, name=%s", name)
|
||||
|
@ -1,20 +1,14 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
Module for interaction with JbossAS7 through CLI.
|
||||
|
||||
All module functions require a jboss_config dict object with the following properties set:
|
||||
cli_path: the path to jboss-cli script, for example: '/opt/jboss/jboss-7.0/bin/jboss-cli.sh'
|
||||
controller: the ip addres and port of controller, for example: 10.11.12.13:9999
|
||||
cli_user: username to connect to jboss administration console if necessary
|
||||
cli_password: password to connect to jboss administration console if necessary
|
||||
Module for low-level interaction with JbossAS7 through CLI.
|
||||
|
||||
This module exposes two ways of interaction with the CLI, either through commands or operations.
|
||||
Following JBoss documentation (https://developer.jboss.org/wiki/CommandLineInterface):
|
||||
"Operations are considered a low level but comprehensive way to manage the AS controller,
|
||||
i.e. if it can't be done with operations it can't be done in any other way.
|
||||
Commands, on the other hand, are more user-friendly in syntax,
|
||||
although most of them still translate into operation requests and some of them even into a few
|
||||
composite operation requests, i.e. commands also simplify some management operations from the user's point of view."
|
||||
|
||||
.. note:: Following JBoss documentation (https://developer.jboss.org/wiki/CommandLineInterface):
|
||||
"Operations are considered a low level but comprehensive way to manage the AS controller, i.e. if it can't be done with operations it can't be done in any other way.
|
||||
Commands, on the other hand, are more user-friendly in syntax,
|
||||
although most of them still translate into operation requests and some of them even into a few
|
||||
composite operation requests, i.e. commands also simplify some management operations from the user's point of view."
|
||||
|
||||
The difference between calling a command or operation is in handling the result.
|
||||
Commands return a zero return code if operation is successful or return non-zero return code and
|
||||
@ -24,6 +18,22 @@ Operations return a json-like structure, that contain more information about the
|
||||
In case of a failure, they also return a specific return code. This module parses the output from the operations and
|
||||
returns it as a dictionary so that an execution of an operation can then be verified against specific errors.
|
||||
|
||||
In order to run each function, jboss_config dictionary with the following properties must be passed:
|
||||
* cli_path: the path to jboss-cli script, for example: '/opt/jboss/jboss-7.0/bin/jboss-cli.sh'
|
||||
* controller: the ip addres and port of controller, for example: 10.11.12.13:9999
|
||||
* cli_user: username to connect to jboss administration console if necessary
|
||||
* cli_password: password to connect to jboss administration console if necessary
|
||||
|
||||
Example:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
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'
|
||||
|
||||
'''
|
||||
|
||||
import logging
|
||||
@ -77,14 +87,14 @@ def run_operation(jboss_config, operation, fail_on_error=True, retries=1):
|
||||
cli_command_result = __call_cli(jboss_config, operation, retries)
|
||||
|
||||
if cli_command_result['retcode'] == 0:
|
||||
if is_cli_output(cli_command_result['stdout']):
|
||||
cli_result = parse(cli_command_result['stdout'])
|
||||
if _is_cli_output(cli_command_result['stdout']):
|
||||
cli_result = _parse(cli_command_result['stdout'])
|
||||
cli_result['success'] = cli_result['outcome'] == 'success'
|
||||
else:
|
||||
raise CommandExecutionError('Operation has returned unparseable output: %s' % cli_command_result['stdout'])
|
||||
else:
|
||||
if is_cli_output(cli_command_result['stdout']):
|
||||
cli_result = parse(cli_command_result['stdout'])
|
||||
if _is_cli_output(cli_command_result['stdout']):
|
||||
cli_result = _parse(cli_command_result['stdout'])
|
||||
cli_result['success'] = False
|
||||
match = re.search('^(JBAS\d+):', cli_result['failure-description'])
|
||||
cli_result['err_code'] = match.group(1)
|
||||
@ -189,14 +199,14 @@ def __escape_command(command):
|
||||
result = result.replace('"', '\\"') # replace " -> \"
|
||||
return result
|
||||
|
||||
def is_cli_output(text):
|
||||
def _is_cli_output(text):
|
||||
cli_re = re.compile("^\s*{.+}\s*$", re.DOTALL)
|
||||
if cli_re.search(text):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def parse(cli_output):
|
||||
def _parse(cli_output):
|
||||
tokens = __tokenize(cli_output)
|
||||
result = __process_tokens(tokens)
|
||||
|
||||
|
@ -15,12 +15,12 @@ def downloaded(name, artifact, target_dir='/tmp', target_file=None):
|
||||
|
||||
artifact:
|
||||
Details of the artifact to be downloaded from artifactory.
|
||||
- artifactory_url: URL of the artifactory instance
|
||||
- repository: Repository in artifactory
|
||||
- artifact_id: Artifact ID
|
||||
- group_id: Group ID
|
||||
- packaging: Packaging
|
||||
- version: Version
|
||||
- artifactory_url: URL of the artifactory instance
|
||||
- repository: Repository in artifactory
|
||||
- artifact_id: Artifact ID
|
||||
- group_id: Group ID
|
||||
- packaging: Packaging
|
||||
- version: Version
|
||||
target_dir:
|
||||
Directory where the artifact should be downloaded. By default it is downloaded to /tmp directory.
|
||||
target_file:
|
||||
@ -29,29 +29,33 @@ def downloaded(name, artifact, target_dir='/tmp', target_file=None):
|
||||
Example::
|
||||
Download artifact to a specific file:
|
||||
|
||||
jboss_module_downloaded:
|
||||
artifactory.downloaded:
|
||||
- artifact:
|
||||
artifactory_url: http://artifactory.intranet.company.com/artifactory
|
||||
repository: 'libs-release-local'
|
||||
artifact_id: 'module'
|
||||
group_id: 'com.company.module'
|
||||
packaging: 'jar'
|
||||
version: '1.0'
|
||||
- target_file: /opt/jboss7/modules/com/company/lib/module.jar
|
||||
.. code-block:: yaml
|
||||
|
||||
jboss_module_downloaded:
|
||||
artifactory.downloaded:
|
||||
- artifact:
|
||||
artifactory_url: http://artifactory.intranet.company.com/artifactory
|
||||
repository: 'libs-release-local'
|
||||
artifact_id: 'module'
|
||||
group_id: 'com.company.module'
|
||||
packaging: 'jar'
|
||||
version: '1.0'
|
||||
- target_file: /opt/jboss7/modules/com/company/lib/module.jar
|
||||
|
||||
Download artifact to the folder (automatically resolves file name):
|
||||
|
||||
jboss_module_downloaded:
|
||||
artifactory.downloaded:
|
||||
- artifact:
|
||||
artifactory_url: http://artifactory.intranet.company.com/artifactory
|
||||
repository: 'libs-release-local'
|
||||
artifact_id: 'module'
|
||||
group_id: 'com.company.module'
|
||||
packaging: 'jar'
|
||||
version: '1.0'
|
||||
- target_dir: /opt/jboss7/modules/com/company/lib
|
||||
.. code-block:: yaml
|
||||
|
||||
jboss_module_downloaded:
|
||||
artifactory.downloaded:
|
||||
- artifact:
|
||||
artifactory_url: http://artifactory.intranet.company.com/artifactory
|
||||
repository: 'libs-release-local'
|
||||
artifact_id: 'module'
|
||||
group_id: 'com.company.module'
|
||||
packaging: 'jar'
|
||||
version: '1.0'
|
||||
- target_dir: /opt/jboss7/modules/com/company/lib
|
||||
|
||||
'''
|
||||
log.debug(" ======================== STATE: artifactory.downloaded (name: %s) ", name)
|
||||
|
@ -1,54 +1,64 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
This state manages JBoss 7 AS via management interface.
|
||||
It uses jboss-cli.sh script from JBoss installation and parses its output to determine execution result.
|
||||
Manage JBoss 7 Application Server via CLI interface
|
||||
|
||||
In order to run each state, jboss_config dict with the following properties must be passed:
|
||||
This state uses jboss-cli.sh script from JBoss installation and parses its output to determine execution result.
|
||||
|
||||
jboss:
|
||||
cli_path: '/opt/jboss/jboss-7.0/bin/jboss-cli.sh'
|
||||
controller: 10.11.12.13:9999
|
||||
cli_user: 'jbossadm'
|
||||
cli_password: 'jbossadm'
|
||||
In order to run each state, jboss_config dictionary with the following properties must be passed:
|
||||
|
||||
If controller doesn't require password, then passing cli_user and cli_password parameters is not obligatory.
|
||||
.. code-block:: yaml
|
||||
|
||||
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.company.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'
|
||||
.. code-block:: yaml
|
||||
|
||||
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 for application deployment could be moved to pillars:
|
||||
application_deployed:
|
||||
jboss7.deployed:
|
||||
- artifact:
|
||||
artifactory_url: http://artifactory.intranet.company.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'
|
||||
|
||||
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'] }}
|
||||
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:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
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:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
artifactory:
|
||||
url: 'http://artifactory.intranet.company.com/artifactory'
|
||||
repository: 'libs-snapshots-local'
|
||||
@ -58,6 +68,9 @@ Configuration in pillars:
|
||||
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.
|
||||
|
||||
|
||||
'''
|
||||
|
||||
import time
|
||||
@ -83,22 +96,24 @@ def datasource_exists(name, jboss_config, datasource_properties, recreate=False)
|
||||
datasource_properties
|
||||
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.
|
||||
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.
|
||||
|
||||
Example::
|
||||
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'] }}
|
||||
.. code-block:: yaml
|
||||
|
||||
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'] }}
|
||||
|
||||
'''
|
||||
log.debug(" ======================== STATE: jboss7.datasource_exists (name: %s) ", name)
|
||||
@ -222,13 +237,16 @@ def bindings_exist(name, jboss_config, bindings):
|
||||
bindings:
|
||||
Dict with bindings to set.
|
||||
|
||||
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'] }}
|
||||
Example:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
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'] }}
|
||||
|
||||
'''
|
||||
log.debug(" ======================== STATE: jboss7.bindings_exist (name: %s) ", name)
|
||||
@ -283,7 +301,7 @@ def deployed(name, jboss_config, artifact=None, salt_source=None):
|
||||
jboss_config:
|
||||
Dict with connection properties (see state description)
|
||||
artifact:
|
||||
If set, the artifact to be deployed will be fetched from artifactory. This is a Dict object with the following properties:
|
||||
If set, the artifact will be fetched from artifactory. This is a Dict object with the following properties:
|
||||
- artifactory_url: Full url to artifactory instance, for example: http://artifactory.intranet.company.com/artifactory
|
||||
- repository: One of the repositories, for example: libs-snapshots, ext-release-local, etc..
|
||||
- artifact_id: Artifact ID of the artifact
|
||||
@ -291,6 +309,7 @@ def deployed(name, jboss_config, artifact=None, salt_source=None):
|
||||
- packaging: war/jar/ear, etc...
|
||||
- version: Artifact version. If latest_snapshot is set to True, the value of this attribute will be ignored, and newest snapshot will be taken instead.
|
||||
- latest_snapshot: If set to True and repository is a snapshot repository it will automatically select the newest snapshot.
|
||||
- snapshot_version: Exact version of the snapshot (with timestamp). A snapshot version may have several builds and a way to differentiate is to provide a build timestamp.
|
||||
- target_dir: Temporary directory on minion where artifacts will be downloaded
|
||||
salt_source:
|
||||
If set, the artifact to be deployed will be fetched from salt master. This is a Dict object with the following properties:
|
||||
@ -299,52 +318,60 @@ def deployed(name, jboss_config, artifact=None, salt_source=None):
|
||||
- undeploy: Regular expression to match against existing deployments. If any deployment matches the regular expression then it will be undeployed.
|
||||
|
||||
The deployment consists of the following steps:
|
||||
1) Fetch artifact (salt filesystem, artifact or filesystem on minion)
|
||||
2) Check if same artifact is not deployed yet (perhaps with different version)
|
||||
3) Undeploy the artifact if it is already deployed
|
||||
4) Deploy the new artifact
|
||||
|
||||
Example ::
|
||||
* Fetch artifact (salt filesystem, artifact or filesystem on minion)
|
||||
* Check if same artifact is not deployed yet (perhaps with different version)
|
||||
* Undeploy the artifact if it is already deployed
|
||||
* Deploy the new artifact
|
||||
|
||||
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'] }}
|
||||
.. code-block:: yaml
|
||||
|
||||
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
|
||||
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:
|
||||
|
||||
1) Deployment of specific version of artifact from Artifactory.
|
||||
1) Deployment of released version of artifact from Artifactory.
|
||||
|
||||
application_deployed:
|
||||
jboss7.deployed:
|
||||
- artifact:
|
||||
artifactory_url: http://artifactory.intranet.company.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'] }}
|
||||
.. code-block:: yaml
|
||||
|
||||
application_deployed:
|
||||
jboss7.deployed:
|
||||
- artifact:
|
||||
artifactory_url: http://artifactory.intranet.company.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:
|
||||
- Download artifact from artifactory. For released version the artifact will be downloaded from:
|
||||
'%(artifactory_url)s/%(repository)s/%(group_url)s/%(artifact_id)s/%(version)s/%(artifact_id)s-%(version)s.%(packaging)s'
|
||||
This follows artifactory convention for artifact resolution. By default the artifact will be downloaded to /tmp directory on minion.
|
||||
- Connect to JBoss via controller (defined in jboss_config dict) and check if the artifact is not deployed already. In case of artifactory
|
||||
it will check if any deployment's name starts with artifact_id value. If deployment already exists it will be undeployed
|
||||
- Deploy the downloaded artifact to JBoss via cli interface.
|
||||
|
||||
2) Deployment of SNAPSHOT version of artifact from Artifactory:
|
||||
* Download artifact from artifactory. In the example above the artifact will be fetched from: http://artifactory.intranet.company.com/artifactory/ext-release-local/com/company/application/webcomponent/0.1/webcomponent-0.1.war
|
||||
As a rule, for released versions the artifacts are downloaded from: artifactory_url/repository/group_id_with_slashed_instead_of_dots/artifact_id/version/artifact_id-version.packaging'
|
||||
This follows artifactory convention for artifact resolution. By default the artifact will be downloaded to /tmp directory on minion.
|
||||
* Connect to JBoss via controller (defined in jboss_config dict) and check if the artifact is not deployed already. In case of artifactory
|
||||
it will check if any deployment's name starts with artifact_id value. If deployment already exists it will be undeployed
|
||||
* Deploy the downloaded artifact to JBoss via cli interface.
|
||||
|
||||
2) Deployment of last updated version of given SNAPSHOT version of artifact from Artifactory.
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
application_deployed:
|
||||
jboss7.deployed:
|
||||
@ -357,12 +384,44 @@ def deployed(name, jboss_config, artifact=None, salt_source=None):
|
||||
version: '0.1-SNAPSHOT'
|
||||
- jboss_config: {{ pillar['jboss'] }}
|
||||
|
||||
Note that snapshot deployment is detected by convention - when version ends with "SNAPSHOT" string, then it is treated so.
|
||||
Deploying snapshot version involves an additional step of resolving the exact name of the artifact (including the timestamp), which
|
||||
is not necessary when deploying a release. Remember that in order to perform a snapshot deployment you have to set repository to a
|
||||
snapshot repository.
|
||||
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.company.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.company.com/artifactory/ext-snapshot-local/com/company/application/webcomponent/0.1-SNAPSHOT/webcomponent-RESOLVED_SNAPSHOT_VERSION.war
|
||||
|
||||
3) Deployment of latest snapshot of artifact from Artifactory.
|
||||
.. note:: In order to perform a snapshot deployment you have to:
|
||||
|
||||
* Set repository to a snapshot repository.
|
||||
* Choose a version that ends with "SNAPSHOT" string.
|
||||
Snapshot repositories have a different layout and provide some extra information that is needed for deployment of the last or a specific snapshot.
|
||||
|
||||
3) Deployment of SNAPSHOT version (with exact timestamp) of artifact from Artifactory.
|
||||
|
||||
If you need to deploy an exact version of the snapshot you may provide snapshot_version parameter.
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
application_deployed:
|
||||
jboss7.deployed:
|
||||
- artifact:
|
||||
artifactory_url: http://artifactory.intranet.company.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.company.com/artifactory/ext-snapshot-local/com/company/application/webcomponent/0.1-SNAPSHOT/webcomponent-0.1-20141023.131756-19.war
|
||||
|
||||
4) Deployment of latest snapshot of artifact from Artifactory.
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
application_deployed:
|
||||
jboss7.deployed:
|
||||
@ -376,8 +435,8 @@ def deployed(name, jboss_config, artifact=None, salt_source=None):
|
||||
- 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.
|
||||
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.
|
||||
|
||||
'''
|
||||
log.debug(" ======================== STATE: jboss7.deployed (name: %s) ", name)
|
||||
@ -584,10 +643,7 @@ def __fetch_from_artifactory(artifact):
|
||||
|
||||
def reloaded(name, jboss_config, timeout=60, interval=5):
|
||||
'''
|
||||
Reloads configuration of jboss server. 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
|
||||
Reloads configuration of jboss server.
|
||||
|
||||
jboss_config:
|
||||
Dict with connection properties (see state description)
|
||||
@ -598,10 +654,19 @@ def reloaded(name, jboss_config, timeout=60, interval=5):
|
||||
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.
|
||||
|
||||
Example::
|
||||
configuration_reloaded:
|
||||
jboss7.reloaded:
|
||||
- jboss_config: {{ pillar['jboss'] }}
|
||||
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
|
||||
|
||||
Example:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
configuration_reloaded:
|
||||
jboss7.reloaded:
|
||||
- jboss_config: {{ pillar['jboss'] }}
|
||||
'''
|
||||
log.debug(" ======================== STATE: jboss7.reloaded (name: %s) ", name)
|
||||
ret = {'name': name,
|
||||
|
@ -172,12 +172,12 @@ class JBoss7CliTestCase(TestCase):
|
||||
}
|
||||
'''
|
||||
|
||||
self.assertTrue(jboss7_cli.is_cli_output(text))
|
||||
self.assertTrue(jboss7_cli._is_cli_output(text))
|
||||
|
||||
def test_not_matches_cli_output(self):
|
||||
text = '''Some error '''
|
||||
|
||||
self.assertFalse(jboss7_cli.is_cli_output(text))
|
||||
self.assertFalse(jboss7_cli._is_cli_output(text))
|
||||
|
||||
def test_parse_flat_dictionary(self):
|
||||
text = '''{
|
||||
@ -185,7 +185,7 @@ class JBoss7CliTestCase(TestCase):
|
||||
"key2" => "value2"
|
||||
}'''
|
||||
|
||||
result = jboss7_cli.parse(text)
|
||||
result = jboss7_cli._parse(text)
|
||||
|
||||
self.assertEqual(len(result), 2)
|
||||
self.assertEqual(result['key1'], 'value1')
|
||||
@ -200,7 +200,7 @@ class JBoss7CliTestCase(TestCase):
|
||||
}
|
||||
}'''
|
||||
|
||||
result = jboss7_cli.parse(text)
|
||||
result = jboss7_cli._parse(text)
|
||||
|
||||
self.assertEqual(len(result), 2)
|
||||
self.assertEqual(result['key1'], 'value1')
|
||||
@ -215,7 +215,7 @@ class JBoss7CliTestCase(TestCase):
|
||||
"response-headers" => {"process-state" => "reload-required"}
|
||||
}'''
|
||||
|
||||
result = jboss7_cli.parse(text)
|
||||
result = jboss7_cli._parse(text)
|
||||
|
||||
self.assertTrue(result['result']['jta'])
|
||||
self.assertEqual(result['response-headers']['process-state'], 'reload-required')
|
||||
@ -233,7 +233,7 @@ class JBoss7CliTestCase(TestCase):
|
||||
"response-headers" => {"process-state" => "reload-required"}
|
||||
}'''
|
||||
|
||||
result = jboss7_cli.parse(text)
|
||||
result = jboss7_cli._parse(text)
|
||||
|
||||
self.assertEqual(result['outcome'], 'success')
|
||||
self.assertIsNone(result['result']['allocation-retry'])
|
||||
@ -254,7 +254,7 @@ class JBoss7CliTestCase(TestCase):
|
||||
"response-headers" => {"process-state" => "reload-required"}
|
||||
}'''
|
||||
|
||||
result = jboss7_cli.parse(text)
|
||||
result = jboss7_cli._parse(text)
|
||||
|
||||
self.assertEqual(result['outcome'], 'failed')
|
||||
self.assertTrue(result['rolled-back'])
|
||||
@ -273,7 +273,7 @@ class JBoss7CliTestCase(TestCase):
|
||||
}
|
||||
}'''
|
||||
|
||||
result = jboss7_cli.parse(text)
|
||||
result = jboss7_cli._parse(text)
|
||||
|
||||
self.assertEqual(result['outcome'], 'success')
|
||||
self.assertEqual(result['result']['binding-type'], 'simple')
|
||||
@ -288,7 +288,7 @@ class JBoss7CliTestCase(TestCase):
|
||||
}
|
||||
}'''
|
||||
|
||||
result = jboss7_cli.parse(text)
|
||||
result = jboss7_cli._parse(text)
|
||||
|
||||
self.assertEqual(result['outcome'], 'success')
|
||||
self.assertEqual(result['result']['min-pool-size'], 1233)
|
||||
@ -353,7 +353,7 @@ class JBoss7CliTestCase(TestCase):
|
||||
"response-headers" => {"process-state" => "reload-required"}
|
||||
}'''
|
||||
|
||||
result = jboss7_cli.parse(text)
|
||||
result = jboss7_cli._parse(text)
|
||||
|
||||
self.assertEqual(result['outcome'],'success')
|
||||
self.assertEqual(result['result']['max-pool-size'], 20)
|
||||
@ -386,7 +386,7 @@ class JBoss7CliTestCase(TestCase):
|
||||
}
|
||||
}
|
||||
'''
|
||||
result = jboss7_cli.parse(cli_output)
|
||||
result = jboss7_cli._parse(cli_output)
|
||||
|
||||
self.assertEqual(result['outcome'],'success')
|
||||
conn_url_attributes = result['result']['attributes']['connection-url']
|
||||
@ -426,7 +426,7 @@ class JBoss7CliTestCase(TestCase):
|
||||
}
|
||||
'''
|
||||
|
||||
result = jboss7_cli.parse(cli_output)
|
||||
result = jboss7_cli._parse(cli_output)
|
||||
|
||||
self.assertEqual(result['outcome'], 'success')
|
||||
conn_url_attributes = result['result']['attributes']['connection-url']
|
||||
|
Loading…
Reference in New Issue
Block a user