Добавил playbook для установки и конфигурации nginx+загрузки файлов

This commit is contained in:
Lulzette 2022-01-01 04:16:10 +00:00
parent 9e1bcd3f9a
commit 9e148c7965
3 changed files with 108 additions and 0 deletions

71
files/nginx.conf Normal file
View File

@ -0,0 +1,71 @@
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
##
# Virtual Host Configs
##
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www;
index index.html index.htm;
server_name _;
location / {
try_files $uri $uri/ =404;
}
}
}

37
playbook.yml Normal file
View File

@ -0,0 +1,37 @@
---
- hosts: localhost
connection: local
tasks:
- name: Install nginx
become: yes
apt:
name: nginx-light
update_cache: yes
state: latest
- name: Create dir
file:
path: /var/www
state: directory
- name: Copy repo files
become: yes
copy:
src: "{{ item }}"
dest: /var/www
owner: www-data
group: www-data
with_fileglob:
- src/*
- name: Copy config file
become: yes
copy:
src: files/nginx.conf
dest: /etc/nginx/nginx.conf
owner: root
notify:
- Reload nginx
handlers:
- name: Reload nginx
become: yes
service:
name: nginx
state: restarted