WildFly CLI Deployment Operations: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(42 intermediate revisions by the same user not shown)
Line 6: Line 6:


* [[WildFly CLI Operations#Subjects|WildFly CLI Operations]]
* [[WildFly CLI Operations#Subjects|WildFly CLI Operations]]
* [[WildFly Deployment Concepts|WildFly Deployment Concepts]]


=Overview=
=Overview=


Deployments are executed with the <tt>deploy</tt> command.  
Deployments and upgrades are performed in CLI with <tt>deploy</tt> command. Undeployments are triggered by the <tt>undeploy</tt> command. Both commands come with in-line help:


Undeployments are executed with the <tt>undeploy</tt> command.
deploy --help


In-line usage details can be obtained with:
undeploy --help


<pre>
The concepts behind deployment operations in standalone and domain mode are explained in {{Internal|WildFly Deployment Concepts|Deployment Concepts}}
deploy --help
undeploy --help
</pre>


<tt>deploy</tt>/<tt>undeploy</tt> interact with domain/AS instance's [[WildFly Deployment Concepts#Deployment_Artifact_Repository|Deployment Artifact Repository]].
=Standalone Mode=


=Examples=
<font color=red>TODO</font>


==Deployment of an Artifact that Has Not Been Deployed Yet==
=Domain Mode=
 
<pre>
jboss-cli.sh -c 'deploy ./path/to/example.war --server-group=web'
</pre>


==Deployment of an Artifact that Has Been Deployed Previously==
==Listing Artifacts in the Deployment Repository==


<pre>
deploy [-l]
jboss-cli.sh -c 'deploy ./path/to/example.war --force'
</pre>


==Undeployment==
Also, for both standalone and domain instances, the content of the artifact repository can be viewed by visiting the /deployment management model node.


<pre>
Actual deployments on domain server nodes can be viewed by navigating to the corresponding management model node:
jboss-cli.sh -c 'undeploy example.war --all-relevant-server-groups'
</pre>


=<tt>domain.xml</tt> Modifications=
/host=''<host-name>''/server=''<server-name>''/deployment


<pre>
==Addition of a New Artifact to Repository and Deployment to Server Nodes==
...
    <deployments>
        <deployment name="servlet-example.war" runtime-name="servlet-example.war">
            <content sha1="b4bcac8f15c72e964076680932b0989675078889"/>
        </deployment>
    </deployments>
...
</pre>


=Deploy Usage=
Content can be added to the deployment repository and pushed to server nodes in a single step. For new artifacts, their content is not known to the repository, so the path to the file must be specified in the "deploy" command.


<pre>
deploy ''<file-path>'' ''<server-group-specification>''
deploy
    (file_path [--script=script_name] [--name=deployment_name]
                  [--runtime-name=deployment_runtime_name]
                  [--force | --disabled] [--unmanaged]
    )
    |
    --name=deployment_name 
  [--server-groups=group_name (,group_name)* | --all-server-groups]
  [--headers={operation_header (;operation_header)*}]
</pre>


<tt>deploy</tt>  deploys the application designated by the <tt>file_path</tt> or enables an already existing but disabled deployment.  
When deploying on server nodes, the server group specification is required in domain mode, and it can be either "--all-server-groups" or a comma-separated list of server group names: "--server-groups=group1, group2, ...".  


If executed w/o arguments, will list all the existing deployments.
{{Warn|Note that if a deployment is to be deployed on multiple server groups, all server groups must be specified in the same deployment command, following the --server-groups option. If the artifact is deployed to a server group first, with one command, and to another server group with a subsequent command, the second deployment attempt will complain. }}


Example:
deploy /tmp/servlet-example.war --all-server-groups


deploy /tmp/test-servlet.war --name=mp-franklin.war --runtime-name=mp-franklin.war --force
The command stores the content in the artifact repository and then immediately pushes content to server nodes, as explained in [[WildFly_Deployment_Concepts#Domain_Deployment_Mechanics|Domain Deployment Mechanics]].
deploy ??? --server-groups=active-hq-nodes


If the deployment on the target server nodes fails for some reason - unsatisfied dependencies, etc. the CLI issues
JBAS010839: Operation failed or was rolled back on all servers.
and the content is not added to the artifact repository.


==file_path==  
==Addition of a New Artifact to Repository==


Absolute or relative. Not required if the deployment already exists in the [[WildFly Concepts#Deployment_Artifact_Repository|artifact repository]].
Artifacts can be placed in the repository without being pushed to server nodes, with:


==--name==
deploy ''<file-path>'' --disabled


The unique name of the deployment. If the file path argument is specified the name argument is optional, the file name is the default value.  
This operation will upload the content in the repository, but won't push it to any server node. To do that, the content will need to be deployed with a [[#Deploying_New_Repository_Content_to_Server_Nodes|separate command]].


==--runtime-name==
==Deployment of a New Repository Artifact to Server Nodes==


Optional argument. The runtime name for the deployment. This will form the basis for default Java EE application and module names. If not specified the value used for <tt>--name</tt> will be used.
Content that has already been added to the domain repository can be pushed to server nodes by identifying the artifact by name, and specifying the target nodes. If the content was never deployed to the server nodes, no additional deploy command options are needed:


There are cases when users may wish to have two deployments with the same <tt>runtime-name</tt> (two versions of application) both available in the management configuration, in which case the deployments would need to have distinct <tt>name</tt> values but would have the same <tt>runtime-name</tt>. Within an individual server, only one deployment with a given 'runtime-name' can deployed. However, multiple deployments with the same <tt>runtime-name</tt> can exist in the configuration, so long as only one is enabled.
deploy --name=''<artifact-name>'' ''<server-group-specification>''


==--force==
deploy --name=servlet-example.war --server-groups=group1


If the deployment with the specified name already exists, by default, deploy will be aborted. <tt>--force</tt> (or <tt>-f</tt>) will force the replacement.
Note that the existing artifact was previously deployed on at least one of the nodes specified as target, a deployment error will occur:


==--disabled==
[domain@localhost:9999 /] deploy --name=servlet-example.war --all-server-groups
{"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-1" => "JBAS014803: Duplicate resource [
    (\"server-group\" => \"group1\"),
    (\"deployment\" => \"servlet-example.war\")
]"}}


Indicates that the deployment has to be added to the repository disabled.
==Upgrade of an Artifact in Repository and All Server Nodes on which the Old Version was Deployed==


==--unmanaged==
A new version of an existing artifact can be added to the deployment repository and pushed to server nodes ''that are already running the current version of the artifact'' as part of one atomic operation. The path of the file containing the new version of the artifact must be specified in the "deploy" command.


If this argument is not specified, the deployment content will be copied (i.e. uploaded) to the server's deployment repository before it is deployed.
deploy --force ''<file-path>''  


If the argument is present, the deployment content will remain at and be  deployed directly from its original location specified with the <tt>file_path</tt>.Exploded deployments are supported only as unmanaged.
  deploy --force /tmp/servlet-example.war


==--server-groups|--all-server-groups == 
This operation updates the content in the repository, by placing the content under a different location, as the hash of the artifact is different, and pushes the content to the ''servers nodes on which the artifact was already deployed''.


Comma separated list of server group names the deploy command should apply to. Either <tt>--server-groups</tt> or <tt>--all-server-groups</tt> is required in the domain mode. This argument does not apply to standalone mode.
It is not possible to specify a different target server group as part of an upgrade operations:


{{Warn|The second deployment attempt will complain if the same artifact is deployed in succession, with two commands, on one server group then on another.}}
[domain@localhost:9999 /] deploy --force /tmp/servlet-example.war --all-server-groups
--force only replaces the content in the deployment repository and can't be used in combination with any of --disabled, --server-groups or --all-server-groups.


==-l==
More details on concepts behind a domain deployment are available in [[WildFly_Deployment_Concepts#Domain_Deployment_Mechanics|Domain Deployment Mechanics]].


Without arguments <tt>deploy</tt> will print all of the existing deployments in the repository. The presence of the <tt>-l</tt> switch will make the existing deployments printed one deployment per line,  instead of in columns (the default).
==Undeployment==
 
==--headers==
 
A list of operation headers separated by a semicolon.
 
==--script==
 
Used only if the <tt>file_path</tt> points a [[WildFly CLI Concepts#CLI_Archive|CLI archive]]. The value is the name of the script contained in a <tt>cli</tt> archive to execute. If not specified, defaults to '<tt>deploy.scr</tt>'.  The deploy command will execute the script given by the --script argument. All paths in the scripts are relative to the root directory in the cli  archive. The script is executed as a batch.
 
=Undeploy Usage=
 
<pre>
    undeploy name [--server-groups=group_name (,group_name)* |
                  --all-relevant-server-groups] [--keep-content]
                  [--headers={operation_header (;operation_header)*}]
</pre>
 
Undeploys the deployment with the given name and, depending on the arguments, removes its content from the repository.
 
If the deployment name isn't specified, prints the list of all the existing deployments.
 
==name==
 
The name of the deployment to undeploy.
 
==--server-groups|--all-relevant-server-groups==
 
Cmma separated list of server group names the undeploy command should apply to. Either <tt>--server-groups</tt> or <tt>--all-relevant-server-groups</tt> is required in the domain mode.
 
==--keep-content==
 
By default undeploy, besides disabling the deployment, also  removes its content from the repository. The presence of <tt>--keep-content</tt> will only disable the deployment without removing its content from the repository.
 
=-l=
 
Same as <tt>[[#-l|deploy -l]]</tt>.
 
==--headers==
 
Same as <tt>[[#--headers|deploy --headers]]</tt>.
 
==--path==
 
Same as <tt>[[#--path |deploy --path]]</tt>.
                       
==--script==
 
Can appear only if the file_path points a cli archive. The value is the name of the script contained in a cli archive to execute. If not specified, defaults to 'undeploy.scr'. All paths in the scripts are relative to the root directory in the cli archive. The script is executed as a batch.
 
=List Current Deployments=
 
See <tt>[[#-l_2|deploy -l]]</tt>. Also, for a standalone instance, current deployments can be listed visiting the /deployment node:
 
<pre>
[standalone@localhost:9999 deployment] cd /deployment
[standalone@localhost:9999 deployment] ls
</pre>
 
=Standalone Mode=
 
=Domain Mode=
 
==Deployment of a New Artifact to the Domain==
 
The artifact is not known to the repository, so the path to the file must be specified in the "deploy" command.
 
deploy /Users/ovidiu/playground/jee/servlet/simplest/target/servlet-example.war ''<server-group-specification>''
 
The server group specification is required in domain mode, and it can be either "--all-server-groups" or a comma-separated list of server group names: "--server-groups=group1, group2, ..."
 
deploy /tmp/servlet-example.war --all-server-groups
 
==Deployment of a Newer Version of an Existing Artifact to the Domain==


The new version of the artifact is not known to the repository, so the path to the file must be specified in the "deploy" command.
undeploy example.war --all-relevant-server-groups

Latest revision as of 16:20, 21 September 2017

External

Internal

Overview

Deployments and upgrades are performed in CLI with deploy command. Undeployments are triggered by the undeploy command. Both commands come with in-line help:

deploy --help
undeploy --help

The concepts behind deployment operations in standalone and domain mode are explained in

Deployment Concepts

Standalone Mode

TODO

Domain Mode

Listing Artifacts in the Deployment Repository

deploy [-l]

Also, for both standalone and domain instances, the content of the artifact repository can be viewed by visiting the /deployment management model node.

Actual deployments on domain server nodes can be viewed by navigating to the corresponding management model node:

/host=<host-name>/server=<server-name>/deployment

Addition of a New Artifact to Repository and Deployment to Server Nodes

Content can be added to the deployment repository and pushed to server nodes in a single step. For new artifacts, their content is not known to the repository, so the path to the file must be specified in the "deploy" command.

deploy <file-path> <server-group-specification>

When deploying on server nodes, the server group specification is required in domain mode, and it can be either "--all-server-groups" or a comma-separated list of server group names: "--server-groups=group1, group2, ...".


Note that if a deployment is to be deployed on multiple server groups, all server groups must be specified in the same deployment command, following the --server-groups option. If the artifact is deployed to a server group first, with one command, and to another server group with a subsequent command, the second deployment attempt will complain.

deploy /tmp/servlet-example.war --all-server-groups

The command stores the content in the artifact repository and then immediately pushes content to server nodes, as explained in Domain Deployment Mechanics.

If the deployment on the target server nodes fails for some reason - unsatisfied dependencies, etc. the CLI issues

JBAS010839: Operation failed or was rolled back on all servers.

and the content is not added to the artifact repository.

Addition of a New Artifact to Repository

Artifacts can be placed in the repository without being pushed to server nodes, with:

deploy <file-path> --disabled

This operation will upload the content in the repository, but won't push it to any server node. To do that, the content will need to be deployed with a separate command.

Deployment of a New Repository Artifact to Server Nodes

Content that has already been added to the domain repository can be pushed to server nodes by identifying the artifact by name, and specifying the target nodes. If the content was never deployed to the server nodes, no additional deploy command options are needed:

deploy --name=<artifact-name>  <server-group-specification>
deploy --name=servlet-example.war --server-groups=group1

Note that the existing artifact was previously deployed on at least one of the nodes specified as target, a deployment error will occur:

[domain@localhost:9999 /] deploy --name=servlet-example.war --all-server-groups
{"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-1" => "JBAS014803: Duplicate resource [
    (\"server-group\" => \"group1\"),
    (\"deployment\" => \"servlet-example.war\")
]"}}

Upgrade of an Artifact in Repository and All Server Nodes on which the Old Version was Deployed

A new version of an existing artifact can be added to the deployment repository and pushed to server nodes that are already running the current version of the artifact as part of one atomic operation. The path of the file containing the new version of the artifact must be specified in the "deploy" command.

deploy --force <file-path> 
deploy --force /tmp/servlet-example.war

This operation updates the content in the repository, by placing the content under a different location, as the hash of the artifact is different, and pushes the content to the servers nodes on which the artifact was already deployed.

It is not possible to specify a different target server group as part of an upgrade operations:

[domain@localhost:9999 /] deploy --force /tmp/servlet-example.war --all-server-groups 
--force only replaces the content in the deployment repository and can't be used in combination with any of --disabled, --server-groups or --all-server-groups.

More details on concepts behind a domain deployment are available in Domain Deployment Mechanics.

Undeployment

undeploy example.war --all-relevant-server-groups