replace systemd user tasks with separated role
This commit is contained in:
@@ -14,6 +14,7 @@ and makes sure all requirements and systemd jobs are set up properly.
|
||||
## Requirements
|
||||
|
||||
* [ansible-role-users](https://src.mehl.mx/mxmehl/ansible-role-users)
|
||||
* [ansible-role-systemd-user](https://src.mehl.mx/mxmehl/ansible-role-systemd-user)
|
||||
|
||||
## Configure
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
name:
|
||||
- moreutils # chronic
|
||||
- pipx
|
||||
- systemd-container # necessary to use machinectl become_method
|
||||
- seafile-cli
|
||||
become: false # need to do this as root
|
||||
|
||||
@@ -63,18 +62,6 @@
|
||||
month: "{{ seafile_cron.month }}"
|
||||
weekday: "{{ seafile_cron.weekday }}"
|
||||
|
||||
- name: Ensure user systemd directory exists
|
||||
file:
|
||||
path: "{{ seafile_local_user_info.home }}/.config/systemd/user/"
|
||||
state: directory
|
||||
mode: "0755"
|
||||
|
||||
- name: Ensure systemd service file is present
|
||||
template:
|
||||
src: seaf-daemon.service.j2
|
||||
dest: "{{ seafile_local_user_info.home }}/.config/systemd/user/seaf-daemon.service"
|
||||
mode: "0644"
|
||||
|
||||
- name: Ensure Seafile config dir exists
|
||||
file:
|
||||
path: "{{ seafile_local_user_info.home }}/config"
|
||||
@@ -87,22 +74,11 @@
|
||||
register: result
|
||||
changed_when: '"already exists" not in result.stdout'
|
||||
|
||||
- name: "Check whether user is lingering: {{ seafile_local_user.user }}"
|
||||
stat:
|
||||
path: "/var/lib/systemd/linger/{{ seafile_local_user.user }}"
|
||||
register: seafile_local_user_lingering
|
||||
|
||||
- name: Ensure systemd lingering is enabled for user {{ seafile_local_user.user }}
|
||||
command: loginctl enable-linger {{ seafile_local_user.user }}
|
||||
become: false
|
||||
changed_when: false
|
||||
when: not seafile_local_user_lingering.stat.exists
|
||||
|
||||
- name: Ensure systemd service is running and enabled
|
||||
systemd:
|
||||
name: seaf-daemon
|
||||
state: started
|
||||
enabled: true
|
||||
daemon_reload: true
|
||||
scope: user
|
||||
become_method: community.general.machinectl # in order to get XDG_RUNTIME_DIR and user's DBUS session
|
||||
- name: Setup systemd user service
|
||||
include_role:
|
||||
name: systemd-user
|
||||
apply:
|
||||
become: false
|
||||
vars:
|
||||
user: "{{ seafile_local_user.user }}"
|
||||
service: seaf-daemon
|
||||
|
||||
Reference in New Issue
Block a user