setup systemd

This commit is contained in:
Robert Kaussow 2018-07-08 23:02:55 +02:00
parent b5aa38be55
commit df1313efe6
3 changed files with 43 additions and 0 deletions

7
files/main.yml Normal file
View File

@ -0,0 +1,7 @@
---
- name: Restart unifi service
systemd:
state: restarted
daemon_reload: yes
name: unifi
listen: __unifi_restart

View File

@ -49,6 +49,7 @@
src: "{{ unifi_base_dir }}/{{ unifi_version }}"
dest: "{{ unifi_base_dir }}/latest"
state: link
notify: __unifi_restart
- name: Cleanup
file:
@ -56,3 +57,20 @@
state: absent
become: True
become_user: "{{ unifi_user }}"
- block:
- name: Create systemd unit files
template:
src: "etc/systemd/system/unifi.service.j2"
dest: "/etc/systemd/system/unifi.service"
mode: 0644
notify:
- __unifi_restart
- name: Ensure service is up and running
systemd:
state: started
daemon_reload: yes
enabled: yes
name: unifi
become: True

View File

@ -0,0 +1,18 @@
## {{ ansible_managed }}
# Systemd unit file for UniFi Controller
[Unit]
Description=UniFi Controller
Wants=mongod.service
After=syslog.target network.target
[Service]
ExecStart=/usr/bin/java -Xmx1024M -jar {{ unifi_base_dir }}/latest/UniFi/lib/ace.jar start
ExecStop=/usr/bin/java -jar {{ unifi_base_dir }}/latest/UniFi/lib/ace.jar stop
Type=simple
User={{ unifi_user }}
WorkingDirectory={{ unifi_base_dir }}
SuccessExitStatus=143
[Install]
WantedBy=multi-user.target