-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[defaults] | ||
inventory = hosts | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
echo "starting to deploy"; | ||
ansible-playbook vm.yml |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
cloud: | ||
hosts: | ||
i1.rustgym.com: | ||
vars: | ||
ansible_user: rustgym | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
server { | ||
listen 80 default_server; | ||
listen [::]:80 default_server; | ||
server_name _; | ||
location / { | ||
proxy_pass http://127.0.0.1:8080; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
--- | ||
- hosts: all | ||
vars: | ||
version: v0.0.9 | ||
tasks: | ||
- name: install sqlite | ||
apt: | ||
name: sqlite | ||
state: present | ||
become: yes | ||
- name: install nginx | ||
apt: | ||
name: nginx | ||
state: latest | ||
become: yes | ||
- name: stop nginx | ||
service: | ||
name: nginx | ||
state: stopped | ||
become: yes | ||
- name: copy nginx config | ||
copy: | ||
src: rustgym-nginx.cfg | ||
dest: /etc/nginx/sites-available/rustgym-nginx.cfg | ||
become: yes | ||
- name: symlink nginx config | ||
file: | ||
src: /etc/nginx/sites-available/rustgym-nginx.cfg | ||
dest: /etc/nginx/sites-enabled/default | ||
state: link | ||
become: yes | ||
- name: start nginx | ||
service: | ||
name: nginx | ||
state: started | ||
become: yes | ||
- name: create version dir | ||
file: | ||
path: '/home/rustgym/{{version}}' | ||
state: directory | ||
mode: '0755' | ||
- name: download rustgym | ||
get_url: | ||
url: 'https://github.com/warycat/rustgym/releases/download/{{version}}/rustgym.tar.gz' | ||
dest: /home/rustgym/rustgym.tar.gz | ||
- name: unarchive rustgym | ||
unarchive: | ||
src: /home/rustgym/rustgym.tar.gz | ||
dest: '/home/rustgym/{{version}}' | ||
remote_src: yes | ||
- name: Get running processes list from remote host | ||
ignore_errors: yes | ||
shell: "ps -few | grep rustgym-server | awk '{print $2}'" | ||
register: running_processes | ||
- name: Kill running processes | ||
ignore_errors: yes | ||
shell: "kill {{ item }}" | ||
with_items: "{{ running_processes.stdout_lines }}" | ||
- wait_for: | ||
path: "/proc/{{ item }}/status" | ||
state: absent | ||
with_items: "{{ running_processes.stdout_lines }}" | ||
ignore_errors: yes | ||
register: rustgym_processes | ||
- name: Force kill stuck processes | ||
ignore_errors: yes | ||
shell: "kill -9 {{ item }}" | ||
with_items: "{{ rustgym_processes.results | select('failed') | map(attribute='item') | list }}" | ||
- name: start rustgym | ||
shell: '/home/rustgym/{{version}}/target/release/rustgym-server >> /home/rustgym/rusgym.log &>> /home/rustgym/rusgym.error.log &' | ||
|
This file contains 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