How to Install a package with Ansible in Debian-like systems?
I’m going to show you a live Playbook with some simple Ansible code. I’m Luca Berton and welcome to today’s episode of Ansible Pilot
Ansible Install a package in Debian-like systems
Today we’re talking about the Ansible module APT. The full name is “ansible.builtin.apt” which means is part of the collection of modules “builtin” with ansible and shipped with it. This module is pretty stable and out for years. It works on Debian-like operating systems and Manages packages with the apt package manager. It’s similar to the yum or DNF module for RedHat-like operating systems.
Main Parameters
- name string
- state string
- update_cache boolean
The parameter list is pretty wide but this three are the most important options. In the “name” parameter you are going to specify the name of the package or the specific version you would like to install. The state specifies the action that we would like to perform. In our case for install is “present”. “update_cache” forces to update the repository metadata before the installation. It could be useful to make sure that the repository is up-to-date.
Demo
Let’s jump in a real-life playbook to install a package in Debian-like systems with Ansible
---
- name: module apt Playbook
hosts: all
become: true
tasks:
- name: install package
apt:
name: curl
state: present
Conclusion
Now you know how to install a package and a specific version of a package in Debian-like systems. Subscribe to the YouTube channel, Medium, and Website, X (formerly Twitter) to not miss the next episode of the Ansible Pilot.
Academy
Learn the Ansible automation technology with some real-life examples in my Udemy 300+ Lessons Video Course.
My book Ansible By Examples: 200+ Automation Examples For Linux and Windows System Administrator and DevOps
Donate
Want to keep this project going? Please donate