mongodbamazon-web-servicesansibleansible-module

cant enable mongo service


I am trying to enable mongo service using ansible on my aws AMI. Here is the task for the playbook

- name: Mongodb repo
  yum_repository:
    name: mongodb
    description: mongodb
    baseurl: https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/
    gpgkey: https://www.mongodb.org/static/pgp/server-3.4.asc
- name: Install mongodb
  yum:
    name: mongodb-org
    state: present
- name: Enable mongodb
  service:
    name: mongodb-org
    enabled: true

and here is the error

TASK [mongodb_ami : Enable mongodb] ********************************************
fatal: [default]: FAILED! => {"changed": false, "msg": "Could not find the requested service mongodb-org: host"}

The first two task are okay but the last one (enabling doesnt work). How can I resolve this?


Solution

  • Are you sure the service name is mongodb-org? I think the service name is mongod:

    - name: Enable mongodb
      service:
        name: mongod
        enabled: true