Currently I build my app with maven and use the tomcat manager to hot deploy the war file (both on windows servers).

Now I want to use ansible to move away from the manual process.

  1. Would it make sense to build with ansible? My assumption is, that it does not.
  2. How could I use the tomcat manager to hot deploy, triggered by ansible. I have searched the web but I did not find a solution.
  3. Is there an other option to hot deploy the war file, which I might have overseen?
  • 1
    There's a manager-script context exactly for that in tomcat manager application.
    – Tensibai
    Commented Dec 8, 2017 at 16:15

2 Answers 2


I've got your point. Ansible is not the right choice for hot deployment to get rid of manual work and deploy the war files continuously to a server or where ever you want. Ansible is a configuration management tool. For this, you need an Automation deployment tool which is Jenkins. You need Jenkins in order to automate this. Create a Job, install a maven plugin within Jenkins and select the maven file before deploying the Code.

For Tomcat, You need to define about the tomcat instance within Jenkins and write the script in such a way it will automatically deploy the war file everytime you commit the code.

Best Practice, You better get a GIT repository and push your code there. Connect GitHub with Jenkins. The moment you will commit the code to GitHub it will automatically deploy the changes within tomcat through Jenkins and will Run the code.

  • You're speaking like the application version on a Middleware server wasn't a configuration thing...I've à hard time with this idea, the app version is no less a configuration step in the system than any other part
    – Tensibai
    Commented Dec 12, 2017 at 21:36

At the bottom line I found this method as stable and reliable, in case you want to deploy via ansible.

### This play deploys a webapp war to an tomcat server

- name: Copy the war file {{ webapp_name }}.war as {{ webapp_name }}.war.tmp to {{ webapp_destination_folder }}
    src: files/{{ webapp_name }}.war
    dest: "{{ webapp_destination_folder }}\\{{ webapp_name }}.war.tmp"
    force: yes 

- name: Remove current war file {{ webapp_destination_folder }}\{{ webapp_name }}.war
    path: "{{ webapp_destination_folder }}\\{{ webapp_name }}.war"
    state: absent

- name: Wait until the webapp folder {{ webapp_destination_folder }}\{{ webapp_name }} is deleted
    path: "{{ webapp_destination_folder }}\\{{ webapp_name }}xxx"
    state: absent
  register: folder_info

- name: rename the {{ webapp_name }}.war.tmp to {{ webapp_name }}.war
  win_command: "cmd.exe /c rename {{ webapp_destination_folder }}\\{{ webapp_name }}.war.tmp {{ webapp_name }}.war"
  register: cmd_result 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.