WildFly CLI Scripting: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
Line 2: Line 2:


* [[WildFly CLI Operations#Subjects|CLI Operations]]
* [[WildFly CLI Operations#Subjects|CLI Operations]]
=Script Example=
<pre>
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
</pre>
=Deployment Script=
==Separated Bash Launcher and CLI Script==
<tt>deploy.sh</tt>:
<pre>
#!/bin/bash
reldir=$(dirname $0)
${JBOSS_HOME}/bin/jboss-cli.sh -c --file=${reldir}/deploy.cli
</pre>
<tt>deploy.cli</tt>:
<pre>
batch
#deploy target/playground.war --server-groups=main-server-group
deploy target/playground.war --force
run-batch
</pre>
==Coalesced Scripts==
This is where you can use bash variables.
<pre>
#!/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
</pre>
=Using Variables=
* JBoss EAP 6 : using variables in CLI scripts (jboss-cli.sh) https://access.redhat.com/solutions/321513
See [#Coalesced_Scripts|coalesced scripts] above.
<font color=red>
I've seen this example, how does it work, how is Host1_Name defined?
<pre>
/host=$Host1_Name:write-local-domain-controller
reload --host=$Host1_Name
</pre>
</font>

Revision as of 03:21, 11 February 2016

Internal

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

Separated Bash Launcher and CLI Script

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

See [#Coalesced_Scripts|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