ansible-role-mumble/tasks/mumble_web.yml

94 lines
2.2 KiB
YAML

- name: Install NodeJS
import_role:
name: geerlingguy.nodejs
tags: nodejs
- name: Install git package
package:
name: git
state: present
tags: mumble_web_install
- name: Install websockify
package:
name: websockify
state: present
notify: reload mumble-web
tags: mumble_web_install
- name: Create mumble-web system user
user:
name: "{{ mumble_web_owner }}"
home: "{{ mumble_web_www_dir }}"
groups:
- www-data
shell: /sbin/nologin
password: '*'
state: present
system: yes
append: yes
create_home: no
- name: Change mumble-web home directory's permissions
file:
path: "{{ mumble_web_www_dir }}"
owner: "{{ mumble_web_owner }}"
group: "{{ mumble_web_group }}"
mode: "755"
state: directory
tags: mumble_web_install
- name: Clone mumble-web git repository
git:
repo: https://github.com/Johni0702/mumble-web.git
dest: "{{ mumble_web_www_dir }}"
version: "{{ mumble_web_version }}"
register: mumble_web_cloned
become_user: "{{ mumble_web_owner }}"
tags: mumble_web_install
- name: Check if mumble-web dist directory exists
stat:
path: "{{ mumble_web_www_dir }}/dist"
register: _mumble_web_dist
- name: Build mumble-web from sources
command: npm clean-install
args:
chdir: "{{ mumble_web_www_dir }}"
register: _mumble_web_installed
become_user: "{{ mumble_web_owner }}"
when: mumble_web_cloned is changed or not _mumble_web_dist.stat.exists
tags: [mumble_web_install,mumble_web_build]
- name: Copy mumble-web config file
template:
src: mumble-web.js.j2
dest: "{{ mumble_web_www_dir }}/dist/config.local.js"
owner: "{{ mumble_web_owner }}"
group: "{{ mumble_web_group }}"
mode: "644"
tags: [mumble_web_install,mumble_web_config]
- name: Copy mumble-web systemd service
template:
src: mumble-web.service.j2
dest: /etc/systemd/system/mumble-web.service
owner: root
group: root
mode: "644"
notify:
- reload systemd
- reload mumble-web
tags: [mumble_web_install,mumble_web_config]
- name: Start mumble-web service
service:
name: mumble-web
state: started
enabled: yes
register: mumble_web_started
tags: mumble_web_run
- name: Trigger mumble-web handlers
meta: flush_handlers