--- - 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') }}"