77 lines
2.4 KiB
YAML
77 lines
2.4 KiB
YAML
---
|
|
- name: Create uptime-kuma project directory
|
|
ansible.builtin.file:
|
|
path: "{{ podman_projects_dir | default('/opt/podman') }}/uptime-kuma"
|
|
state: directory
|
|
owner: "{{ ansible_user }}"
|
|
group: "{{ ansible_user }}"
|
|
mode: "0755"
|
|
|
|
- name: Create uptime-kuma data directory
|
|
ansible.builtin.file:
|
|
path: "{{ uptime_kuma_data_dir }}"
|
|
state: directory
|
|
owner: "{{ ansible_user }}"
|
|
group: "{{ ansible_user }}"
|
|
mode: "0755"
|
|
|
|
- name: Deploy Kubernetes YAML for uptime-kuma
|
|
ansible.builtin.template:
|
|
src: uptime-kuma.yaml.j2
|
|
dest: "{{ podman_projects_dir | default('/opt/podman') }}/uptime-kuma/uptime-kuma.yaml"
|
|
owner: "{{ ansible_user }}"
|
|
group: "{{ ansible_user }}"
|
|
mode: "0644"
|
|
notify: Restart uptime-kuma
|
|
|
|
- name: Get home directory for {{ ansible_user }}
|
|
ansible.builtin.getent:
|
|
database: passwd
|
|
key: "{{ ansible_user }}"
|
|
|
|
- name: Set user home directory fact
|
|
ansible.builtin.set_fact:
|
|
user_home_dir: "{{ getent_passwd[ansible_user][4] }}"
|
|
|
|
- name: Create systemd user directory for uptime-kuma
|
|
ansible.builtin.file:
|
|
path: "{{ user_home_dir }}/.config/systemd/user"
|
|
state: directory
|
|
owner: "{{ ansible_user }}"
|
|
group: "{{ ansible_user }}"
|
|
mode: "0755"
|
|
|
|
- name: Create systemd service for uptime-kuma (user scope)
|
|
ansible.builtin.template:
|
|
src: uptime-kuma.service.j2
|
|
dest: "{{ user_home_dir }}/.config/systemd/user/uptime-kuma.service"
|
|
owner: "{{ ansible_user }}"
|
|
group: "{{ ansible_user }}"
|
|
mode: "0644"
|
|
notify: Reload systemd user
|
|
|
|
- name: Enable lingering for user {{ ansible_user }}
|
|
ansible.builtin.command: "loginctl enable-linger {{ ansible_user }}"
|
|
when: ansible_user != 'root'
|
|
|
|
- name: Enable and start uptime-kuma service (user scope)
|
|
ansible.builtin.command: "systemctl --user enable --now uptime-kuma.service"
|
|
become_user: "{{ ansible_user }}"
|
|
|
|
- name: Deploy nginx vhost configuration for uptime-kuma
|
|
ansible.builtin.template:
|
|
src: nginx-vhost.conf.j2
|
|
dest: "{{ nginx_conf_dir | default('/etc/nginx/conf.d') }}/uptime-kuma.conf"
|
|
owner: root
|
|
group: root
|
|
mode: "0644"
|
|
when: uptime_kuma_nginx_enabled
|
|
notify: Reload nginx
|
|
|
|
- name: Remove nginx vhost configuration for uptime-kuma
|
|
ansible.builtin.file:
|
|
path: "{{ nginx_conf_dir | default('/etc/nginx/conf.d') }}/uptime-kuma.conf"
|
|
state: absent
|
|
when: not uptime_kuma_nginx_enabled
|
|
notify: Reload nginx
|