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?

  • Check the debug log of Ansible. It should contain command run by Ansible. Run that command manually to debug. – Henrik Pingel Jun 29 at 18:27
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
| improve this answer | |
  • 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. – Andrew Fielden Jun 29 at 13:21
  • My apologies. That change does appear to have made a difference! Kudos to you. – Andrew Fielden Jun 29 at 13:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.