ansible-ppm/roles/ppm/tasks/oneapp.yml
2024-10-16 21:13:17 +02:00

36 lines
1.4 KiB
YAML

- name: "Create user ({{ ppm_app.user }})"
ansible.builtin.user:
name: "{{ ppm_app.user }}"
shell: /bin/bash
register: ppm_app_user
# Enabling linger will make systemd start the user-systemd for this user at bootup time
# Enabling this will allow us to run programs automatically and independently of any user login
- name: "Linger user ({{ ppm_app.user }})"
ansible.builtin.command:
cmd: "loginctl enable-linger {{ ppm_app_user.name }}"
creates: "/var/lib/systemd/linger/{{ ppm_app_user.name }}"
- name: "Ensure we have a XDG_RUNTIME_DIR variable ({{ ppm_app.user }})"
ansible.builtin.lineinfile:
dest: "{{ ppm_app_user.home }}/.bashrc"
state: present
line: "export XDG_RUNTIME_DIR=/run/user/$(id -u)"
regexp: ^export XDG_RUNTIME_DIR=
- name: "Place configuration ({{ ppm_app.user }})"
ansible.builtin.copy:
content: "{{ ppm_app.appconfig | dict2items | selectattr('key', 'ne', 'code') | items2dict | to_nice_yaml }}"
dest: "{{ ppm_app_user.home }}/config.yml"
owner: "{{ ppm_app_user.name }}"
group: "{{ ppm_app_user.group }}"
mode: "0600"
- name: "See if app definition exists ({{ ppm_app.user }})"
ansible.builtin.stat:
path: "{{ ppm_app_user.home }}/appdefinition"
register: appdefinition
- name: "Bootstrap the app definition ({{ ppm_app.user }})"
ansible.builtin.include_tasks: copyappdef.yml
when: ppm_app.chicken_egg_appdefinition is defined and not appdefinition.stat.exists