commit 928d49870647f93bb441b0b657c340f198b11780 Author: Justin Date: Thu Jan 23 00:51:55 2025 +0000 first commit diff --git a/config-add-sshkey.yaml b/config-add-sshkey.yaml new file mode 100644 index 0000000..6c39626 --- /dev/null +++ b/config-add-sshkey.yaml @@ -0,0 +1,23 @@ +--- +- name: Add ssh key + hosts: "killer1" + become: true + + tasks: + - name: create id_rsa + file: + path: "~/.ssh/id_rsa.pub" + state: touch + - name: Install public keys + ansible.posix.authorized_key: + user: "{{ lookup('env', 'USER') }}" + state: present + key: "/root/.ssh/id_rsa.pub" + + - name: Change sudoers file + ansible.builtin.lineinfile: + path: /etc/sudoers + state: present + regexp: '^%sudo' + line: '%sudo ALL=(ALL) NOPASSWD: ALL' + validate: /usr/sbin/visudo -cf %s diff --git a/maint-diskspace.yaml b/maint-diskspace.yaml new file mode 100644 index 0000000..7ad47d1 --- /dev/null +++ b/maint-diskspace.yaml @@ -0,0 +1,32 @@ +--- +- name: Check disk space + hosts: "all" + + tasks: + - name: Check disk space available + ansible.builtin.shell: + cmd: | + set -euo pipefail + df -Ph / | awk 'NR==2 {print $5}' + executable: /bin/bash + changed_when: false + check_mode: false + register: disk_usage + + - name: Diskspace is over 80% + ansible.builtin.debug: + msg: "Disk is over 80%" + when: disk_usage.stdout[:-1]|int>80 + + - name: Posting + ntfy: + msg: '{"content": "Disk space on {{ inventory_hostname }} is above 80%!"}' + topic: "admin-alerts" + attrs: + priority: 4 + actions: + - action: view + label: "Open Mastodon" + url: "ntfy.ki5bhv.com/server" + when: disk_usage.stdout[:-1]|int>80 + diff --git a/maint-reboot-required.yaml b/maint-reboot-required.yaml new file mode 100644 index 0000000..ecbf217 --- /dev/null +++ b/maint-reboot-required.yaml @@ -0,0 +1,16 @@ +--- +- name: Check if system reboot is required + hosts: "all" + become: true + + tasks: + - name: Check if system reboot is required + become: true + ansible.builtin.stat: + path: /run/reboot-required + register: reboot_required + + - name: Report if reboot is required + ansible.builtin.debug: + msg: "Reboot is required" + when: reboot_required.stat.exists diff --git a/plex.yaml b/plex.yaml new file mode 100644 index 0000000..dd50504 --- /dev/null +++ b/plex.yaml @@ -0,0 +1,11 @@ +--- +- name: Update Plex Sever + hosts: killer1 + become: yes + + tasks: + - name: Ensure Plex is at the latest version + apt: + update_cache: yes + name: plexmediaserver + state: latest diff --git a/update.yaml b/update.yaml new file mode 100644 index 0000000..413d174 --- /dev/null +++ b/update.yaml @@ -0,0 +1,74 @@ +--- +- name: Send Start update + hosts: localhost + + tasks: + - name: send ntfy + ansible.builtin.command: + cmd: 'curl -d "Starting updating with ansible" ntfy.ki5bhv.com/server' + +- name: Proxmox Update and upgrade apt packages + hosts: proxmox + become: yes + + tasks: + - name: Update packages with apt + when: ansible_pkg_mgr == 'apt' + ansible.builtin.apt: + update_cache: true + + - name: Installing proxmox guest agent + when: ansible_pkg_mgr == 'apt' + ansible.builtin.apt: + name: qemu-guest-agent + state: latest + + - name: Enable proxmox agent + ansible.builtin.command: + cmd: systemctl enable qemu-guest-agent + + - name: Restart proxmox agent + ansible.builtin.command: + cmd: systemctl restart qemu-guest-agent + + + - name: Upgrade packages with apt + when: ansible_pkg_mgr == 'apt' + ansible.builtin.apt: + upgrade: dist + + - name: Clean up packages with apt + when: ansible_pkg_mgr == 'apt' + ansible.builtin.apt: + autoclean: true + autoremove: true + +- name: Hardware Update and upgrade apt packages + hosts: hardware + become: yes + + tasks: + - name: Update packages with apt + when: ansible_pkg_mgr == 'apt' + ansible.builtin.apt: + update_cache: true + + + - name: Upgrade packages with apt + when: ansible_pkg_mgr == 'apt' + ansible.builtin.apt: + upgrade: dist + + - name: Clean up packages with apt + when: ansible_pkg_mgr == 'apt' + ansible.builtin.apt: + autoclean: true + autoremove: true + +- name: Send completed update + hosts: localhost + + tasks: + - name: send ntfy + ansible.builtin.command: + cmd: 'curl -d "Updated with ansible" ntfy.ki5bhv.com/server'