playbook for index

This commit is contained in:
Daniel Liu 2021-09-16 20:54:11 -04:00
parent 36f63187f1
commit 283c3fc6b8
24 changed files with 67 additions and 603 deletions

View File

@ -46,7 +46,7 @@ qemu_run() {
}
clean() {
rm -rf userdata
rm -rf qemu/vm libvirt/vm
}
case $1 in

View File

@ -1,56 +1,57 @@
---
# quite a lot of duplication, probably fix later
# Gather info
- name: Check if vm was created already
stat:
path: "{{userdata}}"
register: vmexists
ignore_errors: true
- name: Check for ubuntu iso
stat:
path: "{{role_path}}/files/ubuntu20_04.iso"
register: isoexists
ignore_errors: true
- name: Check for ubuntu iso seed
stat:
path: "{{userdata}}/seed.iso"
register: seedexists
ignore_errors: true
- hosts: localhost
tasks:
- name: Check if vm was created already
stat:
path: "{{userdata}}"
register: vmexists
ignore_errors: true
- name: Check for ubuntu iso
stat:
path: "{{role_path}}/files/ubuntu20_04.iso"
register: isoexists
ignore_errors: true
- name: Check for ubuntu iso seed
stat:
path: "{{userdata}}/seed.iso"
register: seedexists
ignore_errors: true
# Setting up VM
- name: Create directory for VM
file:
state: directory
path: "{{userdata}}"
when: vmexists.stat.exists == false
# Setting up VM
- name: Create directory for VM
file:
state: directory
path: "{{userdata}}"
when: vmexists.stat.exists == false
# didn't use get_url module since it broke with symlinks
- name: Fetching ubuntu iso
command: curl -o "{{role_path}}/files/ubuntu20_04.iso" https://releases.ubuntu.com/20.04.3/ubuntu-20.04.3-live-server-amd64.iso
when: isoexists.stat.exists == false
# didn't use get_url module since it broke with symlinks
- name: Fetching ubuntu iso
command: curl -o "{{role_path}}/files/ubuntu20_04.iso" https://releases.ubuntu.com/20.04.3/ubuntu-20.04.3-live-server-amd64.iso
when: isoexists.stat.exists == false
- name: Create disk images
shell:
cmd: "for i in {1..6}; do qemu-img create -f qcow2 {{userdata}}/drive${i} {{vm_disk_size}}; done"
when: vmexists.stat.exists == false
- name: Create disk images
shell:
cmd: "for i in {1..6}; do qemu-img create -f qcow2 {{userdata}}/drive${i} {{vm_disk_size}}; done"
when: vmexists.stat.exists == false
- name: Creating cloud-init iso
command: "genisoimage -output {{userdata}}/seed.iso -volid cidata -joliet -rock {{role_path}}/files/user-data {{role_path}}/files/meta-data"
when: seedexists.stat.exists == false
- name: Creating cloud-init iso
command: "genisoimage -output {{userdata}}/seed.iso -volid cidata -joliet -rock {{role_path}}/files/user-data {{role_path}}/files/meta-data"
when: seedexists.stat.exists == false
- name: Starting autoinstallation
shell:
cmd: "qemu-system-x86_64 -cdrom {{role_path}}/files/ubuntu20_04.iso \
-enable-kvm -boot order=d \
-drive file={{userdata}}/drive1,if=virtio,id=a,media=disk,format=qcow2 \
-drive file={{userdata}}/drive2,if=virtio,id=b,media=disk,format=qcow2 \
-drive file={{userdata}}/drive3,if=virtio,id=c,media=disk,format=qcow2 \
-drive file={{userdata}}/drive4,if=virtio,id=d,media=disk,format=qcow2 \
-drive file={{userdata}}/drive5,if=virtio,id=e,media=disk,format=qcow2 \
-drive file={{userdata}}/drive6,if=virtio,id=f,media=disk,format=qcow2 \
-drive file={{userdata}}/seed.iso,if=virtio,format=raw \
-bios {{ovmf}} \
-m {{vm_ram}}"
- name: Starting autoinstallation
shell:
cmd: "qemu-system-x86_64 -cdrom {{role_path}}/files/ubuntu20_04.iso \
-enable-kvm -boot order=d \
-drive file={{userdata}}/drive1,if=virtio,id=a,media=disk,format=qcow2 \
-drive file={{userdata}}/drive2,if=virtio,id=b,media=disk,format=qcow2 \
-drive file={{userdata}}/drive3,if=virtio,id=c,media=disk,format=qcow2 \
-drive file={{userdata}}/drive4,if=virtio,id=d,media=disk,format=qcow2 \
-drive file={{userdata}}/drive5,if=virtio,id=e,media=disk,format=qcow2 \
-drive file={{userdata}}/drive6,if=virtio,id=f,media=disk,format=qcow2 \
-drive file={{userdata}}/seed.iso,if=virtio,format=raw \
-bios {{ovmf}} \
-m {{vm_ram}}"
# todo: find a way to not ask for confirmation to start autoinstall
# bug: autoinstall will not shutdown properly so the ansible task will never finish
# todo: find a way to not ask for confirmation to start autoinstall
# bug: autoinstall will not shutdown properly so the ansible task will never finish

