Member-only story

Ansible Modules you should know as a DevOps Engineer

Yogesh
5 min readDec 25, 2024

--

Ansible is a powerful open-source automation tool that allows you to manage servers, networks, and applications effortlessly. But with hundreds of Ansible modules available, it’s easy to feel overwhelmed. Which ones do you really need for your day-to-day tasks? In this article, we’ll cover the key Ansible modules that form the backbone of most common automation playbooks.

1. Package Management

One of the first tasks you’ll perform is installing and updating packages on your systems.

  • Modules: apt, yum, dnf, package
  • Use Cases: Installing, updating, or removing system packages.
- name: Install latest version of nginx
apt:
name: nginx
state: latest
become: yes

Tip: Use apt for Debian/Ubuntu, yum or dnf for RHEL-based systems, or package for a more generic approach.

2. Service Management

Keeping services running and enabled at boot is critical.

  • Modules: service, systemd
  • Use Cases: Starting, stopping, restarting, and enabling services at boot.
- name: Ensure nginx is running and enabled
service:
name: nginx
state: started
enabled: yes

When to choose service vs. systemd?

  • Use service for broad compatibility across init systems.
  • Use systemd when you…

--

--

No responses yet