0

I'm using Ansible to start the mongod service on a Centos 6.8 VM. The task is pretty straightforward:

- name: Start mongod service
  service: 
    state: started
    name: mongod

However the service fails to start, and in /var/log/messages I see

Jun 26 15:40:18 server1 ansible-service: Invoked with name=mongod pattern=None enabled=None state=started sleep=None arguments= runlevel=default
Jun 26 15:40:18 server1 init: mongod main process (4133) terminated with status 1
Jun 26 15:40:18 server1 init: mongod main process ended, respawning
Jun 26 15:40:18 server1 init: mongod main process (4143) terminated with status 1
Jun 26 15:40:18 server1 init: mongod main process ended, respawning
Jun 26 15:40:18 server1 init: mongod main process (4145) terminated with status 1
Jun 26 15:40:18 server1 init: mongod main process ended, respawning
Jun 26 15:40:18 server1 init: mongod main process (4147) terminated with status 1
Jun 26 15:40:18 server1 init: mongod main process ended, respawning
Jun 26 15:40:18 server1 init: mongod main process (4149) terminated with status 1
Jun 26 15:40:18 server1 init: mongod main process ended, respawning
Jun 26 15:40:18 server1 init: mongod main process (4151) terminated with status 1
Jun 26 15:40:18 server1 init: mongod main process ended, respawning
Jun 26 15:40:18 server1 init: mongod main process (4153) terminated with status 1
Jun 26 15:40:18 server1 init: mongod main process ended, respawning
Jun 26 15:40:18 server1 init: mongod main process (4155) terminated with status 1
Jun 26 15:40:18 server1 init: mongod main process ended, respawning
Jun 26 15:40:18 server1 init: mongod main process (4157) terminated with status 1
Jun 26 15:40:18 server1 init: mongod main process ended, respawning
Jun 26 15:40:18 server1 init: mongod main process (4159) terminated with status 1
Jun 26 15:40:18 server1 init: mongod main process ended, respawning
Jun 26 15:40:18 server1 init: mongod main process (4161) terminated with status 1
Jun 26 15:40:18 server1 init: mongod respawning too fast, stopped

In /var/log/mongodb/mongod.log I see that the process received a SIGTERM

2020-06-25T18:57:21.842+0000 I NETWORK  [conn1] end connection 127.0.0.1:49576 (0 connections now open)
2020-06-25T18:57:41.815+0000 I CONTROL  [signalProcessingThread] got signal 15 (Terminated), will terminate after current cmd ends

But I don't know what is sending this to the process, presumably init?

Now the really strange thing is that when I log on to the VM manually and start the mongod service, using service mongod start, it's perfectly happy and starts up normally.

Any ideas how I can track this one down, and find out why my process is being killed when starting via Ansible?

1
  • Check the debug log of Ansible. It should contain command run by Ansible. Run that command manually to debug. Jun 29, 2020 at 18:27

1 Answer 1

0

Unless you already log in as the root user from Ansible you probably need to include the become: yes option in the task for privilege escalation.

- name: Start mongod service
  service: 
    state: started
    name: mongod
  become: yes
2
  • Good suggestion. However I am using become in the top level Ansible playbook. But the weird thing is that the process does start up, and about 60 seconds later mysteriously receives a SIGTERM (signal 15). I don't know why. Jun 29, 2020 at 13:21
  • My apologies. That change does appear to have made a difference! Kudos to you. Jun 29, 2020 at 13:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .