Ansible Pilot

Install a package in Debian-like systems - Ansible module apt

Some real-life examples of how to install a package in Debian-like systems: Debian, Ubuntu, Linux Mint, MX Linux, Deepin, AntiX, PureOS, Kali Linux, Parrot OS, Devuan, Knoppix, AV Linux Linux

August 6, 2021
Access the Complete Video Course and Learn Quick Ansible by 200+ Practical Lessons

How to Install a package with Ansible in Debian-like systems?

I’m going to show you a live demo 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

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 demo
  hosts: all
  become: true
  tasks:
    - name: install package
      apt:
        name: curl
        state: present

code with ❤️ in GitHub

Recap

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

My book Ansible By Examples: 200+ Automation Examples For Linux and Windows System Administrator and DevOps

BUY the Complete PDF BOOK to easily Copy and Paste the 250+ Ansible code

Want to keep this project going? Please donate

Access the Complete Video Course and Learn Quick Ansible by 200+ Practical Lessons
Follow me

Subscribe not to miss any new releases