How to execute a remote shell script in ansible

Abhishek Verma's picture

Hello ,

I am new to Ansible and trying to setup for automating deployment process .

I have written a simple playbook to execute a shell script ( at remote host) on remote host using command module .

=============================================

---

- name: start server.

  hosts: app

  remote_user: app

 

  tasks:

 

     - name: Start APP Service

       command: /home/app/current-app/etas/util_bin/start_app

       register: comm_out

     - debug: msg="{{ comm_out.stdout }}"

     - debug: msg="{{ comm_out.stderr }}"

==============================================

But it seems that its not able to load the libraries on remote host and fails to start the application process , however the ansible-playbook command line exist with success status .

 

Error :

===================

/home/app/current-app/etas/bin/eta_registry: error while loading shared libraries: libapp_r64.so.1: cannot open shared object file: No such file or directory\n/home/app/current-app/etas/bin/eta_log_manager: error while loading shared libraries: libapp_r64.so.1: cannot open shared object file: No such file or directory\

 

======================

 

Please help on this .

 

Thanks in Advance!!

 

 

 

Tags: 

3 Answers

Larry Brigman's picture

Verify that your user has the correct path to libraries to run the application and the necessary environmental variables.

The reason that your ansible script show success despite the fact that the application didn't start is that the shell script that is being exited with a result == 0.  Ansible just report pass/fail based on the exit status of the command - unless you tell it otherwise.

Abhishek Verma's picture

Thanks everyone .... Issue is resolved after giving absolute path in command .

CMCrossroads is a TechWell community.

Through conferences, training, consulting, and online resources, TechWell helps you develop and deliver great software every day.