Search code examples
curljbossjboss7.xwildflywildfly-8

Remove war/ear from all servers configured in domain mode of wildfly with curl script


Below cmd only removes from server group but it doesnt remove from Content Repository. I want to remove war and deploy a fresh one.

curl --digest -D - http://username:pwd@localhost:9990/management --header   
"Content-Type: application/json" -d '{"operation":"remove", "address":[{"host":"master"},  
{"server":"server-one"},{"deployment":"Myapp.war"}],"json.pretty":1}'

Solution

  • It would probably be to use CLI if that's an option.

    $JBOSS_HOME/bin/jboss-cli.sh -c -u=user -p=password --command="undeploy Myapp.war --all-relevant-server-groups"
    

    If that's not an option then you'd need to remove the deployment all relevant server groups, then remove the deployment content. I don't think the command you're currently using should work. It will leave the deployment in an invalid state.

    Remove from the server group:

    /server-group=main-server-group/deployment=Myapp.war:remove
    

    Remove the content:

    /deployment=Myapp.war:remove
    

    The above are CLI commands, but the paths are the addresses so you could translate that to curl if you'd like too. Just make sure you remove the deployment from all relevant server groups before you attempt to remove the content.