Chapter 11. How to... The following CLI commands and operations provide basic examples on how to accomplish certain tasks. For detailed instructions, see the appropriate section of the Configuration Guide , Configuring Messaging , or other JBoss EAP documentation . Unless specified otherwise, the examples apply when running as a standalone server. Use the --help argument on a command to get usage for that command. Use the read-operation-description to get information on a particular operation for a resource. 11.1. Add a Datasource 11.2. Add an Extension Example: Add a New Extension to a Configuration 11.3. Add a Jakarta Messaging Queue 11.4. Add a Jakarta Messaging Topic 11.5. Add a Module Additional resources For more information see modules and dependencies . Important Using the module management CLI command to add and remove modules is provided as Technology Preview only. This command is not appropriate for use in a managed domain or when connecting to the management CLI remotely. Modules should be added and removed manually in a production environment. For more information, see the Create a Custom Module Manually and Remove a Custom Module Manually sections of the JBoss EAP Configuration Guide . Technology Preview features are not supported with Red Hat production service level agreements (SLAs), might not be functionally complete, and Red Hat does not recommend to use them for production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process. See Technology Preview Features Support Scope on the Red Hat Customer Portal for information about the support scope for Technology Preview features. 11.6. Add a Server Example: Add a New Server to a Host in a Managed Domain 11.7. Add a Server Group Example: Add a New Server Group in a Managed Domain 11.8. Add a System Property 11.9. Clone a Profile Example: Clone a Profile in a Managed Domain 11.10. Create a Hierarchical Profile Example: Create a New Profile That Inherits from Other Profiles 11.11. Deploy an Application to a Managed Domain Example: Deploy an Application to All Server Groups Example: Deploy an Application to One or More Server Groups 11.12. Deploy an Application to a Standalone Server 11.13. Disable All Applications You can use the deployment disable-all command to disable all the deployments. 11.14. Display the Active User Example: Command to Display the Current User Example: Output for the Current User 11.15. Display the Contents of an Attachment You can use the attachment display command to display the contents of an attachment returned from a management operation. This applies to any management operation that returns the attached-streams response header. For example, the following operation returns the server.log file attached as a stream. You can use the attachment display command to display the contents of the stream returned from this operation to the console. This outputs the contents of the server.log file to the console. 11.16. Display Schema Information To show the schema information for the :product-info command: To display the schema version, execute an ls command at the management CLI root and look for the management-*-version values: 11.17. Display System and Server Information Example: Command to Display the System and Server Information Example: Output for the System and Server Information Similarly, for a managed domain, you can display the information for a particular JBoss EAP host or server: 11.18. Enable All Disabled Deployments You can use the deployment enable-all command to enable all the deployments. 11.19. Get the Command Timeout Value Example: Display the CLI Command Timeout Value The value returned is in seconds. A value of 0 means no timeout. 11.20. Reload a Host Controller 11.21. Reload a Host Controller in Admin-only Mode 11.22. Reload All Servers in a Server Group Example: Reload All Servers in a Certain Server Group in a Managed Domain Note To reload the servers in a suspended state, pass in the start-mode=suspend argument. 11.23. Reload a Server Example: Reload a Server in a Managed Domain Note To reload the server in a suspended state, pass in the start-mode=suspend argument. 11.24. Reload a Standalone Server Note To reload the server in admin-only mode, pass in the --start-mode=admin-only argument. To reload the server in a suspended state, pass in the --start-mode=suspend argument. 11.25. Remove an Extension Example: Remove an Existing Extension 11.26. Remove a Module Important Using the module management CLI command to add and remove modules is provided as Technology Preview only. This command is not appropriate for use in a managed domain or when connecting to the management CLI remotely. Modules should be added and removed manually in a production environment. For more information, see the Create a Custom Module Manually and Remove a Custom Module Manually sections of the JBoss EAP Configuration Guide . Technology Preview features are not supported with Red Hat production service level agreements (SLAs), might not be functionally complete, and Red Hat does not recommend to use them for production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process. See Technology Preview Features Support Scope on the Red Hat Customer Portal for information about the support scope for Technology Preview features. 11.27. Reset the Command Timeout Value Example: Reset the Command Timeout to the Default Value Example: Reset the Command Timeout to the Value Provided by the CLI Configuration Note The value provided by the CLI configuration can be set in either in the EAP_HOME /bin/jboss-cli.xml file or passed in with the --command-timeout argument when starting the management CLI. 11.28. Restart All Servers in a Server Group Example: Restart All Servers in a Certain Server Group in a Managed Domain Note To restart the servers in a suspended state, pass in the start-mode=suspend argument. 11.29. Restart a Server Example: Restart a Server in a Managed Domain Note To restart the server in a suspended state, pass in the start-mode=suspend argument. 11.30. Save the Contents of an Attachment You can use the attachment save command to save the contents of an attachment returned from a management operation to a file. This applies to any management operation that returns the attached-streams response header. For example, the following operation returns the server.log file attached as a stream. You can use the attachment save command to save the contents of the stream returned form this operation to a file. This saves the contents of the server.log file to EAP_HOME /bin/log-output.txt . 11.31. Set the Command Timeout Value Example: Set the Maximum Time to Wait for a CLI Command to Complete The value is set in seconds. A value of 0 means no timeout. 11.32. Shut Down a Host Controller Example: Shut Down a Host Controller in a Managed Domain 11.33. Shut Down the Server Example: Shut Down a Standalone Server 11.34. Start All Servers in a Server Group Example: Start All Servers in a Certain Server Group in a Managed Domain Note To start the servers in a suspended state, pass in the start-mode=suspend argument. 11.35. Start a Server Example: Start a Server in a Managed Domain Note To start the server in a suspended state, pass in the start-mode=suspend argument. 11.36. Stop All Servers in a Server Group Example: Stop All Servers in a Certain Server Group in a Managed Domain 11.37. Stop a Server Example: Stop a Server in a Managed Domain 11.38. Take a Configuration Snapshot Example: Take a Snapshot of the Current Configurations 11.39. Undeploy All Applications Example: Undeploy All Applications from a Managed Domain Example: Undeploy All Applications from a Standalone Domain 11.40. Undeploy an Application from a Managed Domain Example: Undeploy an Application from All Server Groups with That Deployment Example: Undeploy an Application from a Specific Server Group 11.41. Undeploy an Application from a Standalone Server 11.42. Update a Host Name Example: Update the Name of a Host in a Managed Domain The host must be reloaded in order for the changes to take effect. 11.43. Upload an Attachment You can upload a local file as an attachment to management operations that accept file streams. For example, the following management CLI command uses the input-stream-index option to upload the contents of a local file to an exploded deployment. For more details on uploading files to a deployment, see the Add Content to an Exploded Deployment section of the Configuration Guide . 11.44. View a Server Log 11.45. Assigning a generic type command to a specific node You can assign a generic type command to a specific node type by using the --node-type argument. You can use the generic type command to edit properties or call the operations of a specific node type in a management model. The --node-type argument is available both on standalone servers and on servers in a managed domain. After you call a command, the server configuration file is updated. Issue help command in your terminal to view a description of the generic type command and any of its arguments. You can display a description of a command you created by issuing help [COMMAND_NAME] , where [COMMAND_NAME] is the name of your command. The procedure uses examples that demonstrate assigning a generic type command to a specific node type on a standalone server. You can also assign a generic type command to a specific node type in a managed domain. You must add a profile to each command. The following examples sets default as the profile. Procedure Append the --node-type argument to the command command. The following example specifies /subsystem=datasources/data-source as the node type, with data-source specified as the generic type command : Identify the target child node of a specified node type by completing one of the following methods: Specify a read-only property of the child node as an identifying property. The following example calls the flush-all-connection-in-pool operation in the myds resource. This resource is identified by the jndi-name property. Specify a value for the child node with the --name argument. The following example calls the flush-all-connection-in-pool operation in the myds resource. This resource is identified by the --name property. Use the add argument to add a new resource. Added properties are prefixed with -- . The following example shows new-ds as the new resource with --driver-name , --connection-url , and --pool-name properties defined for the resource: You can now edit writable properties by identifying a resource with the --jndi-name command. The following example displays myds as the identified resource, with the writable properties of min-pool-size and max-pool-size modified. 11.46. Assigning a generic type command to a child node You can assign a generic type command to an existing child node by using the --node-child argument. You can use the generic type command to edit properties or call the operations of a child node in the management model. The --node-child argument is available both on standalone servers and on servers in a managed domain. After you call a command, the server configuration file is updated. The procedure uses examples that demonstrate assigning a generic type command to a child node on a standalone server. You can also assign a generic type command to a child node in a managed domain. You must add a profile to each command. The following examples sets default as the profile. Note If you need to add the child node to the management model, you must specify the child node with the generic type command applied to a node type. Procedure Append the --node-child argument to the command command. The following example shows /core-service=management/access=authorization as the child node, with authorization specified as the generic type command : You can now write properties to an existing resource. The following example demonstrates writing properties to existing resources in the authorization child node . Additionally, you can send operations to the existing resource in the authorization child node. The following example sends the read-attribute operation to retrieve a value from the provider property.

