Get time back, update all your Linux distribution in one command line
Easy peasy, let's use Ansible to make the work for us !
To install Ansible, take a peek at our earlier post right here.
Create your inventory host file with the list of your Linux :
[linux]
10.0.4.26
10.0.4.28
10.0.4.6
10.0.4.63
10.0.4.49
10.0.4.3
10.0.5.135
[pihole]
192.168.1.253
10.0.5.146
[proxmox]
10.0.5.130
10.0.5.131
10.0.5.132
[deployacronis]
10.0.4.64
10.0.4.36
Then whip up your new playbook using the YAML file below :
- hosts: all
become: yes
tasks:
# This task updates servers that use 'yum' and RPM packages
- name: .rpm upgrade server
yum: >
update_cache=yes
name=*
state=latest
update_cache=yes
when: >
ansible_distribution == 'CentOS'
or
ansible_distribution == 'RedHat'
# This task updates servers that use 'apt' and DEB packages
- name: .deb do safe-upgrade
apt: >
update_cache=yes
cache_valid_time=1200
upgrade=safe
when: >
ansible_distribution == 'Debian'
or
ansible_distribution == 'Ubuntu'
the playbook apply to all by the <hosts: all> at line 1.
How about a more selective approach? Something like <hosts: "deployacronis">
Then off you go, Ansible, my trusty minion—handle the work for me!
sudo ansible-playbook playbooks/update-linux.yml --key-file "/home/greg/ansible/id_rsa" --user=greg --ask-become-pass --ssh-common-args='-o StrictHostKeyChecking=no'
Want to have more details about command args ? then check our previous post about Ansible here.