fix bugs add handlers

This commit is contained in:
reqwizz 2024-11-24 19:44:14 +03:00
parent 24fbd9246f
commit 0474fb6047
9 changed files with 121 additions and 9 deletions

View File

@ -1,5 +1,13 @@
ansible_python_interpreter: /usr/bin/python3.6 ansible_python_interpreter: /usr/bin/python3.6
nginx_worker_processes: auto
nginx_error_log: /var/log/nginx/error.log
nginx_error_log_level: warn
nginx_worker_connections: 1024
nginx_access_log: /var/log/nginx/access.log main
nginx_keepalive_timeout: 65
nginx_types_hash_max_size: 2048
siteA: siteA:
site_title: "SiteA - Добро пожаловать" site_title: "SiteA - Добро пожаловать"
site_h1: "Добро пожаловать на SiteA" site_h1: "Добро пожаловать на SiteA"

View File

@ -0,0 +1,4 @@
- name: Restart firewalld
systemd:
name: firewalld
state: restarted

View File

@ -2,12 +2,16 @@
zypper: zypper:
name: firewalld name: firewalld
state: present state: present
notify:
- Restart firewalld
- name: Ensure firewalld is enabled and started - name: Ensure firewalld is enabled and started
systemd: systemd:
name: firewalld name: firewalld
enabled: yes enabled: yes
state: started state: started
notify:
- Restart firewalld
- name: Open specified firewall ports - name: Open specified firewall ports
firewalld: firewalld:
@ -15,4 +19,6 @@
permanent: yes permanent: yes
state: enabled state: enabled
immediate: yes immediate: yes
loop: "{{ firewall_ports }}" loop: "{{ firewall_ports }}"
notify:
- Restart firewalld

View File

@ -0,0 +1,4 @@
- name: Restart Nginx
systemd:
name: nginx
state: restarted

View File

@ -2,12 +2,16 @@
zypper: zypper:
name: nginx name: nginx
state: present state: present
notify:
- Restart Nginx
- name: Ensure Nginx is enabled and started - name: Ensure Nginx is enabled and started
systemd: systemd:
name: nginx name: nginx
enabled: yes enabled: yes
state: started state: started
notify:
- Restart Nginx
- name: Create directory for error pages - name: Create directory for error pages
file: file:
@ -16,19 +20,28 @@
owner: nginx owner: nginx
group: nginx group: nginx
mode: '0755' mode: '0755'
notify:
- Restart Nginx
- name: Deploy custom error page - name: Deploy custom error page
template: template:
src: site_down.html.j2 src: site_down.html.j2
dest: /var/www/errors/site_down.html dest: /var/www/errors/site_down.html
mode: '0644' mode: '0644'
notify:
- Restart Nginx
- name: Deploy Proxy Configuration - name: Deploy Proxy Configuration
template: template:
src: proxy.conf.j2 src: proxy.conf.j2
dest: /etc/nginx/conf.d/proxy.conf dest: /etc/nginx/conf.d/proxy.conf
notify:
- Restart Nginx
- name: Reload Nginx - name: Deploy Main Nginx Configuration
systemd: template:
name: nginx src: nginx.conf.j2
state: reloaded dest: /etc/nginx/nginx.conf
mode: '0644'
notify:
- Restart Nginx

View File

@ -0,0 +1,27 @@
user nginx;
worker_processes {{ nginx_worker_processes }};
error_log {{ nginx_error_log }} {{ nginx_error_log_level }};
pid /var/run/nginx.pid;
events {
worker_connections {{ nginx_worker_connections }};
}
http {
include 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 {{ nginx_access_log }} main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout {{ nginx_keepalive_timeout }};
types_hash_max_size {{ nginx_types_hash_max_size }};
include /etc/nginx/conf.d/*.conf;
}

View File

@ -0,0 +1,4 @@
- name: Restart Nginx
systemd:
name: nginx
state: restarted

View File

@ -2,12 +2,16 @@
zypper: zypper:
name: nginx name: nginx
state: present state: present
notify:
- Restart Nginx
- name: Ensure Nginx is enabled and started - name: Ensure Nginx is enabled and started
systemd: systemd:
name: nginx name: nginx
enabled: yes enabled: yes
state: started state: started
notify:
- Restart Nginx
- name: Create web root for SiteA - name: Create web root for SiteA
file: file:
@ -17,6 +21,8 @@
group: nginx group: nginx
mode: '0755' mode: '0755'
when: "'SiteA' in group_names" when: "'SiteA' in group_names"
notify:
- Restart Nginx
- name: Create web root for SiteB - name: Create web root for SiteB
file: file:
@ -26,18 +32,24 @@
group: nginx group: nginx
mode: '0755' mode: '0755'
when: "'SiteB' in group_names" when: "'SiteB' in group_names"
notify:
- Restart Nginx
- name: Deploy SiteA Configuration - name: Deploy SiteA Configuration
template: template:
src: siteA.conf.j2 src: siteA.conf.j2
dest: /etc/nginx/conf.d/siteA.conf dest: /etc/nginx/conf.d/siteA.conf
when: "'SiteA' in group_names" when: "'SiteA' in group_names"
notify:
- Restart Nginx
- name: Deploy SiteB Configuration - name: Deploy SiteB Configuration
template: template:
src: siteB.conf.j2 src: siteB.conf.j2
dest: /etc/nginx/conf.d/siteB.conf dest: /etc/nginx/conf.d/siteB.conf
when: "'SiteB' in group_names" when: "'SiteB' in group_names"
notify:
- Restart Nginx
- name: Deploy SiteA HTML - name: Deploy SiteA HTML
template: template:
@ -49,6 +61,8 @@
site_h2: "{{ siteA.site_h2 }}" site_h2: "{{ siteA.site_h2 }}"
site_p: "{{ siteA.site_p }}" site_p: "{{ siteA.site_p }}"
when: "'SiteA' in group_names" when: "'SiteA' in group_names"
notify:
- Restart Nginx
- name: Deploy SiteB HTML - name: Deploy SiteB HTML
template: template:
@ -60,8 +74,13 @@
site_h2: "{{ siteB.site_h2 }}" site_h2: "{{ siteB.site_h2 }}"
site_p: "{{ siteB.site_p }}" site_p: "{{ siteB.site_p }}"
when: "'SiteB' in group_names" when: "'SiteB' in group_names"
notify:
- Restart Nginx
- name: Reload Nginx - name: Deploy Main Nginx Configuration
systemd: template:
name: nginx src: nginx.conf.j2
state: reloaded dest: /etc/nginx/nginx.conf
mode: '0644'
notify:
- Restart Nginx

View File

@ -0,0 +1,27 @@
user nginx;
worker_processes {{ nginx_worker_processes }};
error_log {{ nginx_error_log }} {{ nginx_error_log_level }};
pid /var/run/nginx.pid;
events {
worker_connections {{ nginx_worker_connections }};
}
http {
include 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 {{ nginx_access_log }} main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout {{ nginx_keepalive_timeout }};
types_hash_max_size {{ nginx_types_hash_max_size }};
include /etc/nginx/conf.d/*.conf;
}