WildFly CLI Scripting: Difference between revisions
Jump to navigation
Jump to search
Line 13: | Line 13: | ||
=Executing a Single Command= | =Executing a Single Command= | ||
< | Any word or phrase without white spaces in it is assumed to be a command. The <tt>--command</tt> optionally precedes it. | ||
</ | After a command is executed, the CLI will terminate the session. | ||
Example: | Example: | ||
<pre> | <pre> | ||
jboss-cli.sh -c | jboss-cli.sh -c ls | ||
</pre> | </pre> | ||
If a command requires space-separated arguments, command and the arguments should be enclosed is single quotes: | |||
<pre> | <pre> | ||
jboss-cli.sh -c 'deploy ./test.war --server-groups=web-frontend' | |||
</pre> | </pre> | ||
Revision as of 19:47, 22 February 2016
Internal
Connection to a Host Controller
In order to be able to interact with a host controller, CLI must be connected. For options on how to connect see:
Executing a Single Command
Any word or phrase without white spaces in it is assumed to be a command. The --command optionally precedes it.
After a command is executed, the CLI will terminate the session.
Example:
jboss-cli.sh -c ls
If a command requires space-separated arguments, command and the arguments should be enclosed is single quotes:
jboss-cli.sh -c 'deploy ./test.war --server-groups=web-frontend'
Executing Multiple Commands Specified on Command Line
--commands - specifies a comma-separated list (the list must not contain whitespaces) of commands and operations that should be executed in the CLI session. The CLI session will be automatically terminated as soon as the last command or operation has been executed or after the first error. Note: --commands argument is optional in a sense that any comma-separated list at the end of the argument list will be assumed to be the list of commands and operations.
Executing a Sequence of Commands Listed in a File
jboss-cli.sh -c --file=./commands.cli
where /commands.cli's content is similar to:
deploy ./test.war --server-groups=web-frontend
Script Example
batch # Configure the connection from main server to "one" and "two" /socket-binding-group=standard-sockets/remote-destination-outbound-socket-binding=remote-ejb:add(host=localhost, port=4647) # add security realm /core-service=management/security-realm=ejb-security-realm:add() /core-service=management/security-realm=ejb-security-realm/server-identity=secret:add(value=cXVpY2stMTIz) # add the outbound connections to the remoting subsystem /subsystem=remoting/remote-outbound-connection=remote-ejb-connection:add(outbound-socket-binding-ref=remote-ejb, security-realm=ejb-security-realm, username=quickuser) /subsystem=remoting/remote-outbound-connection=remote-ejb-connection/property=SASL_POLICY_NOANONYMOUS:add(value=false) /subsystem=remoting/remote-outbound-connection=remote-ejb-connection/property=SSL_ENABLED:add(value=false) run-batch
Deployment Script
batch
deploy.sh:
#!/bin/bash reldir=$(dirname $0) ${JBOSS_HOME}/bin/jboss-cli.sh -c --file=${reldir}/deploy.cli
deploy.cli:
batch #deploy target/playground.war --server-groups=main-server-group deploy target/playground.war --force run-batch
Coalesced Scripts
This is where you can use bash variables.
#!/bin/bash # ... jboss-cli.sh -c <<EOF batch #deploy target/playground.war --server-groups=main-server-group deploy target/playground.war --force run-batch EOF
Using Variables
- JBoss EAP 6 : using variables in CLI scripts (jboss-cli.sh) https://access.redhat.com/solutions/321513
See coalesced scripts above.
I've seen this example, how does it work, how is Host1_Name defined?
/host=$Host1_Name:write-local-domain-controller reload --host=$Host1_Name