[question] run logstash shell script in ansible playbooks

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.

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.

@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

`

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

@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 님의 말:

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.