This commit is contained in:
2024-11-11 23:16:26 +03:00
parent ac4bad6936
commit c273781043
13 changed files with 49 additions and 68 deletions

View File

@ -1,4 +1,3 @@
---
- name: Start and enable firewalld
service:
name: firewalld
@ -26,4 +25,4 @@
ansible.builtin.service:
name: firewalld
state: reloaded
tags: firewall
tags: firewall

View File

@ -0,0 +1,11 @@
- name: Configure Nginx as HTTPS proxy
template:
src: proxy.conf.j2
dest: /etc/nginx/conf.d/proxy.conf
tags: proxy
- name: Restart Nginx
service:
name: nginx
state: restarted
tags: proxy

View File

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

View File

@ -1,24 +1,26 @@
---
- name: Ensure SSL directory exists
file:
path: /etc/nginx/ssl
state: directory
mode: '0755'
mode: '0700'
tags: ssl
- name: Generate private key
openssl_privatekey:
path: /etc/nginx/ssl/{{ proxy_name }}.key
size: 2048
type: RSA
mode: '0600'
owner: root
group: root
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
mode: '0600'
provider: selfsigned
tags: ssl

View File

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

View File

@ -1,12 +1,14 @@
---
- import_tasks: install.yml
tags: install
- import_tasks: configure.yml
tags: configure
- import_tasks: configure_site.yml
tags: configure_site
- import_tasks: proxy.yml
tags: proxy
- import_tasks: firewall.yml
- import_tasks: configure_firewall.yml
tags: firewall
- import_tasks: generate_ssl.yml
tags: ssl
- import_tasks: configure_proxy.yml
tags: proxy

View File

@ -1,26 +0,0 @@
---
- 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