Loading...

Watch: 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 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

``yaml

---

  • name: module apt Playbook

hosts: all

become: true

tasks:

- name: install package

apt:

name: curl

state: present

``

[code with ❤️ in GitHub](https://github.com/lucab85/ansible-pilot/tree/master/install%20a%20package%20in%20Debian-like%20systems)

Conclusion

Now you know how to install a package and a specific version of a package in Debian-like systems.

Read the full tutorial: Install a package in Debian-like systems - Ansible module apt