forked from bitlair/ansible
Cleanup thelounge playbook
This commit is contained in:
parent
8e2cc7e77a
commit
050205e95c
5 changed files with 61 additions and 74 deletions
|
@ -65,3 +65,9 @@
|
||||||
- { role: "acme", tags: ["acme"] }
|
- { role: "acme", tags: ["acme"] }
|
||||||
- { role: "nginx", tags: ["nginx"] }
|
- { role: "nginx", tags: ["nginx"] }
|
||||||
- { role: "www", tags: ["www"] }
|
- { role: "www", tags: ["www"] }
|
||||||
|
|
||||||
|
- hosts: chat
|
||||||
|
roles:
|
||||||
|
- { role: "acme", tags: [ "acme" ] }
|
||||||
|
- { role: "nginx", tags: [ "nginx" ] }
|
||||||
|
- { role: "chat", tags: [ "chat" ] }
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
---
|
||||||
|
|
||||||
- hosts: chat
|
- hosts: chat
|
||||||
roles:
|
roles:
|
||||||
- { role: "common", tags: [ "common" ] }
|
- { role: "common", tags: [ "common" ] }
|
||||||
|
|
10
roles/chat/handlers/main.yaml
Normal file
10
roles/chat/handlers/main.yaml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
---
|
||||||
|
- name: Reload systemd
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
daemon_reload: yes
|
||||||
|
|
||||||
|
- name: Restart thelounge
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: thelounge
|
||||||
|
state: restarted
|
||||||
|
enabled: true
|
|
@ -1,7 +1,9 @@
|
||||||
|
---
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
state: present
|
state: present
|
||||||
pkg:
|
pkg:
|
||||||
- gpg
|
- gpg
|
||||||
- apt-transport-https
|
- apt-transport-https
|
||||||
- build-essential
|
- build-essential
|
||||||
|
@ -14,25 +16,30 @@
|
||||||
creates: /usr/share/keyrings/nodesource.gpg
|
creates: /usr/share/keyrings/nodesource.gpg
|
||||||
notify: Apt update
|
notify: Apt update
|
||||||
|
|
||||||
- name: Install nodesource source list
|
- name: Ensure directories are present
|
||||||
ansible.builtin.template:
|
ansible.builtin.file:
|
||||||
src: nodesource.list
|
path: "{{ item.path }}"
|
||||||
dest: /etc/apt/sources.list.d/nodesource.list
|
owner: "thelounge"
|
||||||
owner: root
|
group: "thelounge"
|
||||||
group: root
|
state: "{{ item.state | default('directory') }}"
|
||||||
mode: 0644
|
mode: "{{ item.mode | default('0770') }}"
|
||||||
notify: Apt update
|
with_items:
|
||||||
|
- { path: "/etc/thelounge" }
|
||||||
|
- { path: "/var/local/thelounge/users" }
|
||||||
|
- { path: "/var/local/thelounge/storage" }
|
||||||
|
notify:
|
||||||
|
- Restart thelounge
|
||||||
|
|
||||||
- name: Install nodejs apt preference
|
- name: Configure templates
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: nodejs-apt-pref
|
src: "{{ item.src }}"
|
||||||
dest: /etc/apt/preferences.d/nodejs
|
dest: "{{ item.dest }}"
|
||||||
owner: root
|
owner: "{{ item.owner | default( 'thelounge' ) }}"
|
||||||
group: root
|
group: "{{ item.group | default( 'thelounge' ) }}"
|
||||||
mode: 0644
|
mode: "{{ item.mode | default('0640') }}"
|
||||||
notify: Apt update
|
with_items:
|
||||||
|
- { src: "nodesource.list", dest: "/etc/apt/sources.list.d/nodesource.list", owner: root, group: root }
|
||||||
- ansible.builtin.meta: flush_handlers
|
- { src: "nodejs-apt-pref", dest: "/etc/apt/preferences.d/nodejs", owner: root, group: root }
|
||||||
|
|
||||||
- name: Install nodejs
|
- name: Install nodejs
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
|
@ -56,7 +63,7 @@
|
||||||
|
|
||||||
- name: Copy patch
|
- name: Copy patch
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: thelounge-bitlair.patch
|
src: thelounge-bitlair.patch
|
||||||
dest: /tmp/thelounge-bitlair.patch
|
dest: /tmp/thelounge-bitlair.patch
|
||||||
|
|
||||||
- name: Apply patch
|
- name: Apply patch
|
||||||
|
@ -69,16 +76,17 @@
|
||||||
ansible.builtin.shell:
|
ansible.builtin.shell:
|
||||||
chdir: /opt/thelounge
|
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
|
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
|
- name: Ensure user thelounge is present
|
||||||
user:
|
ansible.builtin.user:
|
||||||
name: thelounge
|
name: thelounge
|
||||||
createhome: no
|
createhome: no
|
||||||
comment: The Lounge (IRC client)
|
comment: The Lounge (IRC client)
|
||||||
system: yes
|
system: yes
|
||||||
state: present
|
state: present
|
||||||
become: yes
|
|
||||||
|
|
||||||
- name: Ensure JS and JSON syntax checking packages are installed
|
- name: Ensure JS and JSON syntax checking packages are installed
|
||||||
yarn:
|
yarn:
|
||||||
name: "{{ item }}"
|
name: "{{ item }}"
|
||||||
|
@ -87,57 +95,18 @@
|
||||||
with_items:
|
with_items:
|
||||||
- esprima
|
- esprima
|
||||||
- jsonlint
|
- jsonlint
|
||||||
become: yes
|
|
||||||
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: Ensure thelounge configuration directory is present
|
- name: Configure templates
|
||||||
file:
|
|
||||||
path: /etc/thelounge
|
|
||||||
owner: thelounge
|
|
||||||
group: thelounge
|
|
||||||
state: directory
|
|
||||||
become: yes
|
|
||||||
|
|
||||||
- name: Ensure The Lounge is configured
|
|
||||||
template:
|
|
||||||
src: config.js.j2
|
|
||||||
dest: /etc/thelounge/config.js
|
|
||||||
owner: thelounge
|
|
||||||
group: thelounge
|
|
||||||
validate: 'esvalidate %s'
|
|
||||||
become: yes
|
|
||||||
|
|
||||||
- name: Ensure user configuration directory is present
|
|
||||||
file:
|
|
||||||
path: /var/local/thelounge/users
|
|
||||||
owner: thelounge
|
|
||||||
group: thelounge
|
|
||||||
state: directory
|
|
||||||
become: yes
|
|
||||||
|
|
||||||
- name: Ensure preview storage directory is present
|
|
||||||
file:
|
|
||||||
path: /var/local/thelounge/storage
|
|
||||||
owner: thelounge
|
|
||||||
group: thelounge
|
|
||||||
mode: "0770"
|
|
||||||
state: directory
|
|
||||||
become: yes
|
|
||||||
|
|
||||||
- name: Copy service file to systemd directory
|
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: thelounge.service # Path to your service file in your Ansible project
|
src: "{{ item.src }}"
|
||||||
dest: /etc/systemd/system/thelounge.service
|
dest: "{{ item.dest }}"
|
||||||
owner: root
|
owner: "{{ item.owner | default( 'thelounge' ) }}"
|
||||||
group: root
|
group: "{{ item.group | default( 'thelounge' ) }}"
|
||||||
mode: '0644'
|
mode: "{{ item.mode | default('0640') }}"
|
||||||
|
validate: "{{ item.validate | default([]) }}"
|
||||||
- name: Reload systemd daemon to read new service file
|
with_items:
|
||||||
ansible.builtin.systemd:
|
- { src: "config.js.j2", dest: "/etc/thelounge/config.js", validate: 'esvalidate %s' }
|
||||||
daemon_reload: yes
|
- { src: "thelounge.service", dest: "/etc/systemd/system/thelounge.service", owner: root, group: root, notify: "Reload systemd" }
|
||||||
|
notify: "{{ item.notify | default('Restart thelounge') }}"
|
||||||
|
|
||||||
- name: Enable and start the service
|
|
||||||
ansible.builtin.systemd:
|
|
||||||
name: thelounge
|
|
||||||
state: started
|
|
||||||
enabled: yes
|
|
|
@ -49,8 +49,8 @@ module.exports = {
|
||||||
url: "{{ thelounge_ldap_url }}",
|
url: "{{ thelounge_ldap_url }}",
|
||||||
primaryKey: "uid",
|
primaryKey: "uid",
|
||||||
searchDN: {
|
searchDN: {
|
||||||
rootDN: "{{ thelounge_ldap_rootDN }}",
|
rootDN: "{{ lookup('passwordstore', 'chat/thelounge/ldap_rootDN subkey=binddn') }}",
|
||||||
rootPassword: "{{ thelounge_ldap_rootPassword }}",
|
rootPassword: "{{ lookup('passwordstore', 'chat/thelounge/ldap_rootDN') }}",
|
||||||
filter: "{{ thelounge_ldap_filter }}",
|
filter: "{{ thelounge_ldap_filter }}",
|
||||||
base: "{{ thelounge_ldap_base }}",
|
base: "{{ thelounge_ldap_base }}",
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue