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

+1 vote
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
• 130 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
+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
• 51,850 points
0 votes
1 answer

Is it possible to run an Ansible Playbook in python script?

Hey @Cerci, Of course its possible. You ...READ MORE

answered Jan 17, 2019 in Ansible by Nicolas
0 votes
1 answer

How to configure fact caching in Ansible?

There are two cache plugins: redis and jsonfile. To ...READ MORE

answered Jan 24, 2019 in Ansible by Kennedy
+13 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,400 points
0 votes
1 answer