Merge branch 'feat/deploy' into 'master'
Feat/deploy See merge request tiutriumov.sm/ansible!3
This commit was merged in pull request #3.
This commit is contained in:
+22
-21
@@ -1,38 +1,39 @@
|
||||
user {{ nginx_user }};
|
||||
worker_processes 2048;
|
||||
worker_priority -1;
|
||||
user {{ nginx_user }};
|
||||
worker_processes 2048;
|
||||
worker_priority -1;
|
||||
|
||||
error_log /var/log/nginx/error.log warn;
|
||||
pid /var/run/nginx.pid;
|
||||
error_log /var/log/nginx/error.log warn;
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
events {
|
||||
worker_connections auto;
|
||||
worker_connections auto;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
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"';
|
||||
access_log /var/log/nginx/access.log main;
|
||||
include /etc/nginx/mime.types;
|
||||
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"';
|
||||
access_log /var/log/nginx/access.log main;
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
reset_timedout_connection on;
|
||||
client_body_timeout 35;
|
||||
send_timeout 30;
|
||||
keepalive_timeout 65;
|
||||
reset_timedout_connection on;
|
||||
client_body_timeout 35;
|
||||
send_timeout 30;
|
||||
gzip on;
|
||||
gzip_min_length 1000;
|
||||
gzip_min_length 1000;
|
||||
gzip_vary on;
|
||||
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_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";
|
||||
types_hash_max_size 2048;
|
||||
client_max_body_size 512m;
|
||||
proxy_buffer_size 64k;
|
||||
proxy_buffers 4 64k;
|
||||
proxy_busy_buffers_size 64k;
|
||||
proxy_buffer_size 64k;
|
||||
proxy_buffers 4 64k;
|
||||
proxy_busy_buffers_size 64k;
|
||||
server_names_hash_bucket_size 64;
|
||||
include /etc/nginx/modules-enabled/*.conf;
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
include /etc/nginx/sites-enabled/*;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -3,4 +3,4 @@
|
||||
hosts: node
|
||||
become: true
|
||||
roles:
|
||||
- role: ./tsm_labs
|
||||
- role: tsm_labs
|
||||
|
||||
+52
-17
@@ -1,24 +1,28 @@
|
||||
---
|
||||
- name: Update all packages Ubuntu
|
||||
when: ansible_os_family == 'Debian'
|
||||
run_once: true
|
||||
ansible.builtin.apt:
|
||||
update_cache: true
|
||||
upgrade: true
|
||||
|
||||
- name: Update all packages CentOS
|
||||
when: ansible_os_family == 'RedHat'
|
||||
run_once: true
|
||||
ansible.builtin.yum:
|
||||
name: "*"
|
||||
state: latest
|
||||
|
||||
- name: Install EPEL repo
|
||||
when: ansible_os_family == 'RedHat'
|
||||
run_once: true
|
||||
ansible.builtin.yum:
|
||||
name:
|
||||
- epel-release
|
||||
state: present
|
||||
|
||||
- name: Install git 'RedHat'
|
||||
run_once: true
|
||||
when: ansible_os_family == 'RedHat'
|
||||
ansible.builtin.yum:
|
||||
name:
|
||||
@@ -26,8 +30,9 @@
|
||||
state: present
|
||||
|
||||
- name: Install NodeJS-18 FRONTEND
|
||||
when: "'node1' in inventory_hostname"
|
||||
when: ansible_os_family == 'Debian'
|
||||
become: true
|
||||
run_once: true
|
||||
block:
|
||||
- name: Скачивание ключа
|
||||
ansible.builtin.get_url:
|
||||
@@ -49,35 +54,66 @@
|
||||
ansible.builtin.git:
|
||||
repo: https://gitlab.resds.ru/itt/sample-project.git
|
||||
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: Установка пакетов
|
||||
community.general.npm:
|
||||
path: /src/sample-project/notes-app/
|
||||
state: present
|
||||
- name: Пуск проекта FRONTEND
|
||||
command: npm start
|
||||
args:
|
||||
become: true
|
||||
- name: Delete old pm2 process
|
||||
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/
|
||||
|
||||
- name: Install NodeJS-18 BACKEND
|
||||
when: "'node2' in inventory_hostname"
|
||||
- name: Install NodeJS-18 Redhat
|
||||
when: ansible_os_family == 'RedHat'
|
||||
become: true
|
||||
run_once: true
|
||||
block:
|
||||
- name: Копирование проекта
|
||||
ansible.builtin.git:
|
||||
repo: https://gitlab.resds.ru/itt/sample-project.git
|
||||
dest: /src/sample-project
|
||||
- name: Установка Node.js & npm BACKEND
|
||||
ansible.builtin.yum:
|
||||
name:
|
||||
- nodejs
|
||||
- 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/
|
||||
npm:
|
||||
path: /src/sample-project/notes-backend/
|
||||
- name: Пуск проекта BACKEND
|
||||
command: npm start
|
||||
args:
|
||||
community.general.npm:
|
||||
path: /src/sample-project/notes-backend/
|
||||
- name: Установка pm2
|
||||
community.general.npm:
|
||||
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/
|
||||
- name: Install nginx 'Ubuntu'
|
||||
when: ansible_os_family == 'Debian'
|
||||
@@ -95,4 +131,3 @@
|
||||
group: root
|
||||
mode: "0644"
|
||||
notify: Reload nginx service
|
||||
|
||||
|
||||
@@ -2,3 +2,10 @@
|
||||
worker_connections: 512
|
||||
gzip_min_length: 1000
|
||||
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