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

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, Website and Twitter to not miss the next episode of the Ansible Pilot.

Academy

Learn the Ansible automation technology with some real-life examples in my

Want to keep this project going? Please donate

Trustpilot
Follow me

Subscribe not to miss any new releases

August 6, 2021

FREE Top 10 Best Practices

Top 10 Best Practices of Ansible Automation: save time, reduce errors and stress