ansible-infra/roles/mumble/tasks/mumble_web.yml

77 lines
2.0 KiB
YAML

- name: Install websockify
apt:
name: websockify
state: present
notify: restart mumble-web
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 }}"
tags: mumble_web_install
- name: Change mumble-web git repository's permissions
file:
path: "{{ mumble_web_www_dir }}"
owner: root
group: www-data
mode: "755"
state: directory
tags: mumble_web_install
- name: Build mumble-web from sources
command: npm install
args:
chdir: "{{ mumble_web_www_dir }}"
register: _mumble_web_installed
changed_when: _mumble_web_installed.stdout is regex('(added|removed) [0-9]+ package')
tags: [mumble_web_install,mumble_web_build]
- name: Apply security suggestions
command: npm audit fix
args:
chdir: "{{ mumble_web_www_dir }}"
when: _mumble_web_installed is changed and _mumble_web_installed.stdout is search('npm audit fix')
tags: [mumble_web_install,mumble_web_build]
- name: Build mumble-web assets
command: npm run build
args:
chdir: "{{ mumble_web_www_dir }}"
register: _mumble_web_assets_built
when: _mumble_web_installed is changed
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: root
group: www-data
mode: "640"
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
- restart 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