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 in Ansible by Kiara
71 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 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 in Ansible by Kunal
57 views
0 votes
1 answer

unable to build grails war on a vagrant machine using ansible

Try and run the command using shell ...READ MORE

answered Jul 2, 2018 in Ansible by ajs3033
• 7,280 points
67 views
0 votes
1 answer

Install Ansible on centOS

Hey @Ali, Installing Ansible is a piece ...READ MORE

answered Jan 8 in Ansible by Kiara
42 views
0 votes
1 answer

Install Ansible using cygwin

Follow these steps to install ansible using ...READ MORE

answered Jan 10 in Ansible by Kush
1,123 views
0 votes
2 answers
+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,380 points
175 views
0 votes
3 answers
0 votes
1 answer

Unable to install Ansible on centOS

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

answered Dec 19, 2018 in Ansible by Alan
31 views