Last active
November 7, 2019 08:41
-
-
Save PrashantBhatasana/b77bafbae93e5f14a174a9b3a08ddca6 to your computer and use it in GitHub Desktop.
This is a Demo Ansible playbook script to pull the latest changes and install new dependences with PM2 start and stop.
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
--- | |
- name: ANSIBLE - Configure Node server | |
hosts: SampleApp-Server | |
become: true | |
become_method: sudo | |
become_user: nodejs | |
vars: | |
node_version: 6.9.1 | |
tasks: | |
- name: SERVER | Update the software package repository | |
yum: | |
name: "*" | |
update_cache: yes | |
- name: SERVER | Ensure repo is up-to-date | |
git: | |
repo: "https://github.com/prashant-bhatasana/Node.git" | |
dest: "/home/nodejs/Node/" | |
depth: 1 | |
force: yes | |
accept_hostkey: yes | |
update: yes | |
- name: SERVER | Stop pm2 service | |
shell: "cd /home/nodejs/Node && source ~/.nvm/nvm.sh && pm2 stop 1" | |
- name: SERVER | Install node dependencies | |
shell: cd /home/nodejs/Node && source ~/.nvm/nvm.sh && npm install | |
- name: SERVER | Start pm2 service | |
shell: "cd /home/nodejs/Node && source ~/.nvm/nvm.sh && pm2 start 1" |
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
[demo-server-1] | |
10.86.485.123 ansible_ssh_user=root |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment