From a1a30915076e975c73430bdb1dd28514da054420 Mon Sep 17 00:00:00 2001 From: Thomas Basler Date: Sun, 9 Jan 2022 19:11:56 +0100 Subject: [PATCH] xrdp_apphost: Consolidate common application tasks This commit consolidates common tasks like user creation which is needed by all applications into a single file. --- roles/xrdp_apphost/tasks/app_common.yml | 51 +++++++++++++++++++++++++ roles/xrdp_apphost/tasks/estlcam.yml | 20 ---------- roles/xrdp_apphost/tasks/lightburn.yml | 20 ---------- roles/xrdp_apphost/tasks/main.yml | 26 ++----------- roles/xrdp_apphost/tasks/slicer.yml | 20 ---------- 5 files changed, 54 insertions(+), 83 deletions(-) create mode 100644 roles/xrdp_apphost/tasks/app_common.yml diff --git a/roles/xrdp_apphost/tasks/app_common.yml b/roles/xrdp_apphost/tasks/app_common.yml new file mode 100644 index 0000000..3d2c43b --- /dev/null +++ b/roles/xrdp_apphost/tasks/app_common.yml @@ -0,0 +1,51 @@ +--- + +- name: Create Application groups + group: name={{ item.value.group }} + with_dict: + - "{{ xrdp_applications }}" + +- name: Create Application users + user: name={{ item.value.user }} password={{ item.value.pass | password_hash('sha512', item.value.salt) }} home=/home/{{ item.value.user }} group={{ item.value.group }} + with_dict: + - "{{ xrdp_applications }}" + +- name: Create Application .xsession + template: src={{ item.value.user }}_xsession.j2 dest=/home/{{ item.value.user }}/.xsession + with_dict: + - "{{ xrdp_applications }}" + +- name: Create Application data directories + file: path=/home/{{ item.value.user }}/data state=directory mode=0755 owner={{ item.value.user }} group={{ item.value.group }} + with_dict: + - "{{ xrdp_applications }}" + +- name: Create info directory + file: + path: "/home/{{ item.value.user }}/data/{{ info_folder_name }}" + state: directory + mode: 0444 + owner: root + group: root + with_dict: + - "{{ xrdp_applications }}" + +- name: Create file cleanup cron + cron: + name: "Delete files older than 30 days" + minute: "0" + hour: "5" + job: "find /home/{{ item.value.user }}/data -type f -mtime +30 ! -name \"{{ info_folder_name }}\" -delete" + user: "{{ item.value.user }}" + with_dict: + - "{{ xrdp_applications }}" + +- name: Create directory cleanup cron + cron: + name: "Delete empty directories" + minute: "1" + hour: "5" + job: "find /home/{{ item.value.user }}/data -type d -empty ! -name \"{{ info_folder_name }}\" -delete" + user: "{{ item.value.user }}" + with_dict: + - "{{ xrdp_applications }}" diff --git a/roles/xrdp_apphost/tasks/estlcam.yml b/roles/xrdp_apphost/tasks/estlcam.yml index 96738ba..8f2b28a 100644 --- a/roles/xrdp_apphost/tasks/estlcam.yml +++ b/roles/xrdp_apphost/tasks/estlcam.yml @@ -22,23 +22,3 @@ - winetricks - wine32 - xfwm4 - -- name: Create Estlcam group - group: name={{ xrdp_applications.Estlcam.group }} - -- name: Create Estlcam user - user: name={{ xrdp_applications.Estlcam.user }} password={{ xrdp_applications.Estlcam.pass | password_hash('sha512', xrdp_applications.Estlcam.salt) }} home=/home/{{ xrdp_applications.Estlcam.user }} group={{ xrdp_applications.Estlcam.group }} - -- name: Create Estlcam .xsession - template: src=estlcam_xsession.j2 dest=/home/{{ xrdp_applications.Estlcam.user }}/.xsession - -- name: Create Estlcam data directory - file: path=/home/{{ xrdp_applications.Estlcam.user }}/data state=directory mode=0755 owner={{ xrdp_applications.Estlcam.user }} group={{ xrdp_applications.Estlcam.group }} - -- name: Create info directory - file: - path: "/home/{{ xrdp_applications.Estlcam.user }}/data/{{ info_folder_name }}" - state: directory - mode: 0444 - owner: root - group: root \ No newline at end of file diff --git a/roles/xrdp_apphost/tasks/lightburn.yml b/roles/xrdp_apphost/tasks/lightburn.yml index 2b99598..cf36973 100644 --- a/roles/xrdp_apphost/tasks/lightburn.yml +++ b/roles/xrdp_apphost/tasks/lightburn.yml @@ -6,26 +6,6 @@ - libpulse-mainloop-glib0 - libnss3 -- name: Create LightBurn group - group: name={{ xrdp_applications.LightBurn.group }} - -- name: Create LightBurn user - user: name={{ xrdp_applications.LightBurn.user }} password={{ xrdp_applications.LightBurn.pass | password_hash('sha512', xrdp_applications.LightBurn.salt) }} home=/home/{{ xrdp_applications.LightBurn.user }} group={{ xrdp_applications.LightBurn.group }} - -- name: Create LightBurn .xsession - template: src=lightburn_xsession.j2 dest=/home/{{ xrdp_applications.LightBurn.user }}/.xsession - -- name: Create LightBurn data directory - file: path=/home/{{ xrdp_applications.LightBurn.user }}/data state=directory mode=0755 owner={{ xrdp_applications.LightBurn.user }} group={{ xrdp_applications.LightBurn.group }} - -- name: Create info directory - file: - path: "/home/{{ xrdp_applications.LightBurn.user }}/data/{{ info_folder_name }}" - state: directory - mode: 0444 - owner: root - group: root - - name: Download LightBurn binary get_url: url={{ lightburn_url }} dest={{ lightburn_target }} checksum={{ xrdp_applications.LightBurn.checksum }} mode=0755 notify: Install LightBurn \ No newline at end of file diff --git a/roles/xrdp_apphost/tasks/main.yml b/roles/xrdp_apphost/tasks/main.yml index 9a2f560..41f92f7 100644 --- a/roles/xrdp_apphost/tasks/main.yml +++ b/roles/xrdp_apphost/tasks/main.yml @@ -7,13 +7,13 @@ line: "UMASK 027" state: present - - include: xrdp.yml +- include: app_common.yml +- include: samba.yml + - include: lightburn.yml - include: estlcam.yml - include: slicer.yml -- include: samba.yml - - name: Create tsadmin group group: name={{ tsadmin_group }} @@ -33,23 +33,3 @@ - name: Create tsadmin_user .xsession template: src=tsadmin_xsession.j2 dest=/home/{{ tsadmin_user }}/.xsession - -- name: Create file cleanup cron - cron: - name: "Delete files older than 30 days" - minute: "0" - hour: "5" - job: "find /home/{{ item.value.user }}/data -type f -mtime +30 ! -name \"{{ info_folder_name }}\" -delete" - user: "{{ item.value.user }}" - with_dict: - - "{{ xrdp_applications }}" - -- name: Create directory cleanup cron - cron: - name: "Delete empty directories" - minute: "1" - hour: "5" - job: "find /home/{{ item.value.user }}/data -type d -empty ! -name \"{{ info_folder_name }}\" -delete" - user: "{{ item.value.user }}" - with_dict: - - "{{ xrdp_applications }}" diff --git a/roles/xrdp_apphost/tasks/slicer.yml b/roles/xrdp_apphost/tasks/slicer.yml index 86ce467..d3c0af5 100644 --- a/roles/xrdp_apphost/tasks/slicer.yml +++ b/roles/xrdp_apphost/tasks/slicer.yml @@ -5,25 +5,5 @@ name: - libgtk2.0-0 -- name: Create Slic3r group - group: name={{ xrdp_applications.Slicer.group }} - -- name: Create Slic3r user - user: name={{ xrdp_applications.Slicer.user }} password={{ xrdp_applications.Slicer.pass | password_hash('sha512', xrdp_applications.Slicer.salt) }} home=/home/{{ xrdp_applications.Slicer.user }} group={{ xrdp_applications.Slicer.group }} - -- name: Create Slic3r .xsession - template: src=slicer_xsession.j2 dest=/home/{{ xrdp_applications.Slicer.user }}/.xsession - -- name: Create Slic3r data directory - file: path=/home/{{ xrdp_applications.Slicer.user }}/data state=directory mode=0755 owner={{ xrdp_applications.Slicer.user }} group={{ xrdp_applications.Slicer.group }} - -- name: Create info directory - file: - path: "/home/{{ xrdp_applications.Slicer.user }}/data/{{ info_folder_name }}" - state: directory - mode: 0444 - owner: root - group: root - - name: Download Slic3r binary get_url: url={{ slicer_url }} dest={{ slicer_target }} checksum={{ xrdp_applications.Slicer.checksum }} mode=0755