first commit
This commit is contained in:
commit
928d498706
|
@ -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
|
|
@ -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
|
||||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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'
|
Loading…
Reference in New Issue