rework all

This commit is contained in:
2024-11-11 13:48:06 +03:00
parent cc7cb56aa3
commit 8ba4e824fc
14 changed files with 196 additions and 245 deletions

View File

@ -0,0 +1,25 @@
---
- name: Create site directories
file:
path: "/var/www/html/{{ site_name }}"
state: directory
mode: '0755'
tags: configure
- name: Deploy site content
template:
src: site_index.html.j2
dest: "/var/www/html/{{ site_name }}/index.html"
tags: configure
- name: Configure Nginx for {{ site_name }}
template:
src: nginx_site.conf.j2
dest: "/etc/nginx/conf.d/{{ site_name }}.conf"
tags: configure
- name: Restart Nginx
service:
name: nginx
state: restarted
tags: configure

View File

@ -0,0 +1,29 @@
---
- name: Start and enable firewalld
service:
name: firewalld
state: started
enabled: true
tags: firewall
- name: Open port 80 for HTTP
ansible.builtin.firewalld:
port: 80/tcp
permanent: true
state: enabled
immediate: yes
tags: firewall
- name: Open port 443 for HTTPS
ansible.builtin.firewalld:
port: 443/tcp
permanent: true
state: enabled
immediate: yes
tags: firewall
- name: Reload firewalld to apply changes
ansible.builtin.service:
name: firewalld
state: reloaded
tags: firewall

View File

@ -0,0 +1,24 @@
---
- name: Ensure SSL directory exists
file:
path: /etc/nginx/ssl
state: directory
mode: '0755'
tags: ssl
- name: Generate self-signed SSL certificate
openssl_certificate:
path: /etc/nginx/ssl/{{ proxy_name }}.crt
privatekey_path: /etc/nginx/ssl/{{ proxy_name }}.key
common_name: "{{ proxy_name }}"
state: present
selfsigned: yes
owner: root
group: root
mode: '0644'
subject:
- organizationName: "Example Company"
- organizationalUnitName: "IT"
- localityName: "City"
- countryName: "US"
tags: ssl

View File

@ -0,0 +1,8 @@
---
- name: Install Nginx
zypper:
name: nginx
state: present
force: yes
update_cache: yes
tags: install

View File

@ -0,0 +1,12 @@
---
- import_tasks: install.yml
tags: install
- import_tasks: configure.yml
tags: configure
- import_tasks: proxy.yml
tags: proxy
- import_tasks: firewall.yml
tags: firewall

View File

@ -0,0 +1,26 @@
---
- name: Configure Nginx load balancer with SSL
template:
src: nginx_proxy_ssl.conf.j2
dest: "/etc/nginx/conf.d/proxy.conf"
tags: proxy
- name: Ensure SSL directory exists
file:
path: /etc/nginx/ssl
state: directory
mode: '0755'
tags: proxy
- name: Copy Diffie-Hellman parameters
copy:
src: dhparam.pem
dest: /etc/nginx/ssl/dhparam.pem
mode: '0600'
tags: proxy
- name: Restart Nginx after configuration
service:
name: nginx
state: restarted
tags: proxy