Ansible
Add VPS to Ansible config in /etc/ansible/hosts:
[ovh]
ovh1 ansible_host=54.37.205.80
ovh2 ansible_host=144.217.13.168
ovh3 ansible_host=51.38.128.6
ovh4 ansible_host=51.255.48.204
ovh5 ansible_host=51.38.131.212
ovh6 ansible_host=146.59.80.103
[contabo]
contabo2 ansible_host=161.97.84.6
contabo4 ansible_host=173.212.237.88
contabo5 ansible_host=144.91.118.192
[greencloud]
green1 ansible_host=188.215.229.63
green2 ansible_host=64.44.168.71
[mvps]
mvps1 ansible_host=2.56.214.210
And create a updateservers.yaml playbook:
---
- hosts: all
become: yes
become_user: root
tasks:
- name: apt update && apt upgrade -y
apt:
upgrade: dist
update_cache: yes
force_apt_get: yes
- name: Check if reboot is needed
register: reboot_required_file
stat:
path: /var/run/reboot-required
get_md5: no
- name: Reboot if kernel updated
reboot:
msg: "Reboot initiated by Ansible for kernel updates"
connect_timeout: 5
reboot_timeout: 300
pre_reboot_delay: 0
post_reboot_delay: 30
test_command: uptime
when: reboot_required_file.stat.exists
Then run ansible-playbook updateservers.yaml --ask-become-pass and enter pass at prompt to have apt update, apt upgrade and if necessary, reboot run on all servers.