AnsiblePilot — Master Ansible Automation
AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,100 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.
Popular Topics
About Luca Berton
Luca Berton is an Ansible automation expert, author of "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example" published by Apress, and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.
Deploy Apache HTTPD with Podman Using Ansible Playbook — Video Tutorial
Automate Apache HTTPD deployment in a Podman container with Ansible. Manage Podman installation, image pulling, and container configuration.
What You'll Learn
- How to Setup Apache Web Server in a Podman Container for RedHat-like systems with Ansible?
- Setup Apache Web Server in a Podman Container for RedHat-like systems
- Links
- code
- execution
- idempotency
- before execution
- after execution
- Conclusion
- Related Articles
Full Tutorial Content
How to Setup Apache Web Server in a Podman Container for RedHat-like systems with Ansible?
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.
Setup Apache Web Server in a Podman Container for RedHat-like systems
- install packages => `ansible.builtin.yum`
- pull image => `containers.podman.podman_image`
- run container => `containers.podman.podman_container`
Today we're talking about how to Deploy a web server apache httpd in a Podman Container for RedHat-like Linux systems.
The full process requires three steps that you could automate with different Ansible modules.
Firstly you need to verify that `podman` and its dependency is successfully installed on the target system using the `ansible.builtin.yum` Ansible module.
Secondly, you need to pull the image for the container hub registry using the `containers.podman.podman_image` Ansible module.
Finally, you could run the `webserver` container setting the right port and settings using the `containers.podman.podman_image` Ansible module.
Links
- [containers.podman.podman_image](https://docs.ansible.com/ansible/latest/collections/containers/podman/podman_image_module.html)
- [containers.podman.podman_container](https://docs.ansible.com/ansible/latest/collections/containers/podman/podman_container_module.html)
- [httpd image](https://hub.docker.com/_/httpd)
## Playbook
How to Setup Apache Web Server in a Podman Container for RedHat-like systems with Ansible Playbook.
code
```yaml
---
- name: deploy httpd on container
hosts: all
become: true
gather_facts: false
tasks:
- name: podman installed
ansible.builtin.yum:
name: podman
state: latest
- name: pull image
containers.podman.podman_image:
name: httpd
pull: true
tag: latest
- name: run httpd container
containers.podman.podman_container:
name: webserver
image: httpd
state: started
detach: true
expose:
- 80
ports:
- 8080:80
```
execution
```bash
ansible-pilot $ ansible-playbook -i virtualmachines/demo/inventory container/podman_httpd_redhat.yml
PLAY [deploy httpd on container] ******************************************************************
TASK [podman installed] ***************************************************************************
changed: [demo.example.com]
TASK [pull image] *********************************************************************************
changed: [demo.example.com]
TASK [run httpd container] ************************************************************************
changed: [demo.example.com]
PLAY RECAP ****************************************************************************************
demo.example.com : ok=3 changed=3 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
ansible-pilot $
```
idempotency
```bash
ansible-pilot $ ansible-playbook -i virtua
About This Tutorial
- Author: Luca Berton
- Difficulty: Beginner
- Read time: 7 min
- Category: installation
Read the full written article: Deploy Apache HTTPD with Podman Using Ansible Playbook
Related Video Tutorials
- Deploy Apache HTTPD Container with Podman via Ansible — Automate the deployment of Apache HTTPD in a Podman container using Ansible. Set up web root, custom index.html, and manage container settings.
- Configure Apache Vhost on RedHat Using Ansible Playbook — Automate Apache virtual host setup on RedHat systems with Ansible. Learn to manage web server installation, configuration, and firewall settings.
- Efficient Web Server Setup Using Ansible Playbook — Set up a web server effortlessly with our Ansible playbook tutorial. Follow step-by-step instructions for installing and configuring HTTPD service.
- Deploy Apache HTTPD on Docker Container with Ansible — Automate the deployment of Apache HTTPD in a Docker container using Ansible. Manage system packages, Docker images, and web content effortlessly.
- Set Up Apache Webserver on Debian with Ansible Playbook — Learn to deploy and configure an Apache web server on Debian using Ansible. Automate installation, custom index.html setup, and firewall rules.
- Set Up Apache Vhost on Debian with Ansible Playbook — Learn to configure an Apache virtual host on Debian using Ansible. Automate web server setup, document root creation, and firewall rules.