ansible-role-uptimekuma/tasks/install.yml

81 lines
2.0 KiB
YAML

---
- name: "Install | Configure git safe.directory"
ansible.builtin.command:
cmd: "git config --global --add safe.directory {{ uptimekuma_home }}"
- name: "install | Create group"
group:
name: "{{ uptimekuma_user }}"
state: present
- name: "install | create system account"
user:
name: "{{ uptimekuma_user }}"
group: "{{ uptimekuma_user }}"
home: "{{ uptimekuma_user_home }}"
shell: /bin/bash
password_lock: yes
system: yes
- name: "install | Check for latest version"
shell:
cmd: curl -sL "{{ uptimekuma_github_api_url }}" | jq -r ".tag_name"
changed_when: false
register: latest_version
- name: "install | Get Git Repository"
git:
repo: "{{ uptimekuma_git_url }}"
dest: "{{ uptimekuma_home }}"
version: "{{ latest_version.stdout }}"
force: yes
- name: "install | Copy version file (needed for update script)"
template:
src: version.j2
dest: "{{ uptimekuma_version_file }}"
owner: "{{ uptimekuma_user }}"
group: "{{ uptimekuma_user }}"
- name: "install | Change ownership"
file:
path: "{{ uptimekuma_home }}"
state: directory
owner: "{{ uptimekuma_user }}"
group: "{{ uptimekuma_user }}"
recurse: true
- name: "install | Install npm packages"
command:
cmd: npm run setup
chdir: "{{ uptimekuma_home }}"
become: true
become_user: "{{ uptimekuma_user }}"
notify: restart uptime-kuma
- name: "install | Copy systemd services file"
template:
src: uptime-kuma.service.j2
dest: "/etc/systemd/system/{{ uptimekuma_service }}"
notify: restart uptime-kuma
- name: "install | Enable systemd service"
systemd:
name: uptime-kuma
enabled: true
daemon_reload: true
state: started
- name: "install | Copy update script"
template:
src: uptime-kuma-updater.j2
dest: /usr/local/bin/uptime-kuma-updater
mode: "0755"
- name: "install | Add cron job for updates"
cron:
name: Update Uptime Kuma
job: uptime-kuma-updater upgrade
hour: "01"
minute: "30"