Commands:
data-source add --name= DATASOURCE_NAME --jndi-name= JNDI_NAME --driver-name= DRIVER_NAME --connection-url= CONNECTION_URL
/extension= EXTENSION_NAME :add
jms-queue add --queue-address= QUEUE_NAME --entries= JNDI_NAME
jms-topic add --topic-address= TOPIC_NAME --entries= JNDI_NAME
module add --name= MODULE_NAME --resources= PATH_TO_RESOURCE --dependencies= DEPENDENCIES
/host= HOST_NAME /server-config= SERVER_NAME :add(group= SERVER_GROUP_NAME )
/server-group= SERVER_GROUP_NAME :add(profile= PROFILE_NAME , socket-binding-group= SOCKET_BINDING_GROUP_NAME )
/system-property= PROPERTY_NAME :add(value= PROPERTY_VALUE )
/profile= PROFILE_TO_CLONE :clone(to-profile= NEW_PROFILE_NAME )
/profile= NEW_PROFILE_NAME :add(includes=[ PROFILE_1 , PROFILE_2 ])
deployment deploy-file /path/to /DEPLOYMENT.war --all-server-groups
deployment deploy-file /path/to/DEPLOYMENT.war --server-groups= SERVER_GROUP_1 , SERVER_GROUP_2
deployment deploy-file /path/to/DEPLOYMENT.war
deployment disable /path/to/DEPLOYMENT.war
deployment disable-all
:whoami
{ "outcome" => "success", "result" => {"identity" => { "username" => "USDlocal", "realm" => "ManagementRealm" }} }
/subsystem=logging/log-file=server.log:read-attribute(name=stream) { "outcome" => "success", "result" => "f61a27c4-c5a7-43ac-af1f-29e90c9acb3e", "response-headers" => {"attached-streams" => [{ "uuid" => "f61a27c4-c5a7-43ac-af1f-29e90c9acb3e", "mime-type" => "text/plain" }]} }
attachment display --operation=/subsystem=logging/log-file=server.log:read-attribute(name=stream)
ATTACHMENT 3480a327-31dd-4412-bdf3-f36c94ac4a09: 2019-10-18 09:19:37,082 INFO [org.jboss.modules] (main) JBoss Modules version 1.8.6.Final-redhat-00001 2019-10-18 09:19:37,366 INFO [org.jboss.msc] (main) JBoss MSC version 1.4.5.Final-redhat-00001 2019-10-18 09:19:37,380 INFO [org.jboss.threads] (main) JBoss Threads version 2.3.2.Final-redhat-1 2019-10-18 09:19:37,510 INFO [org.jboss.as] (MSC service thread 1-1) WFLYSRV0049: JBoss EAP 7.4.0 (WildFly Core 10.0.0.Final-redhat-20190924) starting
:read-operation-description(name=product-info)
management-major-version=4 management-micro-version=0 management-minor-version=1
:product-info
{ "outcome" => "success", "result" => [{"summary" => { "host-name" => "__HOST_NAME__", "instance-identifier" => "__INSTANCE_ID__", "product-name" => "JBoss EAP", "product-version" => "EAP 7.4.0", "product-community-identifier" => "Product", "product-home" => "__EAP_HOME__", "standalone-or-domain-identifier" => "__OPERATING_MODE__", "host-operating-system" => "__OS_NAME__", "host-cpu" => { "host-cpu-arch" => "__CPU_ARCH__", "host-core-count" => __CORE_COUNT__ }, "jvm" => { "name" => "__JAVA_VM_NAME__", "java-version" => "__JAVA_VERSION__", "jvm-version" => "__JAVA_VM_VERSION__", "jvm-vendor" => "__JAVA_VM_VENDOR__", "java-home" => "__JAVA_HOME__" } }}] }
/host= HOST_NAME :product-info
/host= HOST_NAME /server= SERVER_NAME :product-info
deployment enable DEPLOYMENT.war
deployment enable-all --server-groups=other-server-group
command-timeout get
reload --host= HOST_NAME
reload --host= HOST_NAME --admin-only=true
/server-group= SERVER_GROUP_NAME :reload-servers
/host= HOST_NAME /server= SERVER_NAME :reload
reload
/extension= EXTENSION_NAME :remove
module remove --name= MODULE_NAME
command-timeout reset default
command-timeout reset config
/server-group= SERVER_GROUP_NAME :restart-servers
/host= HOST_NAME /server= SERVER_NAME :restart
/subsystem=logging/log-file=server.log:read-attribute(name=stream) { "outcome" => "success", "result" => "f61a27c4-c5a7-43ac-af1f-29e90c9acb3e", "response-headers" => {"attached-streams" => [{ "uuid" => "f61a27c4-c5a7-43ac-af1f-29e90c9acb3e", "mime-type" => "text/plain" }]} }
attachment save --operation=/subsystem=logging/log-file=server.log:read-attribute(name=stream) --file=log-output.txt
command-timeout set TIMEOUT_VALUE
shutdown --host= HOST_NAME
shutdown
/server-group= SERVER_GROUP_NAME :start-servers
/host= HOST_NAME /server= SERVER_NAME :start
/server-group= SERVER_GROUP_NAME :stop-servers
/host= HOST_NAME /server= SERVER_NAME :stop
:take-snapshot
deployment undeploy * --all-relevant-server-groups
deployment undeploy *
deployment undeploy DEPLOYMENT.war --all-relevant-server-groups
deployment undeploy DEPLOYMENT.war --server-groups= SERVER_GROUP_NAME
deployment undeploy DEPLOYMENT.war
/host= EXISTING_HOST_NAME :write-attribute(name=name,value= NEW_HOST_NAME ) reload --host= EXISTING_HOST_NAME
/deployment= DEPLOYMENT_NAME .war:add-content(content=[{target-path= /path/to/FILE_IN_DEPLOYMENT , input-stream-index= /path/to/LOCAL_FILE_TO_UPLOAD }]
/subsystem=logging/log-file= SERVER_LOG_NAME :read-log-file
[domain@localhost:9999 /] data-source --profile=default --jndi-name=myds --min-pool-size=11 --max-pool-size=22
[standalone@localhost:9999 /] command add --node-type=/subsystem=datasources/data-source --command-name=data-source
[standalone@localhost:9999 /] data-source flush-all-connection-in-pool --jndi-name=myds
[standalone@localhost:9999 /] data-source flush-all-connection-in-pool --name=myds
[standalone@localhost:9999 /] data-source add --jndi-name=my-new-ds --driver-name=h2 \ --connection-url=db:url --pool-name=my-ds-pool
[standalone@localhost:9999 /] data-source --jndi-name=myds --min-pool-size=11 --max-pool-size=22
[domain@localhost:9999 /] authorization --profile=default --provider=rbac --permission-combination-policy=permissive --use-identity-roles=false
[standalone@localhost:9999 /] command add --node-child=/core-service=management/access=authorization --command-name=authorization
[standalone@localhost:9999 /] authorization --provider=rbac --permission-combination-policy=permissive --use-identity-roles=false
[standalone@localhost:9999 /] authorization read-attribute --name=provider