Created
February 26, 2018 09:31
-
-
Save VireshDoshi/5de99a514ab5d1a0c6db94dffa622f82 to your computer and use it in GitHub Desktop.
ansible playbook used by packer AMI provisioner creation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: all | |
tasks: | |
- name: Install the gpg key for nodejs LTS | |
become: true | |
apt_key: | |
url: "http://deb.nodesource.com/gpgkey/nodesource.gpg.key" | |
state: present | |
validate_certs: no | |
- name: Install the nodejs LTS repos | |
become: true | |
apt_repository: | |
repo: "deb http://deb.nodesource.com/node_8.x {{ ansible_distribution_release }} main" | |
state: present | |
update_cache: yes | |
- name: Install NodeJs | |
become: true | |
apt: | |
name: nodejs | |
state: present | |
- name: Install PM2 | |
become: true | |
command: npm install -g pm2 | |
- name: Create PM2 service | |
become: true | |
command: env PATH=$PATH:/usr/bin pm2 startup upstart -u ubuntu --hp /home/ubuntu | |
- name: PM2 startup configuration (pm2 start) | |
command: pm2 start bin/www --name="node-app" | |
args: | |
chdir: /home/ubuntu/node-app/ | |
- name: PM2 startup configuration (pm2 save) | |
command: pm2 save |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment