setup systemd
This commit is contained in:
parent
b5aa38be55
commit
df1313efe6
7
files/main.yml
Normal file
7
files/main.yml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
- name: Restart unifi service
|
||||||
|
systemd:
|
||||||
|
state: restarted
|
||||||
|
daemon_reload: yes
|
||||||
|
name: unifi
|
||||||
|
listen: __unifi_restart
|
@ -49,6 +49,7 @@
|
|||||||
src: "{{ unifi_base_dir }}/{{ unifi_version }}"
|
src: "{{ unifi_base_dir }}/{{ unifi_version }}"
|
||||||
dest: "{{ unifi_base_dir }}/latest"
|
dest: "{{ unifi_base_dir }}/latest"
|
||||||
state: link
|
state: link
|
||||||
|
notify: __unifi_restart
|
||||||
|
|
||||||
- name: Cleanup
|
- name: Cleanup
|
||||||
file:
|
file:
|
||||||
@ -56,3 +57,20 @@
|
|||||||
state: absent
|
state: absent
|
||||||
become: True
|
become: True
|
||||||
become_user: "{{ unifi_user }}"
|
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
|
||||||
|
18
templates/etc/systemd/system/unifi.service.j2
Normal file
18
templates/etc/systemd/system/unifi.service.j2
Normal 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
|
Loading…
Reference in New Issue
Block a user