# \[question\] run logstash shell script in ansible playbooks

**URL:** <https://forum.ansible.com/t/question-run-logstash-shell-script-in-ansible-playbooks/31037>\
**Category:** Ansible Project\
**Created:** [August 14, 2019, 1:15am UTC](https://forum.ansible.com/t/question-run-logstash-shell-script-in-ansible-playbooks/31037 "2019-08-14T01:15:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![seungdols](https://avatars.discourse-cdn.com/v4/letter/s/aeb1de/32.png) [@seungdols](https://forum.ansible.com/u/seungdols)\
**Post date:** [August 14, 2019, 1:15am UTC](https://forum.ansible.com/t/question-run-logstash-shell-script-in-ansible-playbooks/31037/1 "2019-08-14T01:15:04Z")

</div>

Hi, I like ansible.

I have one question. I have the role of setup-logstash.

I want to execute the logstash process. (it doesn’t registration in service of centos)

setup-logstash role is download logstash.tar.gz and then unpack.

So, Copy config file to the target server and run a shell script (run daemon of logstash)

role of setup-logstash is success.

but, I get target server but doesn’t logstash process.

Can you explain why it doesn’t work ?

Thank you.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [August 14, 2019, 1:43pm UTC](https://forum.ansible.com/t/question-run-logstash-shell-script-in-ansible-playbooks/31037/2 "2019-08-14T13:43:31Z")

</div>

define 'doesn't work' and it would help to show exact task you are  
using and the output you get, adding -vvv is generally helpful when  
debugging.

---

<div class="post-metadata">

**Author:** ![seungdols](https://avatars.discourse-cdn.com/v4/letter/s/aeb1de/32.png) [@seungdols](https://forum.ansible.com/u/seungdols)\
**Post date:** [August 16, 2019, 11:00am UTC](https://forum.ansible.com/t/question-run-logstash-shell-script-in-ansible-playbooks/31037/3 "2019-08-16T11:00:00Z")

</div>

@Brian Coca, Thank you for your advice on how to ask questions.

To test, I configured the following:

start\_logstash.sh

`  
#!/bin/bash

LOG\_NAME=“access-to-kafka”  
cd ~/logstash/current  
bin/logstash -f …/conf/${LOG\_NAME}.conf --path.data=…/data/${LOG\_NAME} --path.logs=…/logs/${LOG\_NAME} --node.name=`hostname`-${LOG\_NAME} -w 4 &

`

and simple playbook

`

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [August 16, 2019, 2:36pm UTC](https://forum.ansible.com/t/question-run-logstash-shell-script-in-ansible-playbooks/31037/4 "2019-08-16T14:36:56Z")

</div>

> The playbook was successful, and in fact, logstash seems to be running on the target server, but logstash shut down a few seconds after running the playbook.

You seem to be using ansible to run a shell script, and it ran OK as far as ansible is involved.  
The error must be somewhere in your shell script.

Dick

---

<div class="post-metadata">

**Author:** ![seungdols](https://avatars.discourse-cdn.com/v4/letter/s/aeb1de/32.png) [@seungdols](https://forum.ansible.com/u/seungdols)\
**Post date:** [August 24, 2019, 5:33am UTC](https://forum.ansible.com/t/question-run-logstash-shell-script-in-ansible-playbooks/31037/5 "2019-08-24T05:33:37Z")

</div>

@Dick visser thank you for your advice.

I try to debug the shell script. but I connect to the target server and then I run shell script of logstash. It’s everything Ok.

So, I don’t know. But I try to debug my shell script.

thank you.

2019년 8월 16일 금요일 오후 11시 37분 22초 UTC+9, Dick Visser 님의 말:

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [August 24, 2019, 2:11pm UTC](https://forum.ansible.com/t/question-run-logstash-shell-script-in-ansible-playbooks/31037/6 "2019-08-24T14:11:04Z")

</div>

This sort of issues is usually down to a slightly different set of environment variables that you get when signed in through an interactive shell vs ansible shell.
