简体   繁体   中英

starting mongod via ansible

as mentionned in the title, I have an ansible role that installs MongoDB perfectly. Now I want to start mongod after installation is done I tried :

- name: Start mongod
  command: mongod 

but when I run the role, the output freezes in that task

So any ideas on how to start mongod via ansible

The problem with this, that the mongodb start to run and the ansible waiting for the stop. But it won't be stop, because it is running. Create a systemd configuration for the mongodb and start it with the service ansible module.

Best way is to go with the init/startup script as @PumpkinSeed said but if you want to continue like this, then you can do like this:

- name: Start mongod
  shell: "mongod &"

Hope that helps you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM