Compare commits

...
Sign in to create a new pull request.

12 commits

38 changed files with 448 additions and 127 deletions

View file

@ -0,0 +1 @@
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICLZGbt/we3JQ482/NYcdOKGoKDOj1MgmYFP2GDmjLw/ kyan@flandre

View file

@ -26,7 +26,7 @@
- hosts: git-ci
roles:
- { role: "git-ci", tags: ["git-ci"] }
- { role: "git_ci", tags: ["git_ci"] }
- hosts: git
roles:
@ -65,3 +65,9 @@
- { role: "acme", tags: ["acme"] }
- { role: "nginx", tags: ["nginx"] }
- { role: "www", tags: ["www"] }
- hosts: chat
roles:
- { role: "acme", tags: [ "acme" ] }
- { role: "nginx", tags: [ "nginx" ] }
- { role: "chat", tags: [ "chat" ] }

9
chat.yaml Normal file
View file

@ -0,0 +1,9 @@
---
- hosts: chat
roles:
- { role: "common", tags: [ "common" ] }
- { role: "nft", tags: [ "nft" ] }
- { role: "nginx", tags: [ "nginx" ] }
- { role: "acme", tags: [ "acme" ] }
- { role: "chat", tags: [ "chat" ] }

View file

@ -3,4 +3,4 @@
- hosts: git-ci
roles:
- { role: "common", tags: [ "common" ] }
- { role: "git-ci", tags: [ "git-ci" ] }
- { role: "git_ci", tags: [ "git_ci" ] }

View file

@ -36,3 +36,6 @@ mqtt_public_host: bitlair.nl
debian_repourl: "http://deb.debian.org/debian/"
debian_securityurl: "http://security.debian.org/debian-security"
deb_forgejo_repos:
- host: git.polyfloyd.net
owner: polyfloyd

36
group_vars/chat.yaml Normal file
View file

@ -0,0 +1,36 @@
---
root_access:
- blackdragon
- ak
- foobar
- polyfloyd
nodejs_version: 22.x
thelounge_version: "4.4.3"
thelounge_ldap_url: ldaps://ldap.bitlair.nl
thelounge_ldap_filter: (objectClass=inetOrgPerson)
thelounge_ldap_base: ou=Members,dc=bitlair,dc=nl
chat_hostname: chat.bitlair.nl
acme_domains:
- "{{ chat_hostname }}"
nginx_sites:
- server_name: "{{ chat_hostname }}"
config:
- |-
location / {
proxy_pass http://127.0.0.1:9000/;
proxy_http_version 1.1;
proxy_set_header Connection "upgrade";
proxy_set_header Upgrade $http_upgrade;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
# by default nginx times out connections in one minute
proxy_read_timeout 1d;
}
group_nft_input:
- "tcp dport { http, https } accept # Allow web-traffic from world"

View file

@ -17,7 +17,8 @@ blockchain.bitlair.nl
git.bitlair.nl
[git-ci]
git-ci.bitlair.nl
git-ci01.bitlair.nl
git-ci02.bitlair.nl
[pad]
pad.bitlair.nl

View file

@ -4,5 +4,6 @@
roles:
- { role: "common", tags: [ "common" ] }
- { role: "acme", tags: [ "acme" ] }
- { role: "deb_forgejo", tags: [ "deb_forgejo" ] }
- { role: "nginx", tags: [ "nginx" ] }
- { role: "monitoring", tags: [ "monitoring" ] }

View file

@ -4,6 +4,7 @@
roles:
- { role: "common", tags: [ "common" ] }
- { role: "acme", tags: [ "acme" ] }
- { role: "deb_forgejo", tags: [ "deb_forgejo" ] }
- { role: "go", tags: [ "go" ] }
# - { role: "nginx", tags: [ "nginx" ] }
- { role: "music", tags: [ "music" ] }

View file

@ -1,4 +1,4 @@
SHELL=/bin/bash
#m h dom mon dow user command
0 * * * * {{ bank_user }} (cd /home/{{ bank_user }}/data.git && git pull -r && git push && git gc --auto && cp revbank.products ../revbank.products)
*/10 * * * * {{ bank_user }} (cd /home/{{ bank_user }}/data.git && git pull -r && git push && git gc --auto && cp revbank.products ../revbank.products)

View file

@ -0,0 +1,5 @@
---
chat_user: thelounge
chat_group: thelounge
chat_configdir: "/etc/thelounge"

View file

