fix directory
This commit is contained in:
67
ansible/roles/nginx_site/tasks/main.yml
Normal file
67
ansible/roles/nginx_site/tasks/main.yml
Normal file
@ -0,0 +1,67 @@
|
||||
- name: Install Nginx
|
||||
zypper:
|
||||
name: nginx
|
||||
state: present
|
||||
|
||||
- name: Ensure Nginx is enabled and started
|
||||
systemd:
|
||||
name: nginx
|
||||
enabled: yes
|
||||
state: started
|
||||
|
||||
- name: Create web root for SiteA
|
||||
file:
|
||||
path: /var/www/siteA
|
||||
state: directory
|
||||
owner: nginx
|
||||
group: nginx
|
||||
mode: '0755'
|
||||
when: inventory_hostname in groups['SiteA']
|
||||
|
||||
- name: Create web root for SiteB
|
||||
file:
|
||||
path: /var/www/siteB
|
||||
state: directory
|
||||
owner: nginx
|
||||
group: nginx
|
||||
mode: '0755'
|
||||
when: inventory_hostname in groups['SiteB']
|
||||
|
||||
- name: Deploy SiteA Configuration
|
||||
template:
|
||||
src: siteA.conf.j2
|
||||
dest: /etc/nginx/conf.d/siteA.conf
|
||||
when: inventory_hostname in groups['SiteA']
|
||||
|
||||
- name: Deploy SiteB Configuration
|
||||
template:
|
||||
src: siteB.conf.j2
|
||||
dest: /etc/nginx/conf.d/siteB.conf
|
||||
when: inventory_hostname in groups['SiteB']
|
||||
|
||||
- name: Deploy SiteA HTML
|
||||
template:
|
||||
src: index.html.j2
|
||||
dest: /var/www/siteA/index.html
|
||||
vars:
|
||||
site_title: "{{ siteA.site_title }}"
|
||||
site_h1: "{{ siteA.site_h1 }}"
|
||||
site_h2: "{{ siteA.site_h2 }}"
|
||||
site_p: "{{ siteA.site_p }}"
|
||||
when: inventory_hostname in groups['SiteA']
|
||||
|
||||
- name: Deploy SiteB HTML
|
||||
template:
|
||||
src: index.html.j2
|
||||
dest: /var/www/siteB/index.html
|
||||
vars:
|
||||
site_title: "{{ siteB.site_title }}"
|
||||
site_h1: "{{ siteB.site_h1 }}"
|
||||
site_h2: "{{ siteB.site_h2 }}"
|
||||
site_p: "{{ siteB.site_p }}"
|
||||
when: inventory_hostname in groups['SiteB']
|
||||
|
||||
- name: Reload Nginx
|
||||
systemd:
|
||||
name: nginx
|
||||
state: reloaded
|
24
ansible/roles/nginx_site/templates/index.html.j2
Normal file
24
ansible/roles/nginx_site/templates/index.html.j2
Normal file
@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{{ site_title }}</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
background-color: #f4f4f4;
|
||||
color: #333;
|
||||
text-align: center;
|
||||
padding-top: 50px;
|
||||
}
|
||||
h1 { color: #ff5722; }
|
||||
h2 { color: #ff9800; }
|
||||
p { font-size: 18px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>{{ site_h1 }}</h1>
|
||||
<h2>{{ site_h2 }}</h2>
|
||||
<p>{{ site_p }}</p>
|
||||
</body>
|
||||
</html>
|
16
ansible/roles/nginx_site/templates/siteA.conf.j2
Normal file
16
ansible/roles/nginx_site/templates/siteA.conf.j2
Normal file
@ -0,0 +1,16 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name {{ siteA.site_domain }};
|
||||
|
||||
root /var/www/siteA;
|
||||
index index.html;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
|
||||
location /health {
|
||||
return 200 'SiteA is up';
|
||||
add_header Content-Type text/plain;
|
||||
}
|
||||
}
|
16
ansible/roles/nginx_site/templates/siteB.conf.j2
Normal file
16
ansible/roles/nginx_site/templates/siteB.conf.j2
Normal file
@ -0,0 +1,16 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name {{ siteB.site_domain }};
|
||||
|
||||
root /var/www/siteB;
|
||||
index index.html;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
|
||||
location /health {
|
||||
return 200 'SiteB is up';
|
||||
add_header Content-Type text/plain;
|
||||
}
|
||||
}
|
1
ansible/roles/nginx_site/vars/main.yml
Normal file
1
ansible/roles/nginx_site/vars/main.yml
Normal file
@ -0,0 +1 @@
|
||||
additional_content: "{{ additional_content | default('') }}"
|
Reference in New Issue
Block a user