diff --git a/ReadMe.md b/ReadMe.md new file mode 100644 index 0000000000000000000000000000000000000000..1972b9b8147ce2b2fdf8ba3228f4c71e6ab5174b --- /dev/null +++ b/ReadMe.md @@ -0,0 +1,6 @@ +hosts file : Contains all your maschines. Be very carefull, a wrong defined maschine can lead to major proplems. +files directory: contains templates for your playbooks. +api : for api.freifunk.lu. +firmware : for firmware.freifunk.lu. +initial : for initial server setup. +gatewaay : for fflux gateway setup. diff --git a/api/ReadMe.md b/api/ReadMe.md new file mode 100644 index 0000000000000000000000000000000000000000..b702e28158df5280521b6b800a2679ff7fe38de6 --- /dev/null +++ b/api/ReadMe.md @@ -0,0 +1,2 @@ +This will install a default api nginx config. +Before executing please check your hosts file and use hosts variable. diff --git a/api/api.freifunk.lu.yml b/api/api.freifunk.lu.yml new file mode 100644 index 0000000000000000000000000000000000000000..4358be3a8310a5c6f1d320412e26dc313fdf9c43 --- /dev/null +++ b/api/api.freifunk.lu.yml @@ -0,0 +1,38 @@ +--- +- hosts: test + become: yes + vars: + server_name: 'api.freifunk.lu ' + document_root: /var/www/api.freifunk.lu + tasks: + - name: Update apt cache and install Nginx + apt: + name: nginx + state: latest + update_cache: yes + +# Create directory api.freifunk.lu + - name: Create the directory api.freifunk.lu in /var/www if it does not exist + ansible.builtin.file: + path: /var/www/api.freifunk.lu + state: directory + mode: '0755' + + - name: Apply Nginx template + template: + src: /etc/ansible/playbooks/files/api.conf.j2 + dest: /etc/nginx/sites-available/api.freifunk.lu + notify: Restart Nginx + + - name: Enable new site + file: + src: /etc/nginx/sites-available/api.freifunk.lu + dest: /etc/nginx/sites-enabled/api.freifunk.lu + state: link + notify: Restart Nginx + + handlers: + - name: Restart Nginx + service: + name: nginx + state: restarted diff --git a/files/api.conf.j2 b/files/api.conf.j2 new file mode 100644 index 0000000000000000000000000000000000000000..b710ac58e022d1048b1a09ce1bbad613d3d42122 --- /dev/null +++ b/files/api.conf.j2 @@ -0,0 +1,16 @@ +server { + listen [::]:80; + listen 80; + server_name {{ server_name }}; + + access_log /var/log/nginx/firmware.freifunk.lu-access.log; + error_log /var/log/nginx/firmware.freifunk.lu-error.log; + + root {{ document_root }}; + + index index.html luxembourg-api.json; + + location / { + try_files $uri $uri/ /luxembourg-api.json; + } +} diff --git a/files/firmware.conf.j2 b/files/firmware.conf.j2 new file mode 100644 index 0000000000000000000000000000000000000000..ae4edaec2956319286a21930995be1a9919d67d2 --- /dev/null +++ b/files/firmware.conf.j2 @@ -0,0 +1,29 @@ +server { + listen [::]:80; + listen 80; + server_name {{ server_name }}; + + access_log /var/log/nginx/firmware.freifunk.lu-access.log; + error_log /var/log/nginx/firmware.freifunk.lu-error.log; + + root {{ document_root }}; + + index index.html; + + location = /favicon.ico { + log_not_found off; + access_log off; + + } + + location = /robots.txt { + allow all; + log_not_found off; + access_log off; + } + + location / { + autoindex on; + try_files $uri $uri/ index.html =404; + } +} diff --git a/files/nginx.conf.j2 b/files/nginx.conf.j2 new file mode 100644 index 0000000000000000000000000000000000000000..ae4edaec2956319286a21930995be1a9919d67d2 --- /dev/null +++ b/files/nginx.conf.j2 @@ -0,0 +1,29 @@ +server { + listen [::]:80; + listen 80; + server_name {{ server_name }}; + + access_log /var/log/nginx/firmware.freifunk.lu-access.log; + error_log /var/log/nginx/firmware.freifunk.lu-error.log; + + root {{ document_root }}; + + index index.html; + + location = /favicon.ico { + log_not_found off; + access_log off; + + } + + location = /robots.txt { + allow all; + log_not_found off; + access_log off; + } + + location / { + autoindex on; + try_files $uri $uri/ index.html =404; + } +} diff --git a/firmware/ReadMe.md b/firmware/ReadMe.md new file mode 100644 index 0000000000000000000000000000000000000000..c23e38eb15f13ceeeb9cfb566674595985d513a0 --- /dev/null +++ b/firmware/ReadMe.md @@ -0,0 +1,2 @@ +This will install a default firmware nginx config. +Before executing please check your hosts file and use hosts variable. diff --git a/firmware/firmware.freifunk.lu.yml b/firmware/firmware.freifunk.lu.yml new file mode 100644 index 0000000000000000000000000000000000000000..f02f6789df9180283b534ebe0457c00a27990339 --- /dev/null +++ b/firmware/firmware.freifunk.lu.yml @@ -0,0 +1,39 @@ +--- +- hosts: test + become: yes + vars: + server_name: 'firmware.freifunk.lu ' + document_root: /var/www/firmware.freifunk.lu + tasks: + - name: Update apt cache and install Nginx + apt: + name: nginx + state: latest + update_cache: yes + +# Create directory firmware.freifunk.lu + - name: Create the directory firmware.freifunk.lu in /var/www if it does not exist + ansible.builtin.file: + path: /var/www/firmware.freifunk.lu + state: directory + mode: '0755' + + + - name: Apply Nginx template + template: + src: /etc/ansible/playbooks/files/firmware.conf.j2 + dest: /etc/nginx/sites-available/firmware.freifunk.lu + notify: Restart Nginx + + - name: Enable new site + file: + src: /etc/nginx/sites-available/firmware.freifunk.lu + dest: /etc/nginx/sites-enabled/firmware.freifunk.lu + state: link + notify: Restart Nginx + + handlers: + - name: Restart Nginx + service: + name: nginx + state: restarted diff --git a/hosts b/hosts new file mode 100644 index 0000000000000000000000000000000000000000..be9343bab43ad981e0d05dc636ff199abcedb555 --- /dev/null +++ b/hosts @@ -0,0 +1,57 @@ +# This is the default ansible 'hosts' file. +# +# It should live in /etc/ansible/hosts +# +# - Comments begin with the '#' character +# - Blank lines are ignored +# - Groups of hosts are delimited by [header] elements +# - You can enter hostnames or ip addresses +# - A hostname/ip can be a member of multiple groups + +# server list is here +fflux-test ansible_host=89.58.3.252 new_hostname=fflux-test + +# machines which are used for tests +[test] +fflux-test + +# variable for the test group come here +[test:vars] +#mac1=ca:fe:ca:fe:00:19 +#ipv4=10.24.128.19 +#ipv6=fd4e:f2d7:88d2:fffe::19 +#vars_files: /etc/ansible/host_vars/firmware.freifunk.lu + +# all machine variables come here +[all:vars] +ansible_python_interpreter=/usr/bin/python3 +ansible_ssh_private_key_file=/home/fflux/.ssh/fflux_fflux + +# new machine come here +[initial] +#fflux-test + +# machines which run api.freifunk.lu +[API] + +# machines which run map.freifunk.lu +[MAP] + +# machines which run stats.freifunk.lu +[STATS] + +# machines which run firmware.freifunk.lu +[FIRMWARE] + +# machines which run freifunk.lu +[WORDPRESS] + +# machine which are gateways for freifunk.lu +[fflux] + +[gw1] + +[gw2] + +[gw3] +