Services DevOps DevSecOps Cloud Consulting Infrastructure Automation Managed Services AIOps MLOps DataOps Microservices 🔐 Private AINEW Solutions DevOps Transformation CI/CD Automation Platform Engineering Security Automation Zero Trust Security Compliance Automation Cloud Migration Kubernetes Migration Cloud Cost Optimisation AI-Powered Operations Data Platform Modernisation SRE & Observability Legacy Modernisation Managed IT Services 🔐 Private AI DeploymentNEW Products ✨ ZippyOPS AINEW 🛡️ ArmorPlane 🔒 DevSecOpsAsService 🖥️ LabAsService 🤝 Collab 🧪 SandboxAsService 🎬 DemoAsService Bootcamp 🔄 DevOps Bootcamp ☁️ Cloud Engineering 🔒 DevSecOps 🛡️ Cloud Security ⚙️ Infrastructure Automation 📡 SRE & Observability 🤖 AIOps & MLOps 🧠 AI Engineering 🎓 ZOLS — Free Learning Company About Us Projects Careers Get in Touch

Ansible Yum Module: How to Install Apache with Playbooks

Ansible Yum Module: How to Install Apache with Playbooks

The Ansible Yum module is a powerful tool that allows system administrators to manage packages on RedHat-based systems. Using the Yum Package Manager, it facilitates tasks such as installing, updating, and removing packages across multiple nodes. In this article, we’ll walk through how to use the Ansible Yum module to install the Apache HTTP server on a RedHat system.

Ansible Yum Module Playbook for Installing Apache on RedHat Systems

What is the Ansible Yum Module?

The Ansible Yum module is specifically designed for managing packages on RedHat-based systems, such as CentOS and Fedora. It integrates seamlessly with the Yum Package Manager, allowing you to perform package operations like installation, removal, and updates directly from your Ansible playbooks. By leveraging this module, you can ensure that your systems remain consistent and up-to-date without manually intervening on each machine.

Example: Installing Apache with Ansible Yum Module

To install Apache on a RedHat-based system, you can create an Ansible playbook that uses the Ansible Yum module to handle the package installation. Below is an example playbook that installs the Apache HTTP package (httpd).

Step 1: Create the Playbook

Create a new playbook file, install_it.yaml, with the following content:

---
- hosts: all
  become: yes
  tasks:
    - name: Install Apache if the OS is RedHat
      yum:
        name: httpd
        state: latest
      when: ansible_os_family == "RedHat"

Step 2: Explanation of the Playbook

In the above playbook:

  • hosts: all specifies that this task will run on all targeted nodes.
  • become: yes ensures that the playbook is run with elevated (root) privileges.
  • The name keyword indicates the package name (httpd) that will be installed.
  • state: latest ensures the latest version of Apache is installed. If the package is already up-to-date, no action is taken.
  • The when statement ensures that Apache is only installed if the target system is a RedHat-based OS.

Step 3: Run the Playbook

Once you’ve written the playbook, run it using the following Ansible command:

ansible-playbook install_it.yaml

After execution, the playbook will display a summary of the tasks completed, such as whether Apache was installed or if the system was already up-to-date.

Example output:

PLAY [all] **************************************************************************************************************************************************

TASK [Gathering Facts] **************************************************************************************************************************************

ok: [192.168.1.2]

TASK [Install Apache if the OS is RedHat] *******************************************************************************************************************

ok: [192.168.1.2]

PLAY RECAP **************************************************************************************************************************************************

192.168.1.2 : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0

Step 4: Ansible Yum Module States

The state keyword in the Ansible Yum module defines the desired package state:

  • present: Ensures the package is installed. If not, it will be installed.
  • absent: Removes the package if it is already installed.
  • latest: Ensures the package is up-to-date. If it’s not installed, it will be installed; if it’s out-of-date, it will be upgraded.

By using these states, you can effectively manage package versions across your systems.

Leveraging ZippyOPS for Ansible Automation

For enterprises looking to streamline their infrastructure management with DevOps practices, ZippyOPS offers consulting, implementation, and managed services tailored to your needs. Whether you’re working with DevSecOps, Cloud, or Automated Ops, ZippyOPS helps organizations integrate tools like Ansible, improving efficiency and security at scale.

If you’re ready to take your IT operations to the next level, ZippyOPS can assist in setting up customized playbooks and automation strategies that scale with your infrastructure needs. Visit our solutions page to learn more about how our managed services can simplify your deployment processes.

Conclusion

In summary, the Ansible Yum module is an efficient way to manage software packages on RedHat-based systems, ensuring consistency across your infrastructure. By creating simple playbooks like the one above, you can automate the installation and maintenance of packages like Apache HTTP Server with ease.

If you’re looking to enhance your DevOps and Automation processes, consider partnering with ZippyOPS for expert consulting and support. With their expertise in areas such as AIOps, MLOps, and Security, they can help optimize your workflows and improve the overall reliability of your systems.

For more information, reach out to us at sales@zippyops.com.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top