manala/ansible-roles

[MongoDB] - Could not find the requested service mongod: host

lamualfa opened this issue · 1 comments

My laptop: Debian 10 Buster Desktop
Remote server: Debian 10 Buster Server
Ansible version: 2.9.9

Ansible config file:

---
- hosts: all
  remote_user: root
  become: true
  vars:
    - ansible_python_interpreter: /usr/bin/python3
  tasks:
    - name: Install & setting UFW
      import_role:
        name: weareinteractive.ufw
      vars:
        ufw_rules:
          [
            { port: 22, rule: allow, comment: SSH Server },
            { port: 80, rule: allow, comment: Nginx HTTP Server },
            { port: 443, rule: allow, comment: Nginx HTTPS Server },
            { port: 27017, rule: allow, comment: MongoDB Server },
          ]

    - name: Setting APT
      import_role:
        name: manala.apt
      vars:
        manala_apt_preferences:
          - mongodb@mongodb_4_2
        manala_apt:
          update: true

    - name: Install & setting Nginx
      import_role:
        name: nginxinc.nginx
      vars:
        nginx_enable: true
        nginx_start: true
        nginx_type: opensource

    - name: Install & setting MongoDB
      import_role:
        name: manala.mongodb
      vars:
        manala_mongodb_config:
          bind_ip: '0.0.0.0'

    - name: Install Pymongo
      pip:
        name: pymongo
        state: latest

    - name: Add default MongoDB user
      no_log: true
      mongodb_user:
        database: admin
        name: root
        password: ****
        roles: dbOwner

    - name: Install & setting NVM
      import_role:
        name: grzegorznowak.nvm_node
      vars:
        nvm_node_version: '12.16.3'
        nvm_install_globally: [yarn, pm2]

I run the configuration file above with:

ansible-playbook -i ./inventory setup-debian-10.yml

and an error appears as follows:

TASK [manala.mongodb : install > Packages] ***********************************************************************************************************
changed: [******.com]

TASK [manala.mongodb : config > Template] ************************************************************************************************************
changed: [******.com]

TASK [manala.mongodb : services > Services] **********************************************************************************************************
failed: [*****.com] (item=mongod) => {"ansible_loop_var": "item", "changed": false, "item": "mongod", "msg": "Could not find the requested service mongod: host"}

RUNNING HANDLER [nginxinc.nginx : (Handler: All OSs) Start NGINX] ************************************************************************************

RUNNING HANDLER [manala.mongodb : mongodb restart] ***************************************************************************************************

Solved!

I had this error too, I had to run manually:

systemctl daemon-reload

After that I ran the ansible playbook again and it didn't fail.

Ref: ansible/ansible#36585 (comment)