Feat/deploy
This commit is contained in:
+22
-21
@@ -1,38 +1,39 @@
|
|||||||
user {{ nginx_user }};
|
user {{ nginx_user }};
|
||||||
worker_processes 2048;
|
worker_processes 2048;
|
||||||
worker_priority -1;
|
worker_priority -1;
|
||||||
|
|
||||||
error_log /var/log/nginx/error.log warn;
|
error_log /var/log/nginx/error.log warn;
|
||||||
pid /var/run/nginx.pid;
|
pid /var/run/nginx.pid;
|
||||||
|
|
||||||
events {
|
events {
|
||||||
worker_connections auto;
|
worker_connections auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
http {
|
http {
|
||||||
include /etc/nginx/mime.types;
|
include /etc/nginx/mime.types;
|
||||||
default_type application/octet-stream;
|
default_type application/octet-stream;
|
||||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"';
|
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"';
|
||||||
access_log /var/log/nginx/access.log main;
|
access_log /var/log/nginx/access.log main;
|
||||||
sendfile on;
|
sendfile on;
|
||||||
tcp_nopush on;
|
tcp_nopush on;
|
||||||
tcp_nodelay on;
|
tcp_nodelay on;
|
||||||
keepalive_timeout 65;
|
keepalive_timeout 65;
|
||||||
reset_timedout_connection on;
|
reset_timedout_connection on;
|
||||||
client_body_timeout 35;
|
client_body_timeout 35;
|
||||||
send_timeout 30;
|
send_timeout 30;
|
||||||
gzip on;
|
gzip on;
|
||||||
gzip_min_length 1000;
|
gzip_min_length 1000;
|
||||||
gzip_vary on;
|
gzip_vary on;
|
||||||
gzip_proxied expired no-cache no-store private auth;
|
gzip_proxied expired no-cache no-store private auth;
|
||||||
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
gzip_disable "msie6";
|
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
|
||||||
|
gzip_disable "msie6";
|
||||||
types_hash_max_size 2048;
|
types_hash_max_size 2048;
|
||||||
client_max_body_size 512m;
|
client_max_body_size 512m;
|
||||||
proxy_buffer_size 64k;
|
proxy_buffer_size 64k;
|
||||||
proxy_buffers 4 64k;
|
proxy_buffers 4 64k;
|
||||||
proxy_busy_buffers_size 64k;
|
proxy_busy_buffers_size 64k;
|
||||||
server_names_hash_bucket_size 64;
|
server_names_hash_bucket_size 64;
|
||||||
include /etc/nginx/modules-enabled/*.conf;
|
include /etc/nginx/modules-enabled/*.conf;
|
||||||
include /etc/nginx/conf.d/*.conf;
|
include /etc/nginx/conf.d/*.conf;
|
||||||
include /etc/nginx/sites-enabled/*;
|
include /etc/nginx/sites-enabled/*;
|
||||||
}
|
}
|
||||||
+1
-1
@@ -3,4 +3,4 @@
|
|||||||
hosts: node
|
hosts: node
|
||||||
become: true
|
become: true
|
||||||
roles:
|
roles:
|
||||||
- role: ./tsm_labs
|
- role: tsm_labs
|
||||||
|
|||||||
+52
-17
@@ -1,24 +1,28 @@
|
|||||||
---
|
---
|
||||||
- name: Update all packages Ubuntu
|
- name: Update all packages Ubuntu
|
||||||
when: ansible_os_family == 'Debian'
|
when: ansible_os_family == 'Debian'
|
||||||
|
run_once: true
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
update_cache: true
|
update_cache: true
|
||||||
upgrade: true
|
upgrade: true
|
||||||
|
|
||||||
- name: Update all packages CentOS
|
- name: Update all packages CentOS
|
||||||
when: ansible_os_family == 'RedHat'
|
when: ansible_os_family == 'RedHat'
|
||||||
|
run_once: true
|
||||||
ansible.builtin.yum:
|
ansible.builtin.yum:
|
||||||
name: "*"
|
name: "*"
|
||||||
state: latest
|
state: latest
|
||||||
|
|
||||||
- name: Install EPEL repo
|
- name: Install EPEL repo
|
||||||
when: ansible_os_family == 'RedHat'
|
when: ansible_os_family == 'RedHat'
|
||||||
|
run_once: true
|
||||||
ansible.builtin.yum:
|
ansible.builtin.yum:
|
||||||
name:
|
name:
|
||||||
- epel-release
|
- epel-release
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Install git 'RedHat'
|
- name: Install git 'RedHat'
|
||||||
|
run_once: true
|
||||||
when: ansible_os_family == 'RedHat'
|
when: ansible_os_family == 'RedHat'
|
||||||
ansible.builtin.yum:
|
ansible.builtin.yum:
|
||||||
name:
|
name:
|
||||||
@@ -26,8 +30,9 @@
|
|||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Install NodeJS-18 FRONTEND
|
- name: Install NodeJS-18 FRONTEND
|
||||||
when: "'node1' in inventory_hostname"
|
when: ansible_os_family == 'Debian'
|
||||||
become: true
|
become: true
|
||||||
|
run_once: true
|
||||||
block:
|
block:
|
||||||
- name: Скачивание ключа
|
- name: Скачивание ключа
|
||||||
ansible.builtin.get_url:
|
ansible.builtin.get_url:
|
||||||
@@ -49,35 +54,66 @@
|
|||||||
ansible.builtin.git:
|
ansible.builtin.git:
|
||||||
repo: https://gitlab.resds.ru/itt/sample-project.git
|
repo: https://gitlab.resds.ru/itt/sample-project.git
|
||||||
dest: /src/sample-project
|
dest: /src/sample-project
|
||||||
|
- name: Deploy FRONTEND
|
||||||
|
when: "'node1' in inventory_hostname"
|
||||||
|
become: true
|
||||||
|
block:
|
||||||
|
- name: Установка pm2
|
||||||
|
community.general.npm:
|
||||||
|
name: "pm2"
|
||||||
|
global: true
|
||||||
|
state: present
|
||||||
|
become: true
|
||||||
- name: Установка пакетов
|
- name: Установка пакетов
|
||||||
community.general.npm:
|
community.general.npm:
|
||||||
path: /src/sample-project/notes-app/
|
path: /src/sample-project/notes-app/
|
||||||
state: present
|
state: present
|
||||||
- name: Пуск проекта FRONTEND
|
become: true
|
||||||
command: npm start
|
- name: Delete old pm2 process
|
||||||
args:
|
ansible.builtin.shell:
|
||||||
|
cmd: pm2 delete Front || true
|
||||||
|
chdir: /src/sample-project/notes-app/
|
||||||
|
- name: Start pm2 process
|
||||||
|
ansible.builtin.shell:
|
||||||
|
cmd: pm2 start npm --name "Front" -- start
|
||||||
chdir: /src/sample-project/notes-app/
|
chdir: /src/sample-project/notes-app/
|
||||||
|
|
||||||
- name: Install NodeJS-18 BACKEND
|
- name: Install NodeJS-18 Redhat
|
||||||
when: "'node2' in inventory_hostname"
|
when: ansible_os_family == 'RedHat'
|
||||||
become: true
|
become: true
|
||||||
|
run_once: true
|
||||||
block:
|
block:
|
||||||
- name: Копирование проекта
|
|
||||||
ansible.builtin.git:
|
|
||||||
repo: https://gitlab.resds.ru/itt/sample-project.git
|
|
||||||
dest: /src/sample-project
|
|
||||||
- name: Установка Node.js & npm BACKEND
|
- name: Установка Node.js & npm BACKEND
|
||||||
ansible.builtin.yum:
|
ansible.builtin.yum:
|
||||||
name:
|
name:
|
||||||
- nodejs
|
- nodejs
|
||||||
- npm
|
- npm
|
||||||
|
|
||||||
|
- name: Deploy BACKEND
|
||||||
|
when: "'node2' in inventory_hostname"
|
||||||
|
become: true
|
||||||
|
block:
|
||||||
|
- name: Копирование проекта
|
||||||
|
ansible.builtin.git:
|
||||||
|
repo: https://gitlab.resds.ru/itt/sample-project.git
|
||||||
|
dest: /src/sample-project
|
||||||
|
single_branch: true
|
||||||
|
version: main
|
||||||
- name: Установка пакетов в директорию /src/sample-project/notes-backend/
|
- name: Установка пакетов в директорию /src/sample-project/notes-backend/
|
||||||
npm:
|
community.general.npm:
|
||||||
path: /src/sample-project/notes-backend/
|
path: /src/sample-project/notes-backend/
|
||||||
- name: Пуск проекта BACKEND
|
- name: Установка pm2
|
||||||
command: npm start
|
community.general.npm:
|
||||||
args:
|
name: pm2
|
||||||
|
global: true
|
||||||
|
state: present
|
||||||
|
- name: Delete old pm2 process
|
||||||
|
ansible.builtin.shell:
|
||||||
|
cmd: /usr/local/bin/pm2 delete Backend || true
|
||||||
|
chdir: /src/sample-project/notes-backend/
|
||||||
|
- name: Start pm2 process
|
||||||
|
ansible.builtin.shell:
|
||||||
|
cmd: /usr/local/bin/pm2 start npm --name "Backend" -- start
|
||||||
chdir: /src/sample-project/notes-backend/
|
chdir: /src/sample-project/notes-backend/
|
||||||
- name: Install nginx 'Ubuntu'
|
- name: Install nginx 'Ubuntu'
|
||||||
when: ansible_os_family == 'Debian'
|
when: ansible_os_family == 'Debian'
|
||||||
@@ -95,4 +131,3 @@
|
|||||||
group: root
|
group: root
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
notify: Reload nginx service
|
notify: Reload nginx service
|
||||||
|
|
||||||
|
|||||||
@@ -2,3 +2,10 @@
|
|||||||
worker_connections: 512
|
worker_connections: 512
|
||||||
gzip_min_length: 1000
|
gzip_min_length: 1000
|
||||||
client_max_body_size: 512m
|
client_max_body_size: 512m
|
||||||
|
|
||||||
|
nodejs_version: 18.x
|
||||||
|
nodejs_rpm_path: '{{ "pub_" + nodejs_version if nodejs_version != "0.10" else "pub" }}'
|
||||||
|
nodejs_rpm_key: rpm.nodesource.com/pub/el/NODESOURCE-GPG-SIGNING-KEY-EL
|
||||||
|
nodejs_rpm_url: rpm.nodesource.com/{{ nodejs_rpm_path }}/el/{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/nodesource-release-el{{ ansible_distribution_major_version
|
||||||
|
}}-1.noarch.rpm
|
||||||
|
nodejs_repo_name: nodesource
|
||||||
|
|||||||
Reference in New Issue
Block a user