View File

@ -0,0 +1,17 @@
---
- name: Copy over crond job
copy:
src: "{{role_path}}/templates/csc-mirror"
dest: /etc/cron.d/csc-mirror
# does the mirror user exists / home dir exist
- name: Copy index files
copy:
src: "{{role_path}}/templates/mirror-index"
dest: /home/mirror/mirror-index
- name: Copy assets
copy:
src: "{{role_path}}/templates/include"
dest: /mirror/root/include

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -1 +0,0 @@
- name: create

View File

@ -1,22 +0,0 @@
Will not copy ssl certs (dev env will not support ssl?)
```
mime.types ->
/etc/nginx/mime.types
```
```
nginx.conf ->
/etc/nginx/nginx.conf
```
```
includes/ ->
/etc/nginx/includes/
```
```
sites-available/ ->
/etc/nginx/sites-available/
```
To enable the sites
```
ln -s /etc/nginx/sites-available/debian.conf /etc/nginx/sites-enabled/
ln -s /etc/nginx/sites-available/mirror.conf /etc/nginx/sites-enabled/
```

View File

@ -1,17 +0,0 @@
server_name ca.ceph.com;
access_log /var/log/nginx/access.ceph.log;
root /mirror/root/ceph;
index index.html;
location ^~ /.well-known/acme-challenge {
alias /var/www/dehydrated;
}
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
autoindex on;
autoindex_exact_size off;
}

View File

@ -1,12 +0,0 @@
server_name debian.csclub.uwaterloo.ca debian.csclub debian;
root /srv/debian/www;
index index.html;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
autoindex on;
autoindex_exact_size off;
}

View File

@ -1,56 +0,0 @@
server_name _;
root /mirror/root;
index index.html;
autoindex on;
autoindex_exact_size off;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
# Server status
location /server-status {
stub_status on;
allow 127.0.0.1;
allow ::1;
allow 129.97.134.0/24;
allow 129.97.31.128/26;
allow 2620:101:f000:4901::/64;
allow 2620:101:f000:4902::/64;
deny all;
}
# Statistics
location ~ /stats/(?<ndpath>.*) {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://[::1]:19999/$ndpath$is_args$args;
proxy_http_version 1.1;
proxy_pass_request_headers on;
proxy_set_header Connection "keep-alive";
proxy_store off;
}
location = /stats {
return 301 /stats/;
}
# On behalf of WiCS, redirect all files
# from sarah_sharp to sage_sharp
location ~ /wics/sarah_sharp_(?<file>.*) {
return 301 /wics/sage_sharp_$file;
}
# Ceph has a special access log
location /ceph {
access_log /var/log/nginx/access.ceph.log;
}
# Removed projects
location ^~ /kali {return 410;}
location ^~ /kali-images {return 410;}
location ^~ /hyperbola {return 410;}

View File

@ -1,11 +0,0 @@
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_dhparam /etc/ssl/private/dhparam.pem;
ssl_session_tickets off;
ssl_stapling on;
ssl_stapling_verify on;
resolver 129.97.134.4 129.97.18.20 [2620:101:f000:4901:c5c::4] [2620:101:f000:7300:c5c::20] valid=300s;
resolver_timeout 5s;
ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt;

View File

@ -1,13 +0,0 @@
server_name ca.releases.ubuntu.com;
root /mirror/root/ubuntu-releases;
index index.html;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
autoindex on;
autoindex_exact_size off;
}

View File

