Add role service-nginx
This commit is contained in:
parent
8212e17d6a
commit
545162a46f
6 changed files with 159 additions and 0 deletions
|
@ -88,3 +88,8 @@
|
|||
|
||||
- name: ip6tables-restore
|
||||
shell: ip6tables-restore < /etc/iptables/rules.v6
|
||||
|
||||
- name: reload nginx
|
||||
systemd:
|
||||
name: nginx
|
||||
state: reloaded
|
||||
|
|
12
roles/service-nginx/README.md
Normal file
12
roles/service-nginx/README.md
Normal file
|
@ -0,0 +1,12 @@
|
|||
# Ansible role service-nginx
|
||||
|
||||
Diese Ansible role installiert und konfiguriert den Web Server nginx.
|
||||
|
||||
- installiert das offizielle Debian Repository von nginx.org
|
||||
- installiert nginx
|
||||
- schreibt default.conf
|
||||
- installiert die Standard MWU Gateway Webseite
|
||||
|
||||
## Benötigte Variablen
|
||||
|
||||
- Variable `inventory_hostname_short`
|
53
roles/service-nginx/files/style.css
Normal file
53
roles/service-nginx/files/style.css
Normal file
|
@ -0,0 +1,53 @@
|
|||
body
|
||||
{
|
||||
background: #ffffff;
|
||||
color: #000000;
|
||||
font-family: "Source Code Pro", "Consolas", "Courier New", "Monaco", monospace;
|
||||
font-size: 12px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
footer
|
||||
{
|
||||
margin: 2em 0;
|
||||
}
|
||||
|
||||
a
|
||||
{
|
||||
color: #ff4b57;
|
||||
}
|
||||
|
||||
.block
|
||||
{
|
||||
margin: 1em;
|
||||
padding: .5em;
|
||||
border-radius: .5em;
|
||||
border: #f9f9f9 1px solid;
|
||||
}
|
||||
|
||||
.cblock
|
||||
{
|
||||
background: #000000;
|
||||
color: #ffffff;
|
||||
margin: 1em;
|
||||
padding: .5em;
|
||||
border-radius: .5em;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.ifblock
|
||||
{
|
||||
display: inline-block;
|
||||
vertical-align: top;
|
||||
text-align: center;
|
||||
margin: .1em;
|
||||
padding: .5em;
|
||||
min-width: 10em;
|
||||
border: #f9f9f9 1px solid;
|
||||
border-radius: .5em;
|
||||
}
|
||||
|
||||
.ifimg
|
||||
{
|
||||
display: block;
|
||||
}
|
52
roles/service-nginx/tasks/main.yml
Normal file
52
roles/service-nginx/tasks/main.yml
Normal file
|
@ -0,0 +1,52 @@
|
|||
---
|
||||
- name: add official nginx apt key
|
||||
apt_key:
|
||||
state: present
|
||||
id: 7BD9BF62
|
||||
url: "https://nginx.org/keys/nginx_signing.key"
|
||||
|
||||
- name: add official nginx apt repository
|
||||
apt_repository:
|
||||
state: present
|
||||
repo: "{{ item }}"
|
||||
update_cache: yes
|
||||
filename: nginx
|
||||
with_items:
|
||||
- deb http://nginx.org/packages/debian/ stretch nginx
|
||||
- deb-src http://nginx.org/packages/debian/ stretch nginx
|
||||
|
||||
- name: install nginx packages
|
||||
package:
|
||||
name: nginx
|
||||
state: present
|
||||
|
||||
- name: write nginx configuration default.conf
|
||||
template:
|
||||
src: default.conf.j2
|
||||
dest: /etc/nginx/conf.d/default.conf
|
||||
mode: 0644
|
||||
notify: reload nginx
|
||||
|
||||
- name: manage html directory for static files
|
||||
file:
|
||||
path: /var/www/html/static
|
||||
state: directory
|
||||
mode: 0755
|
||||
|
||||
- name: copy css stylesheet
|
||||
copy:
|
||||
src: style.css
|
||||
dest: /var/www/html/static/style.css
|
||||
mode: 0644
|
||||
|
||||
- name: write index.html
|
||||
template:
|
||||
src: index.html.j2
|
||||
dest: /var/www/html/index.html
|
||||
mode: 0644
|
||||
|
||||
- name: configure systemd unit nginx
|
||||
systemd:
|
||||
name: nginx
|
||||
state: started
|
||||
enabled: yes
|
12
roles/service-nginx/templates/default.conf.j2
Normal file
12
roles/service-nginx/templates/default.conf.j2
Normal file
|
@ -0,0 +1,12 @@
|
|||
server {
|
||||
listen 80 default_server;
|
||||
server_name _;
|
||||
|
||||
charset utf-8;
|
||||
server_tokens off;
|
||||
|
||||
root /var/www/html;
|
||||
location / {
|
||||
index index.html;
|
||||
}
|
||||
}
|
25
roles/service-nginx/templates/index.html.j2
Normal file
25
roles/service-nginx/templates/index.html.j2
Normal file
|
@ -0,0 +1,25 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Freifunk MWU Gateway "{{ inventory_hostname_short }}" </title>
|
||||
<link href="./static/favicon.ico" rel="shortcut icon" />
|
||||
<link href="./static/style.css" rel="stylesheet" type="text/css" media="screen" />
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
function toggle(id)
|
||||
{
|
||||
var e = document.getElementById(id);
|
||||
e.style.display = (e.style.display == 'none') ? 'block' : 'none';
|
||||
}
|
||||
-->
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>Freifunk MWU Gateway <a href="./index.html">{{ inventory_hostname_short }}</a></h1>
|
||||
</header>
|
||||
<div class="block"><a href="firmware">Firmware</a></div>
|
||||
<div class="block"><a href="traffic">Traffic</a></div>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in a new issue