I execute an Ansible playbook with an ansible
user. The playbook executes properly, with no errors in the application log, no errors in the Ansible log. This .war
usually deploys with user "tomcat" when the deploy is manual.
Could this be the cause of the problem? Execute playbook with different users
This is my playbook (syntax is correct):
- name: Deploy war
hosts: grupo1
tasks:
- name: Stop Tomcat
command: systemctl stop tomcat
- name: Delete old war1
command: rm -rf /opt/tomcat/catalina_base/webapps.old/portal-admin
args:
warn: false
- name: Delete old war
command: rm -rf /opt/tomcat/catalina_base/webapps.old/portal-client
args:
warn: false
- name: Copy the old war
copy:
src: /opt/tomcat/catalina_base/webapps/portal-client
remote_src: true
dest: /opt/tomcat/catalina_base/webapps.old/
- name: Copy the old war2
copy:
src: /opt/tomcat/catalina_base/webapps/portal-admin
remote_src: true
dest: /opt/tomcat/catalina_base/webapps.old/
- name: delte the war fileclient
shell: /bin/rm -rf /opt/tomcat/catalina_base/webapps/portal-client/*
args:
warn: false
- name: deploy warclient
command: unzip /tmp/portal-client.war -d /opt/tomcat/catalina_base/webapps/portal-client/
args:
warn: false
- name: delete the war fileadmin
shell: /bin/rm -rf /opt/tomcat/catalina_base/webapps/portal-admin/*
args:
warn: false
- name: deploy waradmin
command: unzip /tmp/portal-admin.war -d /opt/tomcat/catalina_base/webapps/portal-admin/
args:
warn: false
- name: Start tomcat
command: systemctl start tomcat
The error when I execute the playbook is
Proxy Error
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET /portal-client/cm/misalud/.
Reason: Error reading from remote server
command
andshell
all around, for stuff you could be using Ansible modules for. For removing stuff, for example, usefile
module withstate: absent
; for service stop/start, use theservice
module instead ofsystemctl
. Check alsounarchive
. The use of modules makes your playbook more readable and more portable.shell
,command
and similar modules should be used only when the functionality is not covered by Ansible.