@ -1,89 +0,0 @@
types {
text/html html htm shtml;
text/css css;
text/xml xml;
image/gif gif;
image/jpeg jpeg jpg;
application/javascript js;
application/atom+xml atom;
application/rss+xml rss;
text/mathml mml;
text/plain txt;
text/vnd.sun.j2me.app-descriptor jad;
text/vnd.wap.wml wml;
text/x-component htc;
image/png png;
image/tiff tif tiff;
image/vnd.wap.wbmp wbmp;
image/x-icon ico;
image/x-jng jng;
image/x-ms-bmp bmp;
image/svg+xml svg svgz;
image/webp webp;
application/font-woff woff;
application/java-archive jar war ear;
application/json json;
application/mac-binhex40 hqx;
application/msword doc;
application/pdf pdf;
application/postscript ps eps ai;
application/rtf rtf;
application/vnd.apple.mpegurl m3u8;
application/vnd.ms-excel xls;
application/vnd.ms-fontobject eot;
application/vnd.ms-powerpoint ppt;
application/vnd.wap.wmlc wmlc;
application/vnd.google-earth.kml+xml kml;
application/vnd.google-earth.kmz kmz;
application/x-7z-compressed 7z;
application/x-cocoa cco;
application/x-java-archive-diff jardiff;
application/x-java-jnlp-file jnlp;
application/x-makeself run;
application/x-perl pl pm;
application/x-pilot prc pdb;
application/x-rar-compressed rar;
application/x-redhat-package-manager rpm;
application/x-sea sea;
application/x-shockwave-flash swf;
application/x-stuffit sit;
application/x-tcl tcl tk;
application/x-x509-ca-cert der pem crt;
application/x-xpinstall xpi;
application/xhtml+xml xhtml;
application/xspf+xml xspf;
application/zip zip;
application/octet-stream bin exe dll;
application/octet-stream deb;
application/octet-stream dmg;
application/octet-stream iso img;
application/octet-stream msi msp msm;
application/vnd.openxmlformats-officedocument.wordprocessingml.document docx;
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx;
application/vnd.openxmlformats-officedocument.presentationml.presentation pptx;
audio/midi mid midi kar;
audio/mpeg mp3;
audio/ogg ogg;
audio/x-m4a m4a;
audio/x-realaudio ra;
video/3gpp 3gpp 3gp;
video/mp2t ts;
video/mp4 mp4;
video/mpeg mpeg mpg;
video/quicktime mov;
video/webm webm;
video/x-flv flv;
video/x-m4v m4v;
video/x-mng mng;
video/x-ms-asf asx asf;
video/x-ms-wmv wmv;
video/x-msvideo avi;
}

View File

@ -1,101 +0,0 @@
user www-data;
worker_processes 17;
pid /run/nginx.pid;
events {
worker_connections 1024;
multi_accept on;
use epoll;
}
http {
##
# Basic Settings
##
sendfile on;
sendfile_max_chunk 1m;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type text/plain;
##
# SSL Settings
##
ssl_protocols TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Open File Cache
#
open_file_cache max=2000 inactive=20s;
open_file_cache_valid 60s;
open_file_cache_min_uses 5;
open_file_cache_errors off;
##
# File
##
output_buffers 1 1m;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}

View File

@ -1,17 +0,0 @@
server {
listen 80;
listen [::]:80;
include includes/csc-debian.conf;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate /etc/ssl/private/csclub-wildcard-chain.crt;
ssl_certificate_key /etc/ssl/private/csclub-wildcard.key;
include includes/ssl.conf;
include includes/csc-debian.conf;
}

View File

@ -1,80 +0,0 @@
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##
# Default server configuration
#
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
# fastcgi_pass unix:/var/run/php5-fpm.sock;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
# listen 80;
# listen [::]:80;
#
# server_name example.com;
#
# root /var/www/example.com;
# index index.html;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}

View File

@ -1,91 +0,0 @@
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# https://www.nginx.com/resources/wiki/start/
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
# https://wiki.debian.org/Nginx/DirectoryStructure
#
# In most cases, administrators will remove this file from sites-enabled/ and
# leave it as reference inside of sites-available where it will continue to be
# updated by the nginx packaging team.
#
# This file will automatically load configuration files provided by other
# applications, such as Drupal or Wordpress. These applications will be made
# available underneath a path with that package name, such as /drupal8.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##
# Default server configuration
#
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
# pass PHP scripts to FastCGI server
#
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
# fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
# listen 80;
# listen [::]:80;
#
# server_name example.com;
#
# root /var/www/example.com;
# index index.html;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}

View File

@ -1,44 +0,0 @@
server {
listen 80 default_server reuseport;
listen [::]:80 default_server reuseport;
include includes/mirror.conf;
}
server {
listen 443 ssl default_server reuseport;
listen [::]:443 ssl default_server reuseport;
ssl_certificate /etc/ssl/private/csclub-wildcard-chain.crt;
ssl_certificate_key /etc/ssl/private/csclub-wildcard.key;
include includes/ssl.conf;
include includes/mirror.conf;
}
# ca.releases.ubuntu.com
server {
listen 80;
listen [::]:80;
include includes/ubuntu.conf;
}
# ca.ceph.com
server {
listen 80;
listen [::]:80;
include includes/ceph.conf;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate /etc/dehydrated/certs/ca.ceph.com/fullchain.pem;
ssl_certificate_key /etc/dehydrated/certs/ca.ceph.com/privkey.pem;
include includes/ssl.conf;
include includes/ceph.conf;
}