Starting filebeat issue from ansible for RHL6

31 views
Skip to first unread message

Daastan Pradhan

unread,
Jun 20, 2018, 3:28:47 PM6/20/18
to Ansible Project
I am running this task in ansible playbook.
- name: Start filebeat service
shell: /fisc/uts/bin/sudo filebeat start

This doesnot start the filebeat agent. But I have checked manually running that command on the test servers. It works fine. ( I tried ‘command’ instead of ‘shell’, it doesnt work either)

The stop command works tho if I replace start with stop. But ‘start’ and ‘restart’ doesnt work.Can you please help?

Prakash Sharma

unread,
Jun 20, 2019, 4:41:20 AM6/20/19
to Ansible Project
I am too facing this issue. 

When I do manually in the server , works fine , but from ansible ( using service module , command, shell , and even raw command ) it doesnt start .

Has anyone seen this , if yes , any clue ?

Dick Visser

unread,
Jun 20, 2019, 5:05:08 AM6/20/19
to ansible...@googlegroups.com
Your privilege escalation logic doesn’t look right. Please read up on 
More specifically don’t issue sudo as part of a command but instead use the ‘become’ logic of ansible. 

Also what environment variables does this filebeat command expect?
Running things manually in an interactive shell usually exposes a different set of environment vars than the ansible shell/command module. 

See 

Slightly related, the command uses a relative path so it could mean that it runs a different filebeat than what you’re using in an interactive shell. 


Dick 




--
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 post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d008e341-0ce6-4711-a3c0-0630086618a6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.

Angel Rengifo Cancino

unread,
Jun 20, 2019, 3:13:31 PM6/20/19
to ansible...@googlegroups.com
Just one additional comment (if applicable):

Would the "filebeat" binary require any environment variables to work properly? Maybe you have some vars that are defined on your shell session, but they're not defined within ansible execution context.

Prakash Sharma

unread,
Jun 20, 2019, 9:34:26 PM6/20/19
to Ansible Project
Thanks for you inputs guys ..

I too think it is missing some kind of environment variable when passed via ansible.  Today morning I have tried investigate further and found that , 

1. If I manually try to restart filebeat service with root user in the server or over SSH , file beat service starts normally..
for e.g

 ssh dev-bozo21 service filebeat restart
Or 
[root@dev-bozo21 ~]# service filebeat restart

works fine..

2. But I run my ansible as non root user and have enabled sudo permission for that .. So starting filebeat over SSH via non root user (lets say devans) doesnt work 

ssh -t devans@dev-bozo21 sudo /etc/init.d/filebeat restart   >>> Dont work 

But when I ssh to dev-bozo21 and then try to start the filebeat , this works 

[devans@dev-bozo21 ~]$ sleep 5 ; sudo /etc/init.d/filebeat restart  >>>>>>>> Works perfectly fine. 


I am wondering why  "ssh -t devans@dev-bozo21 sudo /etc/init.d/filebeat restart" ( I am sure ansible also tries something similar) doesn't work.


my code 
+++++++++++++++++++++++++++++
---
- hosts: "{{ target }}"
  become: yes
  become_method: sudo
  gather_facts: yes

(( Do some work )) 

  - name: restart filebeat
    service:
      name: filebeat
      state: restarted
      enabled: true
++++++++++++++++++++++++++++++++++
To unsubscribe from this group and stop receiving emails from it, send an email to ansible...@googlegroups.com.
--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.

--
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...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages