diff --git a/bitlair.yaml b/bitlair.yaml index f4ece91..19de646 100644 --- a/bitlair.yaml +++ b/bitlair.yaml @@ -47,6 +47,7 @@ - hosts: music roles: - { role: "acme", tags: ["acme"] } + - { role: "go", tags: ["go"] } - { role: "music", tags: ["music"] } - hosts: pad @@ -57,7 +58,6 @@ - hosts: services roles: - - { role: "deb_forgejo", tags: [ "deb_forgejo" ] } - { role: "services", tags: ["services"] } - hosts: wiki @@ -71,7 +71,3 @@ - { role: "acme", tags: [ "acme" ] } - { role: "nginx", tags: [ "nginx" ] } - { role: "chat", tags: [ "chat" ] } - -- hosts: ldap - roles: - - { role: "common", tags: [ "common" ] } diff --git a/chat.yaml b/chat.yaml index fdf3a9a..a5b4c42 100644 --- a/chat.yaml +++ b/chat.yaml @@ -6,5 +6,4 @@ - { role: "nft", tags: [ "nft" ] } - { role: "nginx", tags: [ "nginx" ] } - { role: "acme", tags: [ "acme" ] } - - { role: "nodesource", tags: [ "nodesource" ] } - { role: "chat", tags: [ "chat" ] } diff --git a/group_vars/all.yaml b/group_vars/all.yaml index 0169ce1..39de4c0 100644 --- a/group_vars/all.yaml +++ b/group_vars/all.yaml @@ -37,7 +37,5 @@ debian_repourl: "http://deb.debian.org/debian/" debian_securityurl: "http://security.debian.org/debian-security" deb_forgejo_repos: - - host: git.bitlair.nl - owner: bitlair - host: git.polyfloyd.net owner: polyfloyd diff --git a/group_vars/music.yaml b/group_vars/music.yaml index 85f4ce8..8f0cc7c 100644 --- a/group_vars/music.yaml +++ b/group_vars/music.yaml @@ -6,18 +6,12 @@ nft: false root_access: - ak - bob + - eightdot - foobar - polyfloyd nginx_client_max_body_size: 512M -nginx_sites: - - server_name: "music.bitlair.nl" - snippets: - - "music-nginx.j2" music_domain: music.bitlair.nl acme_san_domains: - [ music.bitlair.nl ] - -music_bitpanel_host: bitpanel.bitlair.nl -music_bitpanel_port: 1337 diff --git a/inventory b/inventory index eca431d..86d1bea 100644 --- a/inventory +++ b/inventory @@ -50,9 +50,6 @@ homeassistant.bitlair.nl [chat] chat.bitlair.nl -[ldap] -ldap-new.bitlair.nl - [debian:children] bank fotos diff --git a/music.yaml b/music.yaml index cc04425..17666f3 100644 --- a/music.yaml +++ b/music.yaml @@ -5,5 +5,6 @@ - { role: "common", tags: [ "common" ] } - { role: "acme", tags: [ "acme" ] } - { role: "deb_forgejo", tags: [ "deb_forgejo" ] } - - { role: "nginx", tags: [ "nginx" ] } + - { role: "go", tags: [ "go" ] } +# - { role: "nginx", tags: [ "nginx" ] } - { role: "music", tags: [ "music" ] } diff --git a/pad.yaml b/pad.yaml index 1d35c0d..380e790 100644 --- a/pad.yaml +++ b/pad.yaml @@ -9,5 +9,4 @@ - { role: "nft", tags: [ "nft" ] } - { role: "acme", tags: [ "acme" ] } - { role: "nginx", tags: [ "nginx" ] } - - { role: "nodesource", tags: [ "nodesource" ] } - { role: "etherpad", tags: [ "etherpad" ] } diff --git a/roles/bank/defaults/main.yaml b/roles/bank/defaults/main.yaml index 922bb73..b0fea92 100644 --- a/roles/bank/defaults/main.yaml +++ b/roles/bank/defaults/main.yaml @@ -1,3 +1,3 @@ bank_user: bank +bank_revbank_git: https://git.bitlair.nl/bitlair/revbank.git bank_local_tty: no -bank_revbank_version: "10.5.1" diff --git a/roles/bank/tasks/login.yaml b/roles/bank/tasks/login.yaml index f54bbfd..7ed568e 100644 --- a/roles/bank/tasks/login.yaml +++ b/roles/bank/tasks/login.yaml @@ -4,7 +4,7 @@ name: bank password: $6$idklol$QrOE/21LDR0vhZBAXwgA7AvnmR6Ju4ZqzAzgeazC08i2yw9kyQjgwu.uuV692iL/cyE7AteDYUxCpcorONXom. # "bank" home: /home/{{ bank_user }} - shell: /usr/local/share/revbank/revbank + shell: /home/{{ bank_user }}/revbank.git/revbank update_password: always - name: Allow password auth for bank user @@ -13,7 +13,7 @@ insertafter: EOF validate: "/usr/sbin/sshd -t -f %s" block: |- - Match User {{ bank_user }} + Match User bank PasswordAuthentication yes notify: reload sshd diff --git a/roles/bank/tasks/revbank.yaml b/roles/bank/tasks/revbank.yaml index 3b2ec65..ec283d1 100644 --- a/roles/bank/tasks/revbank.yaml +++ b/roles/bank/tasks/revbank.yaml @@ -1,22 +1,50 @@ --- - name: Install dependencies ansible.builtin.apt: - name: [ git, libterm-readline-gnu-perl, libcurses-ui-perl ] + name: [ git, libterm-readline-gnu-perl, libcurses-ui-perl, qrencode ] state: present - name: Clone revbank source ansible.builtin.git: - repo: https://github.com/revspace/revbank.git - version: "v{{ bank_revbank_version }}" - dest: /usr/local/share/revbank + repo: "{{ bank_revbank_git }}" + version: master + dest: /home/{{ bank_user }}/revbank.git accept_hostkey: yes -- name: Clone revbank-plugin source - ansible.builtin.git: - repo: https://git.bitlair.nl/bitlair/revbank-plugins.git - version: main - dest: /usr/local/share/revbank-plugins - accept_hostkey: yes +- name: Create data files + ansible.builtin.command: cp /home/{{ bank_user }}/revbank.git/{{ item }} /home/{{ bank_user }}/{{ item }} + args: + creates: /home/{{ bank_user }}/{{ item }} + with_items: + - revbank.accounts + - revbank.market + - revbank.products + +- name: Ensure data file permissions + ansible.builtin.file: + path: /home/{{ bank_user }}/{{ item }} + state: touch + owner: "{{ bank_user }}" + group: "{{ bank_user }}" + mode: 0644 + with_items: + - revbank.accounts + - revbank.market + - revbank.products + +- name: Link plugins + ansible.builtin.file: + state: link + path: /home/{{ bank_user }}/{{ item }} + src: /home/{{ bank_user }}/revbank.git/{{ item }} + with_items: + - plugins + - revbank.plugins + +- name: Create git data dir + ansible.builtin.file: + path: /home/{{ bank_user }}/data.git + state: directory - name: Install git cronjob ansible.builtin.template: diff --git a/roles/bank/templates/git.cron b/roles/bank/templates/git.cron index b5ad03c..b334260 100644 --- a/roles/bank/templates/git.cron +++ b/roles/bank/templates/git.cron @@ -1,4 +1,4 @@ SHELL=/bin/bash #m h dom mon dow user command - */10 * * * * {{ bank_user }} git -C ~/.revbank pull -r && git -C ~/.revbank push && git -C ~/.revbank gc + */10 * * * * {{ bank_user }} (cd /home/{{ bank_user }}/data.git && git pull -r && git push && git gc --auto && cp revbank.products ../revbank.products) diff --git a/roles/chat/tasks/main.yaml b/roles/chat/tasks/main.yaml index cad172f..7b74982 100644 --- a/roles/chat/tasks/main.yaml +++ b/roles/chat/tasks/main.yaml @@ -4,8 +4,17 @@ ansible.builtin.apt: state: present pkg: + - gpg + - apt-transport-https - build-essential - - nodejs + +- 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: @@ -21,15 +30,26 @@ 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 -- ansible.builtin.stat: - path: /opt/thelounge +- stat: path=/opt/thelounge register: src_path - name: Retreive thelounge source @@ -68,14 +88,14 @@ state: present - name: Ensure JS and JSON syntax checking packages are installed - community.general.yarn: + yarn: name: "{{ item }}" global: yes - # state: latest # FIXME: Remove when https://github.com/ansible/ansible/pull/39557 makes it in + 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 + changed_when: no # FIXME: Remove when https://github.com/ansible/ansible/pull/39557 makes it in - name: Configure templates ansible.builtin.template: diff --git a/roles/chat/templates/nodejs-apt-pref b/roles/chat/templates/nodejs-apt-pref new file mode 100644 index 0000000..6193912 --- /dev/null +++ b/roles/chat/templates/nodejs-apt-pref @@ -0,0 +1,5 @@ +# {{ ansible_managed }} + +Package: nodejs +Pin: origin deb.nodesource.com +Pin-Priority: 1000 diff --git a/roles/chat/templates/nodesource.list b/roles/chat/templates/nodesource.list new file mode 100644 index 0000000..6ac9322 --- /dev/null +++ b/roles/chat/templates/nodesource.list @@ -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 diff --git a/roles/etherpad/defaults/main.yaml b/roles/etherpad/defaults/main.yaml index 4a05b97..7e1952a 100644 --- a/roles/etherpad/defaults/main.yaml +++ b/roles/etherpad/defaults/main.yaml @@ -1,3 +1,4 @@ +nodejs_version: 22.x etherpad_db_user: etherpad etherpad_db_password: "{{ lookup('password', '/tmp/etherpad_db_password length=32') }}" etherpad_db_name: etherpad diff --git a/roles/etherpad/tasks/main.yaml b/roles/etherpad/tasks/main.yaml index e19835c..38dc4d3 100644 --- a/roles/etherpad/tasks/main.yaml +++ b/roles/etherpad/tasks/main.yaml @@ -3,10 +3,43 @@ - name: Install dependencies ansible.builtin.apt: state: present - pkg: - - nodejs + pkg: + - gpg - postgresql - python3-psycopg2 + - apt-transport-https + +- 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: Install nodesource source list + ansible.builtin.template: + src: nodesource.list + dest: /etc/apt/sources.list.d/nodesource.list + owner: root + group: root + mode: 0644 + notify: apt update + +- name: Install nodejs apt preference + ansible.builtin.template: + src: nodejs-apt-pref + dest: /etc/apt/preferences.d/nodejs + owner: root + group: root + mode: 0644 + notify: apt update + +- ansible.builtin.meta: flush_handlers + +- name: Install nodejs + ansible.builtin.apt: + name: nodejs - name: Add database user become: true diff --git a/roles/nodesource/templates/nodejs-apt-pref b/roles/etherpad/templates/nodejs-apt-pref similarity index 100% rename from roles/nodesource/templates/nodejs-apt-pref rename to roles/etherpad/templates/nodejs-apt-pref diff --git a/roles/nodesource/templates/nodesource.list b/roles/etherpad/templates/nodesource.list similarity index 56% rename from roles/nodesource/templates/nodesource.list rename to roles/etherpad/templates/nodesource.list index 3600170..43defab 100644 --- a/roles/nodesource/templates/nodesource.list +++ b/roles/etherpad/templates/nodesource.list @@ -1,3 +1,3 @@ # {{ ansible_managed }} -deb [arch=$arch signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_{{ nodesource_version }} nodistro main +deb [arch=$arch signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_{{ nodejs_version }} nodistro main diff --git a/roles/git-server/templates/cronjob b/roles/git-server/templates/cronjob index 659b668..9a71799 100644 --- a/roles/git-server/templates/cronjob +++ b/roles/git-server/templates/cronjob @@ -1,4 +1,4 @@ # {{ ansible_managed }} -#m h dom mon dow user command - 0 2 * * 1 root {{ git_server_working_dir }}/update.sh +#m h dom mon dow user command + 0 2 * * 1 {{ git_server_user }} {{ git_server_working_dir }}/update.sh diff --git a/roles/mqtt/defaults/main.yaml b/roles/mqtt/defaults/main.yaml new file mode 100644 index 0000000..8cf4403 --- /dev/null +++ b/roles/mqtt/defaults/main.yaml @@ -0,0 +1 @@ +mqtt_bambulab_cafile: /etc/mosquitto/ca_certificates/bambulab.pem diff --git a/roles/mqtt/tasks/main.yaml b/roles/mqtt/tasks/main.yaml index c2e46ab..498f49c 100644 --- a/roles/mqtt/tasks/main.yaml +++ b/roles/mqtt/tasks/main.yaml @@ -9,10 +9,8 @@ - name: Install bambulab cafile # openssl s_client -showcerts -connect :8883