@ -0,0 +1,11 @@
---
- name: Reload systemd
ansible.builtin.systemd:
daemon_reload: yes
- name: Restart thelounge
ansible.builtin.systemd:
name: thelounge
state: restarted
enabled: true

112
roles/chat/tasks/main.yaml Normal file
View file

@ -0,0 +1,112 @@
---
- name: Install dependencies
ansible.builtin.apt:
state: present
pkg:
- gpg
- apt-transport-https
- build-essential
- name: Import nodesource signing key
ansible.builtin.shell:
cmd: curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor
-o /usr/share/keyrings/nodesource.gpg
args:
creates: /usr/share/keyrings/nodesource.gpg
notify: Apt update
- name: Ensure directories are present
ansible.builtin.file:
path: "{{ item.path }}"
owner: "{{ chat_user }}"
group: "{{ chat_group }}"
state: "{{ item.state | default('directory') }}"
mode: "{{ item.mode | default('0770') }}"
with_items:
- { path: "{{ chat_configdir }}" }
- { path: "/var/local/thelounge/users" }
- { path: "/var/local/thelounge/storage" }
notify:
- Restart thelounge
- name: Configure templates
ansible.builtin.template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
owner: "{{ item.owner | default( chat_user ) }}"
group: "{{ item.group | default( chat_group ) }}"
mode: "{{ item.mode | default('0640') }}"
with_items:
- { src: "nodesource.list", dest: "/etc/apt/sources.list.d/nodesource.list", owner: root, group: root }
- { src: "nodejs-apt-pref", dest: "/etc/apt/preferences.d/nodejs", owner: root, group: root }
- name: Install nodejs
ansible.builtin.apt:
name: nodejs
- name: Install yarn
ansible.builtin.shell:
cmd: npm install --global yarn
- stat: path=/opt/thelounge
register: src_path
- name: Retreive thelounge source
block:
- name: Checkout source
ansible.builtin.git:
repo: 'https://github.com/revspace/thelounge.git'
dest: /opt/thelounge
version: 9d6dc83
force: true
- name: Copy patch
ansible.builtin.template:
src: thelounge-bitlair.patch
dest: /tmp/thelounge-bitlair.patch
- name: Apply patch
ansible.builtin.shell:
chdir: /opt/thelounge
cmd: git apply /tmp/thelounge-bitlair.patch
when: not src_path.stat.exists
- name: Build and install thelounge
ansible.builtin.shell:
chdir: /opt/thelounge
cmd: yarn add sharp --ignore-engines && yarn install --include-optional sharp && NODE_ENV=production yarn build && ln -sf $(pwd)/index.js /usr/local/bin/thelounge
notify:
- Restart thelounge
- name: Ensure user thelounge is present
ansible.builtin.user:
name: thelounge
createhome: no
comment: The Lounge (IRC client)
system: yes
state: present
- name: Ensure JS and JSON syntax checking packages are installed
yarn:
name: "{{ item }}"
global: yes
state: latest # FIXME: Remove when https://github.com/ansible/ansible/pull/39557 makes it in
with_items:
- esprima
- jsonlint
changed_when: no # FIXME: Remove when https://github.com/ansible/ansible/pull/39557 makes it in
- name: Configure templates
ansible.builtin.template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
owner: "{{ item.owner | default( chat_user ) }}"
group: "{{ item.group | default( chat_group ) }}"
mode: "{{ item.mode | default('0640') }}"
validate: "{{ item.validate | default([]) }}"
with_items:
- { src: "config.js.j2", dest: "/etc/thelounge/config.js", validate: 'esvalidate %s' }
- { src: "thelounge.service", dest: "/etc/systemd/system/thelounge.service", owner: root, group: root, notify: "Reload systemd" }
notify: "{{ item.notify | default('Restart thelounge') }}"

View file

@ -0,0 +1,59 @@
"use strict";
module.exports = {
public: false,
port: 9000,
bind: "0.0.0.0",
host: "127.0.0.1",
reverseProxy: true,
lockNetwork: true,
maxHistory: 10000,
leaveMessage: "Doei!",
defaults: {
name: "Smurfnet",
password: "",
rejectUnauthorized: true,
nick: "",
username: "",
realname: "",
join: "#bitlair",
},
messageStorage: ["sqlite", "text"],
fileUpload: {
enable: true,
},
networks: {
Smurfnet: {
host: "irc.smurfnet.ch",
port: 6697,
tls: true,
rejectUnauthorized: false,
},
"Libera.Chat": {
host: "irc.libera.chat",
port: 6697,
tls: true,
rejectUnauthorized: true,
},
OFTC: {
host: "irc.oftc.net",
port: 6697,
tls: true,
rejectUnauthorized: true,
},
},
identd: {
enable: false,
},
ldap: {
enable: true,
url: "{{ thelounge_ldap_url }}",
primaryKey: "uid",
searchDN: {
rootDN: "{{ lookup('passwordstore', 'chat/thelounge/ldap_rootDN subkey=binddn') }}",
rootPassword: "{{ lookup('passwordstore', 'chat/thelounge/ldap_rootDN') }}",
filter: "{{ thelounge_ldap_filter }}",
base: "{{ thelounge_ldap_base }}",
},
},
};

