Install mean stack on ubuntu using ansible

0 votes
I'm trying to install mean stack using ansible. How should my playbook look like?
Mar 15, 2019 in Ansible by Kiara
1,222 views

1 answer to this question.

0 votes

You can have three roles 

under /etc/ansible/roles

-prerequisites

-mongodb

-nodejs

under /etc/ansible - mean.yaml

- hosts: nodes
  become: yes
  become_method: sudo
  vars:
    #variable needed during node installation
    var_node: /tmp
  
  roles:
    - prerequisites
    - mongodb
    - nodejs

prerequisites.yml

- name: Install git
  apt:
    name: git
    state: present
    update_cache: yes

mongodb.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 http://repo.mongodb.org/apt/ubuntu trusty/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

nodejs.yml

- name: Node.js - Get script
  get_url:
    url: "http://deb.nodesource.com/setup_6.x"
    dest: "{{ var_node }}/nodejs.sh"

- name: Node.js - Set execution permission to script
  file:
    path: "{{ var_node }}/nodejs.sh"
    mode: "u+x"

- name: Node.js - Execute installation script
  shell: "{{ var_node }}/nodejs.sh"

- name: Node.js - Remove installation script
  file:
    path: "{{ var_node}}/nodejs.sh"
    state: absent

- name: Node.js - Install Node.js
  apt: name={{ item }} state=present update_cache=yes
  with_items:
    - build-essential
    - nodejs

- name: Node.js - Install bower and gulp globally
  npm: name={{ item }} state=present global=yes
  with_items:
    - bower
    - gulp
answered Mar 15, 2019 by Janice

Related Questions In Ansible

0 votes
1 answer

How do I install Ansible on Ubuntu?

Hey Kiara, Execute the following commands to Install ...READ MORE

answered Feb 20, 2019 in Ansible by Kunal
837 views
0 votes
1 answer

Requirements to install MySQL and MariaDB on ubuntu - Ansible

You don't really need anything specific. Just ...READ MORE

answered Oct 24, 2019 in Ansible by Bob
684 views
0 votes
1 answer

How to install mongodb on centos 7 using ansible

Hi@Shashi, I think for MongoDB you need to ...READ MORE

answered Sep 16, 2020 in Ansible by MD
• 95,460 points
3,895 views
0 votes
2 answers
+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,062 views
+1 vote
3 answers
0 votes
1 answer

Unable to install Ansible on centOS

Seems like you're stuck at creating ansible ...READ MORE

answered Dec 20, 2018 in Ansible by Alan
704 views
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