Inital commit

This commit is contained in:
phil 2023-05-14 20:05:12 +02:00
commit fd5c78edb4
11 changed files with 245 additions and 0 deletions

80
tasks/install.yml Normal file
View file

@ -0,0 +1,80 @@
---
- 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"

6
tasks/main.yml Normal file
View file

@ -0,0 +1,6 @@
---
- import_tasks: packages.yml
tags: packages
- import_tasks: install.yml
tags: install

19
tasks/packages.yml Normal file
View file

@ -0,0 +1,19 @@
---
- name: "packages | Add nodesource apt key"
apt_key:
url: https://deb.nodesource.com/gpgkey/nodesource.gpg.key
keyring: /etc/apt/trusted.gpg.d/nodesource.gpg
- name: "packages | Add nodesource repository"
apt_repository:
repo: "deb https://deb.nodesource.com/node_14.x {{ ansible_distribution_release }} main"
state: present
- name: "packages | Install apt packages"
apt:
default_release: "{{ ansible_distribution_release }}-backports"
state: latest
pkg:
- nodejs