Tuesday, October 10, 2017

amazon ec2 - Can't install PM2 services via Ansible on an Ubuntu EC2 instance

I'm using Ansible to create a pm2 service on a EC2 / Ubuntu instance. Below is the script. When I run it, PM2 is installed and the service is enabled. When I run pm2 list, I don't the see the service, but I can grep it (ps aux | grep node) and see that it's running. It also seems like a shadow copy of pm2 is running and loading the app, but I can't seem to control it.




- hosts: comm
sudo: yes
tasks:
- npm: name=pm2 global=yes
- name: configure pm2 to restart on startup
shell: pm2 startup ubuntu >& /dev/null chdir=~/ executable=/bin/bash
sudo: yes

sudo_user: root
- command: sudo env PATH=$PATH:/usr/bin pm2 startup ubuntu -u ubuntu
sudo: yes
- command: /usr/bin/pm2 save
- command: /usr/bin/pm2 start /home/ubuntu/something/app.js --name something

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...