Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some chores #59

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use_flake
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When including a flake.nix in this repo, it would be probably better to just use use flake (cf. https://github.com/direnv/direnv/blob/master/man/direnv-stdlib.1.md#use-flake-installable)

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
*.retry
.vault_pass

.direnv
result
43 changes: 43 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
inputs = {
nixpkgs.url="github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }@inputs:
flake-utils.lib.eachDefaultSystem (system:
let pkgs = import nixpkgs { inherit system; };
in {
devShells.default = pkgs.mkShell {
packages = with pkgs; [
ansible
ansible-lint
];
PASSWORD_STORE_DIR="~/.password-store/chaos/jetzt";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure whether to include a flake.nix in this repo. Especially L15 makes hard assumptions about the system of the persons using it. On my system e.g. the password store is not located in ~/.password-store.

};
});
}
13 changes: 7 additions & 6 deletions group_vars/all/mumble.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
---
mumble_domain: "mumble.{{ base_url }}"
murmur_icesecretread: "secret"
murmur_welcometext: "Welcome on the {{ base_url }}-mumble server running murmur. Enjoy your stay!"
murmur_bandwidth: "128000"
murmur_sslcert: "/etc/ssl/certs/mumble.{{ base_url }}.crt"
murmur_sslkey: "/etc/ssl/private/mumble.{{ base_url }}.key"
murmur_registername: no
murmur_sslcert: "/etc/ssl/certs/{{ mumble_domain }}.crt"
murmur_sslkey: "/etc/ssl/private/{{ mumble_domain }}.key"
murmur_registername: false
murmur_registry_password: "{{ lookup('passwordstore', 'infra/murmur/registry create=true') }}"

mumble_web: yes
mumble_web: true
mumble_web_path: "/usr/lib/node_modules/mumble-web"
mumble_web_config: ""
mumble_web_supplementary_groups: "ssl-cert"
mumble_web_listen: "127.0.0.1:84"
mumble_web_ssl_activated: False
mumble_web_ssl_target: True
mumble_web_ssl_activated: false
mumble_web_ssl_target: true
48 changes: 48 additions & 0 deletions playbooks/site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,30 @@
regexp: "^#SystemMaxUse="
replace: "SystemMaxUse=50M"
notify: restart systemd-journald
- name: Register if alacritty terminfo is present
command: infocmp alacritty
ignore_errors: true
register: alacritty_present
check_mode: false
- name: Install alacritty terminfo
block:
- name: Download terminfo file
get_url:
url: "https://raw.githubusercontent.com/alacritty/alacritty/master/extra/alacritty.info"
dest: "/tmp/alacritty.info"
mode: 06440
- name: Install terminfo file for alacritty
command:
argv:
- tic
- "-xe"
- alacritty,alacritty-direct
- /tmp/alacritty.info
- name: Delete temporary alacritty.info
file:
path: "/tmp/alacritty.info"
state: absent
when: alacritty_present.rc == 1
tags: base

- hosts: web,matrix
Expand Down Expand Up @@ -227,6 +251,15 @@
tags: pretix

- hosts: web
handlers:
- name: daemon reload
systemd:
daemon_reload: true
- name: restart certificate reload timer
systemd:
name: mumble-certificate-reloader.timer
state: restarted
enabled: true
pre_tasks:
- name: add mumble repository
apt_repository:
Expand Down Expand Up @@ -269,6 +302,21 @@
name: "mumble-server"
groups: "ssl-cert"
append: yes

- name: Copy mumble-server-certificate-reloader.sh
template:
src: mumble/mumble-server-certificate-reloader.sh
dest: /usr/local/bin/mumble-server-certificate-reloader
mode: 0755

- name: Template certificate reloader service and timer
template:
src: "mumble/mumble-server-certificate-reloader.{{ item }}.j2"
dest: "/etc/systemd/system/mumble-certificate-reloader.{{ item }}"
notify:
- daemon reload
- restart certificate reload timer
with_items: ["service", "timer"]
tags: mumble

- hosts: web
Expand Down
2 changes: 1 addition & 1 deletion roles/n0emis.synapse
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Unit]
Description=Mumble certificate reloader

[Service]
Type=oneshot
SyslogIdentifier=mumble-server-certificate-reloader
ExecStart=/usr/local/bin/mumble-server-certificate-reloader {{ mumble_domain }} {{ murmur_port }}
User={{ murmur_username }}
22 changes: 22 additions & 0 deletions templates/mumble/mumble-server-certificate-reloader.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
if ${DEBUG:-false}; then
set -x
fi
set -E

hostname=${1:-mumble.chaos.jetzt}
port=${2:-64738}
murmur_pid=$(cat /var/run/mumble-server/mumble-server.pid)
reload_cmd=${3:-"kill -10 $murmur_pid"}
now=$(date +"%s")
in_one_week=$((now + 60*60*24*7))
${DRY_RUN:=false}

# Checking if the certificate will expire in one week or less
echo | openssl s_client -connect "${hostname}:${port}" -servername "${hostname}" -servername mumble.chaos.jetzt -attime ${in_one_week} -verify_return_error -verify 20 >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
echo "Reloading..."
if ! $DRY_RUN; then
$reload_cmd
fi
fi
9 changes: 9 additions & 0 deletions templates/mumble/mumble-server-certificate-reloader.timer.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=Mumble certificate reloader

[Timer]
OnCalendar=*-*-* *:13:37
Persistent=true

[Install]
WantedBy=timers.target