Add jail for momlaptop.
This commit is contained in:
15
ansible/roles/jail_momlaptop/files/headers.include
Normal file
15
ansible/roles/jail_momlaptop/files/headers.include
Normal file
@@ -0,0 +1,15 @@
|
||||
# Enable HTTP Strict Transport Security (HSTS) to force clients to
|
||||
# always connect via HTTPS (do not use if only testing)
|
||||
add_header Strict-Transport-Security "max-age=31536000;" always;
|
||||
# Enable cross-site filter (XSS) and tell browser to block detected
|
||||
# attacks
|
||||
add_header X-XSS-Protection "1; mode=block" always;
|
||||
# Prevent some browsers from MIME-sniffing a response away from the
|
||||
# declared Content-Type
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
# Disallow the site to be rendered within a frame (clickjacking
|
||||
# protection)
|
||||
add_header X-Frame-Options "DENY" always;
|
||||
|
||||
# Indicate that we are serving http3 on port 443
|
||||
add_header Alt-Svc 'h3=":8033"; ma=864000';
|
||||
BIN
ansible/roles/jail_momlaptop/files/htpasswd
Normal file
BIN
ansible/roles/jail_momlaptop/files/htpasswd
Normal file
Binary file not shown.
2
ansible/roles/jail_momlaptop/files/newsyslog.conf
Normal file
2
ansible/roles/jail_momlaptop/files/newsyslog.conf
Normal file
@@ -0,0 +1,2 @@
|
||||
# logfilename [owner:group] mode count size when flags [/pid_file] [sig_num]
|
||||
/var/log/nginx/*.log 640 5 1000 @T00 GYC /var/run/nginx.pid SIGUSR1
|
||||
48
ansible/roles/jail_momlaptop/files/nginx.conf
Normal file
48
ansible/roles/jail_momlaptop/files/nginx.conf
Normal file
@@ -0,0 +1,48 @@
|
||||
worker_processes auto;
|
||||
user www www;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
types {
|
||||
text/plain log;
|
||||
}
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
gzip on;
|
||||
|
||||
include conf.d/headers.include;
|
||||
|
||||
server {
|
||||
listen 443 quic reuseport;
|
||||
listen [::]:443 quic reuseport;
|
||||
listen 443 ssl;
|
||||
listen [::]:443 ssl;
|
||||
http2 on;
|
||||
|
||||
server_name momlaptop.fizz.buzz;
|
||||
|
||||
include conf.d/tls_settings.include;
|
||||
# RSA
|
||||
ssl_certificate /momlaptop.fizz.buzz/tls.crt;
|
||||
ssl_certificate_key /momlaptop.fizz.buzz/tls.key;
|
||||
|
||||
# Nginx by default only allows file uploads up to 50M in size
|
||||
client_max_body_size 50M;
|
||||
|
||||
location / {
|
||||
auth_basic "Stuff";
|
||||
auth_basic_user_file conf.d/htpasswd;
|
||||
|
||||
alias /srv/http/;
|
||||
autoindex on;
|
||||
}
|
||||
}
|
||||
}
|
||||
1
ansible/roles/jail_momlaptop/files/nginx_rc.conf
Normal file
1
ansible/roles/jail_momlaptop/files/nginx_rc.conf
Normal file
@@ -0,0 +1 @@
|
||||
nginx_enable="YES"
|
||||
9
ansible/roles/jail_momlaptop/files/proxy.include
Normal file
9
ansible/roles/jail_momlaptop/files/proxy.include
Normal file
@@ -0,0 +1,9 @@
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
# Settings for keepalive module for upstreams
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection "";
|
||||
# Requests sent with early data are subject to replay attacks so the application needs to protect against that by using the Early-Data header.
|
||||
# proxy_set_header Early-Data $ssl_early_data;
|
||||
3
ansible/roles/jail_momlaptop/files/tls_settings.include
Normal file
3
ansible/roles/jail_momlaptop/files/tls_settings.include
Normal file
@@ -0,0 +1,3 @@
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256';
|
||||
ssl_prefer_server_ciphers on;
|
||||
2
ansible/roles/jail_momlaptop/meta/main.yaml
Normal file
2
ansible/roles/jail_momlaptop/meta/main.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
dependencies:
|
||||
- syslog
|
||||
55
ansible/roles/jail_momlaptop/tasks/common.yaml
Normal file
55
ansible/roles/jail_momlaptop/tasks/common.yaml
Normal file
@@ -0,0 +1,55 @@
|
||||
# - name: Create directories
|
||||
# file:
|
||||
# name: "{{ item }}"
|
||||
# state: directory
|
||||
# mode: 0755
|
||||
# owner: root
|
||||
# group: wheel
|
||||
# loop:
|
||||
# - /foo/bar
|
||||
|
||||
# - name: Install scripts
|
||||
# copy:
|
||||
# src: "files/{{ item.src }}"
|
||||
# dest: "{{ item.dest }}"
|
||||
# mode: 0755
|
||||
# owner: root
|
||||
# group: wheel
|
||||
# loop:
|
||||
# - src: foo.bash
|
||||
# dest: /usr/local/bin/foo
|
||||
|
||||
# - name: Install Configuration
|
||||
# copy:
|
||||
# src: "files/{{ item.src }}"
|
||||
# dest: "{{ item.dest }}"
|
||||
# mode: 0600
|
||||
# owner: root
|
||||
# group: wheel
|
||||
# loop:
|
||||
# - src: foo.conf
|
||||
# dest: /usr/local/etc/foo.conf
|
||||
|
||||
# - name: Clone Source
|
||||
# git:
|
||||
# repo: "https://foo.bar/baz.git"
|
||||
# dest: /foo/bar
|
||||
# version: "v1.0.2"
|
||||
# force: true
|
||||
# diff: false
|
||||
|
||||
- import_tasks: tasks/freebsd.yaml
|
||||
when: 'os_flavor == "freebsd"'
|
||||
|
||||
- import_tasks: tasks/linux.yaml
|
||||
when: 'os_flavor == "linux"'
|
||||
|
||||
# - include_tasks:
|
||||
# file: tasks/peruser.yaml
|
||||
# apply:
|
||||
# become: yes
|
||||
# become_user: "{{ initialize_user }}"
|
||||
# when: users is defined
|
||||
# loop: "{{ users | dict2items | community.general.json_query('[?value.initialize==`true`].key') }}"
|
||||
# loop_control:
|
||||
# loop_var: initialize_user
|
||||
81
ansible/roles/jail_momlaptop/tasks/freebsd.yaml
Normal file
81
ansible/roles/jail_momlaptop/tasks/freebsd.yaml
Normal file
@@ -0,0 +1,81 @@
|
||||
- name: Create www group
|
||||
group:
|
||||
name: www
|
||||
|
||||
- name: Create www user
|
||||
user:
|
||||
name: www
|
||||
home: /srv/http
|
||||
createhome: false
|
||||
group: www
|
||||
|
||||
- name: Create directories
|
||||
file:
|
||||
name: "{{ item }}"
|
||||
state: directory
|
||||
mode: 0755
|
||||
owner: root
|
||||
group: wheel
|
||||
loop:
|
||||
- /momlaptop.fizz.buzz
|
||||
- /etc/rc.conf.d
|
||||
- /usr/local/etc/nginx/conf.d
|
||||
|
||||
- name: Create directories
|
||||
file:
|
||||
name: "{{ item }}"
|
||||
state: directory
|
||||
mode: 0755
|
||||
owner: www
|
||||
group: www
|
||||
loop:
|
||||
- /srv/http
|
||||
|
||||
- name: Install packages
|
||||
package:
|
||||
name:
|
||||
- nginx
|
||||
state: present
|
||||
|
||||
# validate fails because nginx config relies on a local mime.types
|
||||
- name: Install Configuration
|
||||
copy:
|
||||
src: "files/{{ item.src }}"
|
||||
dest: "{{ item.dest }}"
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: wheel
|
||||
loop:
|
||||
- src: nginx.conf
|
||||
dest: /usr/local/etc/nginx/nginx.conf
|
||||
- src: headers.include
|
||||
dest: /usr/local/etc/nginx/conf.d/headers.include
|
||||
- src: proxy.include
|
||||
dest: /usr/local/etc/nginx/conf.d/proxy.include
|
||||
- src: tls_settings.include
|
||||
dest: /usr/local/etc/nginx/conf.d/tls_settings.include
|
||||
# Generate htpasswd with `htpasswd -c files/htpasswd user1`
|
||||
# or `printf "USER:$(openssl passwd)\n" >> files/htpasswd`
|
||||
- src: htpasswd
|
||||
dest: /usr/local/etc/nginx/conf.d/htpasswd
|
||||
|
||||
- name: Install newsyslog configuration
|
||||
copy:
|
||||
src: "files/{{ item.src }}"
|
||||
dest: "{{ item.dest }}"
|
||||
mode: 0600
|
||||
owner: root
|
||||
group: wheel
|
||||
loop:
|
||||
- src: newsyslog.conf
|
||||
dest: /usr/local/etc/newsyslog.conf.d/nginx.conf
|
||||
|
||||
- name: Install service configuration
|
||||
copy:
|
||||
src: "files/{{ item }}_rc.conf"
|
||||
dest: "/etc/rc.conf.d/{{ item }}"
|
||||
mode: 0644
|
||||
owner: root
|
||||
group: wheel
|
||||
loop:
|
||||
- nginx
|
||||
29
ansible/roles/jail_momlaptop/tasks/linux.yaml
Normal file
29
ansible/roles/jail_momlaptop/tasks/linux.yaml
Normal file
@@ -0,0 +1,29 @@
|
||||
# - name: Build aur packages
|
||||
# register: buildaur
|
||||
# become_user: "{{ build_user.name }}"
|
||||
# command: "aurutils-sync --no-view {{ item }}"
|
||||
# args:
|
||||
# creates: "/var/cache/pacman/custom/{{ item }}-*.pkg.tar.*"
|
||||
# loop:
|
||||
# - foo
|
||||
|
||||
# - name: Update cache
|
||||
# when: buildaur.changed
|
||||
# pacman:
|
||||
# name: []
|
||||
# state: present
|
||||
# update_cache: true
|
||||
|
||||
# - name: Install packages
|
||||
# package:
|
||||
# name:
|
||||
# - foo
|
||||
# state: present
|
||||
|
||||
# - name: Enable services
|
||||
# systemd:
|
||||
# enabled: yes
|
||||
# name: "{{ item }}"
|
||||
# daemon_reload: yes
|
||||
# loop:
|
||||
# - foo.service
|
||||
2
ansible/roles/jail_momlaptop/tasks/main.yaml
Normal file
2
ansible/roles/jail_momlaptop/tasks/main.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
- import_tasks: tasks/common.yaml
|
||||
# when: foo is defined
|
||||
29
ansible/roles/jail_momlaptop/tasks/peruser.yaml
Normal file
29
ansible/roles/jail_momlaptop/tasks/peruser.yaml
Normal file
@@ -0,0 +1,29 @@
|
||||
- include_role:
|
||||
name: per_user
|
||||
|
||||
# - name: Create directories
|
||||
# file:
|
||||
# name: "{{ account_homedir.stdout }}/{{ item }}"
|
||||
# state: directory
|
||||
# mode: 0700
|
||||
# owner: "{{ account_name.stdout }}"
|
||||
# group: "{{ group_name.stdout }}"
|
||||
# loop:
|
||||
# - ".config/foo"
|
||||
|
||||
# - name: Copy files
|
||||
# copy:
|
||||
# src: "files/{{ item.src }}"
|
||||
# dest: "{{ account_homedir.stdout }}/{{ item.dest }}"
|
||||
# mode: 0600
|
||||
# owner: "{{ account_name.stdout }}"
|
||||
# group: "{{ group_name.stdout }}"
|
||||
# loop:
|
||||
# - src: foo.conf
|
||||
# dest: .config/foo/foo.conf
|
||||
|
||||
- import_tasks: tasks/peruser_freebsd.yaml
|
||||
when: 'os_flavor == "freebsd"'
|
||||
|
||||
- import_tasks: tasks/peruser_linux.yaml
|
||||
when: 'os_flavor == "linux"'
|
||||
Reference in New Issue
Block a user