--- - name: Install global dependencies apt: name: - git - 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 attributes: '+i' 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 }}" - name: Create config directory file: path: "{{ item.value.git_config_folder }}" state: directory become: yes become_user: "{{ item.value.user }}" with_dict: - "{{ xrdp_applications }}" - name: Create git repo for configs command: git init {{ item.value.git_config_folder }} become: yes become_user: "{{ item.value.user }}" args: creates: "{{ item.value.git_config_folder }}/.git" with_dict: - "{{ xrdp_applications }}" - name: Setup git user names git_config: name: user.name scope: global value: "{{ item.value.user }}" become: yes become_user: "{{ item.value.user }}" with_dict: - "{{ xrdp_applications }}" - name: Setup git E-Mail git_config: name: user.email scope: global value: "{{ item.value.user }}@{{ inventory_hostname }}" become: yes become_user: "{{ item.value.user }}" with_dict: - "{{ xrdp_applications }}" - name: Create config git commit cron cron: name: "Add and commit all changes" minute: "5" hour: "5" job: "cd {{ item.value.git_config_folder }} && git add -A && git commit -m 'Commit via cronjob'" user: "{{ item.value.user }}" with_dict: - "{{ xrdp_applications }}"