View file

@ -0,0 +1,5 @@
# {{ ansible_managed }}
Package: nodejs
Pin: origin deb.nodesource.com
Pin-Priority: 1000

View file

@ -0,0 +1,3 @@
# {{ ansible_managed }}
deb [arch=amd64 signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_{{ nodejs_version }} nodistro main

View file

@ -0,0 +1,28 @@
diff --git a/package.json b/package.json
index 2991a6ec..dac43f16 100644
--- a/package.json
+++ b/package.json
@@ -84,9 +84,7 @@
"ua-parser-js": "1.0.33",
"uuid": "8.3.2",
"web-push": "3.4.5",
- "yarn": "1.22.17"
- },
- "optionalDependencies": {
+ "yarn": "1.22.17",
"sqlite3": "5.1.7"
},
"devDependencies": {
diff --git a/server/plugins/auth/ldap.ts b/server/plugins/auth/ldap.ts
index e6093b0f..d30b9a1c 100644
--- a/server/plugins/auth/ldap.ts
+++ b/server/plugins/auth/ldap.ts
@@ -134,7 +134,7 @@ const ldapAuth: AuthHandler = (manager, client, user, password, callback) => {
// auth plugin API
function callbackWrapper(valid: boolean) {
if (valid && !client) {
- manager.addUser(user, null, false);
+ manager.addUser(user, null, true);
}
callback(valid);

View file

@ -0,0 +1,17 @@
[Unit]
Description=The Lounge (IRC client)
After=network-online.target
Wants=network-online.target
[Service]
User={{ chat_user }}
Group={{ chat_group }}
Type=simple
Environment=THELOUNGE_HOME=/var/local/thelounge
ExecStart=/usr/local/bin/thelounge start
ProtectSystem=yes
ProtectHome=yes
PrivateTmp=yes
[Install]
WantedBy=multi-user.target

View file

@ -3,7 +3,7 @@
ansible.builtin.command:
cmd: update-grub
- name: Apt update
- name: apt update
ansible.builtin.apt:
update_cache: true

View file

@ -0,0 +1 @@
deb_private_host: git.polyfloyd.net

View file

@ -0,0 +1,3 @@
---
- ansible.builtin.import_tasks:
file: ../../common/handlers/main.yaml

View file

@ -0,0 +1,26 @@
---
- tags: deb_forgejo
block:
- name: Install dependencies
apt:
name: apt-transport-https
state: present
- name: Install packaging key
get_url:
url: https://{{ item.host }}/api/packages/{{ item.owner }}/debian/repository.key
dest: /etc/apt/keyrings/{{ item.host }}-{{ item.owner }}.asc
mode: "0644"
with_items: "{{ deb_forgejo_repos }}"
notify: apt update
- name: Install sources.list
template:
src: sources.list
dest: /etc/apt/sources.list.d/deb-forgejo.list
owner: root
group: root
mode: "0644"
notify: apt update
- meta: flush_handlers

View file

@ -0,0 +1,5 @@
# {{ ansible_managed }}
{% for repo in deb_forgejo_repos %}
deb [signed-by=/etc/apt/keyrings/{{ repo.host }}-{{ repo.owner }}.asc] https://{{ repo.host }}/api/packages/{{ repo.owner }}/debian {{ repo.distro | default('stable') }} {{ repo.component | default('main') }}
{% endfor %}

View file

@ -15,7 +15,7 @@
-o /usr/share/keyrings/nodesource.gpg
args:
creates: /usr/share/keyrings/nodesource.gpg
notify: Apt update
notify: apt update
- name: Install nodesource source list
ansible.builtin.template:
@ -24,7 +24,7 @@
owner: root
group: root
mode: 0644
notify: Apt update
notify: apt update
- name: Install nodejs apt preference
ansible.builtin.template:
@ -33,7 +33,7 @@
owner: root
group: root
mode: 0644
notify: Apt update
notify: apt update
- ansible.builtin.meta: flush_handlers

View file

@ -1,2 +0,0 @@
runner_wd: /var/lib/forgejo-runner
runner_version: 6.3.0

View file

@ -1,50 +0,0 @@
---
- name: Install dependencies
ansible.builtin.apt:
name: docker.io
- name: Download forgejo-runner
ansible.builtin.get_url:
url: "https://code.forgejo.org/forgejo/runner/releases/download/v{{ runner_version }}/forgejo-runner-{{ runner_version }}-linux-amd64"
dest: /usr/local/bin/forgejo-runner
mode: 0755
notify: restart forgejo-runner
- name: Create runner dir
ansible.builtin.file:
state: directory
path: "{{ runner_wd }}"
owner: root
group: root
mode: 0755
- name: Register runner
ansible.builtin.command: "forgejo-runner register --no-interactive --instance={{ forgejo_url }} --token={{ lookup('passwordstore', 'git/ci subkey=runner_token') }}"
args:
chdir: "{{ runner_wd }}"
creates: "{{ runner_wd }}/.runner"
- name: Install service file
ansible.builtin.template:
src: forgejo-runner.service
dest: /etc/systemd/system/forgejo-runner.service
owner: root
group: root
mode: 0644
notify: restart forgejo-runner
- name: Enable service
ansible.builtin.systemd:
name: forgejo-runner
enabled: true
daemon_reload: true
- name: Start service
ansible.builtin.systemd:
name: forgejo-runner
state: started
daemon_reload: true
- name: Flush handlers
ansible.builtin.meta: flush_handlers

View file

@ -0,0 +1,2 @@
---
git_ci_runner_wd: /var/lib/forgejo-runner

View file

@ -3,6 +3,6 @@
file: ../../common/handlers/main.yaml
- name: restart forgejo-runner
ansible.builtin.systemd:
systemd:
name: forgejo-runner
state: restarted

View file

@ -0,0 +1,83 @@
---
- tags: git_ci
block:
- name: Install dependencies
apt:
name: docker.io
- name: Query latest forgejo-runner version
uri:
url: https://code.forgejo.org/api/v1/repos/forgejo/runner/tags
return_content: true
register: response
changed_when: false
check_mode: false
failed_when: "response is failed or 'json' not in response"
- name: Format forgejo-runner latest version
set_fact:
forgejo_runner_version: "{{ response['json'][0]['name'] | trim('v') }}"
- name: Detect installed forgejo-runner version
shell:
cmd: |
set -o pipefail
forgejo-runner --version | grep --color=never -Po '\d\.\d+(\.\d+)?' || echo none
executable: /bin/bash
register: forgejo_runner_installed_version_shell
changed_when: false
check_mode: false
- name: Format installed forgejo-runner version
set_fact:
forgejo_runner_installed_version: "{{ forgejo_runner_installed_version_shell.stdout }}"
- debug:
msg:
- "Forgejo Runner latest version: {{ forgejo_runner_version }}"
- "Forgejo Runner installed version: {{ forgejo_runner_installed_version }}"
- name: Download forgejo-runner
get_url:
url: "https://code.forgejo.org/forgejo/runner/releases/download/v{{ forgejo_runner_version }}/forgejo-runner-{{ forgejo_runner_version }}-linux-amd64"
dest: /usr/local/bin/forgejo-runner
mode: "0755"
notify: restart forgejo-runner
when: forgejo_runner_installed_version != forgejo_runner_version
- name: Create runner dir
file:
state: directory
path: "{{ git_ci_runner_wd }}"
owner: root
group: root
mode: "0755"
- name: Register runner
command: "forgejo-runner register --no-interactive --instance={{ forgejo_url }} --token={{ lookup('passwordstore', 'git/ci subkey=runner_token') }}"
args:
chdir: "{{ git_ci_runner_wd }}"
creates: "{{ git_ci_runner_wd }}/.runner"
- name: Install service file
template:
src: forgejo-runner.service
dest: /etc/systemd/system/forgejo-runner.service
owner: root
group: root
mode: "0644"
notify: restart forgejo-runner
- name: Enable service
systemd:
name: forgejo-runner
enabled: true
daemon_reload: true
- name: Start service
systemd:
name: forgejo-runner
state: started
daemon_reload: true
- meta: flush_handlers

View file

@ -6,7 +6,7 @@ After=network.target
[Service]
ExecStart=/usr/local/bin/forgejo-runner daemon
WorkingDirectory={{ runner_wd }}
WorkingDirectory={{ git_ci_runner_wd }}
Restart=on-failure
RestartSec=10s

View file

@ -1,47 +1,22 @@
---
- name: Clone source
ansible.builtin.git:
repo: https://github.com/polyfloyd/mqtt-exporter.git
version: main
dest: /opt/mqtt_exporter
accept_hostkey: yes
notify: restart mqtt_exporter
- name: Install apt dependencies
ansible.builtin.apt:
name:
- jq
- python3-paho-mqtt
- python3-prometheus-client
- python3-yaml
name: mqtt-exporter
state: present
- name: Install service
ansible.builtin.template:
src: mqtt_exporter.service
dest: /etc/systemd/system/mqtt_exporter.service
owner: root
group: root
mode: 0644
notify:
- Daemon reload
- restart mqtt_exporter
- name: Install config file
ansible.builtin.template:
src: mqtt_exporter_config.yaml
dest: /etc/mqtt_exporter.yaml
dest: /etc/mqtt-exporter.yaml
owner: root
group: root
mode: 0644
notify:
- Daemon reload
- restart mqtt_exporter
notify: restart mqtt_exporter
- ansible.builtin.meta: flush_handlers
- name: Start service
ansible.builtin.systemd:
name: mqtt_exporter
name: mqtt-exporter
state: started
enabled: true

View file

@ -1,28 +1,17 @@
---
- name: Install dependencies
ansible.builtin.apt:
name: virtualenv
name:
- mqtt-soundboard
- mplayer
state: present
- name: Clone soundboard source
ansible.builtin.git:
repo: https://github.com/polyfloyd/mqtt-soundboard.git
version: main
dest: /opt/soundboard
accept_hostkey: yes
notify: Restart soundboard
- name: Create virtualenv
ansible.builtin.command:
cmd: virtualenv /opt/soundboard/.venv
args:
creates: /opt/soundboard/.venv
- name: Install Python dependencies
ansible.builtin.shell:
cmd: . .venv/bin/activate && pip install -r requirements.txt
args:
chdir: /opt/soundboard
- ansible.builtin.file:
path: "{{ item }}"
state: absent
with_items:
- /opt/soundboard
- /etc/systemd/system/soundboard.service
- name: Install soundboard config file
ansible.builtin.template:
@ -33,15 +22,6 @@
mode: 0644
notify: Restart soundboard
- name: Install soundboard service file
ansible.builtin.template:
src: soundboard.service
dest: /etc/systemd/system/soundboard.service
owner: root
group: root
mode: 0644
notify: Restart soundboard
- name: Enable soundboard
ansible.builtin.systemd:
name: soundboard

View file

@ -21,7 +21,7 @@
- name: Clone source
ansible.builtin.git:
repo: https://github.com/bitlair/discord-bot.git
repo: https://git.bitlair.nl/bitlair/discord-bot.git
version: main
dest: /var/lib/discord-bot
accept_hostkey: yes

View file

@ -7,7 +7,7 @@
- name: Clone source
ansible.builtin.git:
repo: https://github.com/bitlair/mastodon-spacestate.git
repo: https://git.bitlair.nl/bitlair/mastodon-spacestate.git
version: main
dest: /var/lib/mastodon-spacestate
accept_hostkey: yes

View file

@ -21,7 +21,7 @@
- name: Clone source
ansible.builtin.git:
repo: https://github.com/bitlair/spacestated.git
repo: https://git.bitlair.nl/bitlair/spacestated.git
version: main
dest: /var/lib/spacestated/spacestated
accept_hostkey: yes

View file

@ -8,7 +8,7 @@
- name: Clone source
ansible.builtin.git:
repo: https://github.com/bitlair/wifi-mqtt.git
repo: https://git.bitlair.nl/bitlair/wifi-mqtt.git
version: main
dest: /var/lib/wifi-mqtt
accept_hostkey: yes

View file

@ -5,7 +5,7 @@
- name: Clone source
ansible.builtin.git:
repo: https://github.com/bitlair/calendar-parser.git
repo: https://git.bitlair.nl/bitlair/wiki-calendar-exporter.git
version: main
dest: /usr/local/src/bitlair-calendar
accept_hostkey: yes

View file

@ -1,7 +1,7 @@
---
- name: Clone spaceapi source
ansible.builtin.git:
repo: https://github.com/bitlair/spaceapi.git
repo: https://git.bitlair.nl/bitlair/spaceapi.git
version: main
dest: /opt/spaceapi
accept_hostkey: true