Ansible Fails to Restart Jetty on a remote host

15 views
Skip to first unread message

Madushan Chathuranga

unread,
Sep 25, 2019, 9:58:24 AM9/25/19
to Ansible Project
Hi All,

I'm trying to restart jetty using an ansible script

bellow is a snippet from my script

---
 
- hosts: all
    tasks
:


     
- name: start jetty
       command
: sh jetty.sh restart
       args
:
         chdir
: /apps/servers/jetty/bin

my inventory file is 
10.0.18.225 ansible_user=appusr ansible_ssh_private_key_file=/home/ec2-user/key


What happens is ansible is able to restart the jetty server as expected. but once ansible script done it's execution jetty server stops.
Any Ideas why this would happen. I don't have the luxury to start jetty as a service here 'jetty start'. There are no error or sigkills in the jetty logs. ansible also shows Jetty Start : OK in it's stdrr output. Would be great if anyone could help me with this.

Thanks.

Jonathan Lozada De La Matta

unread,
Sep 25, 2019, 10:02:34 AM9/25/19
to ansible...@googlegroups.com
probably because you have sh on the command. Probably better if you pass the whole directory to jetty.sh restart. Like /apps/servers/jetty/bin/jetty.sh restart

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/ad1172d1-4cc0-4435-98e0-697fad20bfcb%40googlegroups.com.
--

Jonathan Cha'gara Lozada De La Matta

He / Him / His

Red Hat

Senior Automation Practice Consultant & Automation CoP Manager

Join the Automation CoP! https://red.ht/autocop

 

Andre Gronwald

unread,
Sep 25, 2019, 10:29:58 AM9/25/19
to Ansible Project
i think it is because the process is started within the ssh session opened by ansible, and if you close the session, the subprocesses will be stopped as well.

2 solutions:
1. use a system-service to restart jetty (don't know if it exists; maybe jetty.sh is doing this already, then the solution from jonathan would solve it))
2. use nohup at beginning of the command, to start the process outside of your ssh-session.

regards,
andre
Reply all
Reply to author
Forward
0 new messages