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
5,374 views

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
  apt_key:
    keyserver: hkp://keyserver.ubuntu.com:80
    id: EA312927
- name: MongoDB - Add repository
  apt_repository:
    filename: '/etc/apt/sources.list.d/mongodb-org-3.2.list'
    repo: 'deb <a href="http://repo.mongodb.org/apt/ubuntu">http://repo.mongodb.org/apt/ubuntu</a> xenial/mongodb-org/3.2 multiverse'
    state: present
    update_cache: yes
- name: MongoDB - Install MongoDB
  apt:
    name: mongodb-org
    state: present
    update_cache: yes
- name: MongoDB - Running state
  service:
    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,460 points
1,261 views
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,350 points
9,646 views
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,460 points
26,637 views
+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 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,040 views
+2 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP