Hello
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.
I don't use the Tomcat manager app to hot deploy apps, but I imagine you could use the uri or win_uri module to post your war file. You can run remote ansible playbooks using the 'Send Files Over SSH' Jenkins plugin - and probably other ways too, such as using the AWX or Tower REST api. While this might feel like extra work just to deploy your app into a development or test environment, you can reuse the same playbook to deploy to production.
Ansible is good for doing rolling updates when you have apps running in a cluster. By setting 'serial: 1' you can update one server at a time and avoid downtime, if that is important for you.
Hope this helps,
Jon
Yes you are right uri doesn't do that so curl would be the only other option I can think of right now.
The way we do releases without down time is to have a minimum of two vms running Tomcat and a load balancer in front of them. To deploy, we stop one Tomcat so that the load balancer stops sending it requests, then we just copy over the new war file and start the Tomcat again. Ansible polls a url that is served by the Tomcat app, so we can tell when it has finished deploying, then we just repeat the installation steps on the other Tomcat vm(s). Ansible makes this super easy as you just specify
serial: 1
in the playbook.
Ideally I would like to update the load balancer and take each vm out of the pool in turn, rather than relying on the health check performed by the load balancer to reroute traffic, but that is difficult for us as the load balancer is a shared resource used by other teams. It hasn't been a problem for us in practice though.
- name: Copy Apache Tomcat binaries to provisioned VM win_copy: src: "{{ role_path }}/files/tomcat/{{ tomcat_64 }}" dest: "{{ tomcat_64_path }}"
- name: Install Tomcat service on provisioned VM win_command: service.bat install args: chdir: "{{ tomcat_64_path }}\\{{ tomcat_64 }}\\bin\\"
- name: Set Tomcat startup mode to auto and ensure it is started win_service: name: tomcat* start_mode: auto state: started
- name: Startup Tomcat on provisioned VM win_command: startup.bat args: chdir: "{{ tomcat_64_path }}\\{{ tomcat_64 }}\\bin\\"- name: set tomcat parameters for startup
win_shell: '{{ tomcat_home }}\bin\tomcat8.exe update --Startup=auto --JvmMs=2000 --JvmMx=2000 --JvmOptions="-Dcatalina
.home={{ tomcat_home }}\;-Dcatalina.base={{ tomcat_home }}\;-Djava.endorsed.dirs={{ tomcat_home }}\endorsed;-Djava.io.tm
pdir={{ tomcat_home }}\temp;-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager;-Djava.util.logging.config
.file={{ tomcat_home }}\conf\logging.properties;-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n;-Xms1500M;
-Xmx1500M;"