This blog post Will show you how to update all software packages on an Ubuntu server using an Ansible playbook without rebooting the server.
Managing Windows systems with Ansible involves utilizing Ansible’s robust automation capabilities to streamline the administration and configuration of Windows environments.
By leveraging Ansible modules specifically designed for Windows, such as win_command, win_copy, and win_feature, administrators can execute commands, transfer files, and manage Windows features efficiently.
Ansible’s agentless architecture simplifies deployment, requiring only WinRM (Windows Remote Management) to be enabled on target machines.
Through playbooks, which are YAML-based files defining tasks and configurations, administrators can automate repetitive tasks, enforce configuration consistency, and ensure compliance across Windows servers and workstations, thus enhancing operational efficiency and reducing the risk of manual errors.
Apt Module
By default, Ansible comes with the Apt module which allows us to update packages on Ubuntu servers. The module is capable of doing the same things as running the apt command directly on a server.
Inventory file
Below is my inventory file and host vars for the host login configuration. The options are very important, and In my case, I am using the following:
You can also see that I am using SSH authentication to connect to my managed hosts.
[servers] 192.168.100.1 [servers:vars] ansible_private_key_file=/home/user/.ssh/id_rsa ansible_user=admin ansible_become=yes ansible_become_method=sudo ansible_python_interpreter='/usr/bin/python3'
Update All Packages on Ubuntu Server With Ansible
The following playbook will install all the available packages on the managed hosts without restarting them.
- hosts: servers tasks: - name: Update cache apt: update_cache: yes - name: Upgrade all packages on servers apt: name: "*" state: latest
To run the playbook, I will use the following command.
sudo ansible-playbook playbooks/update-ubuntu.yml -i hosts