ansible playbook to install configure mongodb configure database schema add users and validate database by inserting data in it how it looks

+2 votes
I have written playbook for mongodb configuration, but after that configuring database schema, adding users, inserting data in db unable to write playbook. could you give a brief idea and modules used .
Dec 26, 2019 in Ansible by syeda
• 140 points

1 answer to this question.

+1 vote

Have a look at this, it might help:

$ cd /mongodb/tasks/main.yml

- name: MongoDB - Import public key
    keyserver: hkp://
    id: EA312927
- name: MongoDB - Add repository
    filename: '/etc/apt/sources.list.d/mongodb-org-3.2.list'
    repo: 'deb <a href=""></a> xenial/mongodb-org/3.2 multiverse'
    state: present
    update_cache: yes
- name: MongoDB - Install MongoDB
    name: mongodb-org
    state: present
    update_cache: yes
- name: MongoDB - Running state
    name: mongod
    state: started
answered Dec 27, 2019 by Yamini
Thanks but i have done till adding users, i want to validate the schema by inserting data in it.

I don't think there is a module specifically for inserting data into a MongoDB database. You can the exec module and execute the insert command.

Related Questions In Ansible

0 votes
1 answer

How to write ansible playbook to setup ubuntu workstation and install any updates on it

Hi@Shashi, Ansible has one module named ec2. This is ...READ MORE

answered Nov 19, 2020 in Ansible by MD
• 95,300 points
0 votes
1 answer
+1 vote
1 answer

Ansible-playbook to install and configure Nginx+Nodejs+Npm+PM2

Try thhis out: --- - hosts: hosts tasks: ...READ MORE

answered Sep 3, 2019 in Ansible by Kalgi
• 52,370 points
0 votes
1 answer

How to add multiple lines in a file using Ansible playbook?

Hi@akhtar, You can update your file using lineinfile ...READ MORE

answered Sep 16, 2020 in Ansible by MD
• 95,300 points
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
+2 votes
1 answer