AnsiblePilot — Ansible Automation Platform and Enterprise Ansible

AnsiblePilot covers Red Hat Ansible Automation Platform (AAP) and enterprise Ansible: install and upgrade paths, Event-Driven Ansible, security and day-2 operations, plus Luca Berton's books, videos and training.

Popular Topics

About Luca Berton

Luca Berton is an Ansible automation expert, author of 9 technical books published by Apress and Leanpub, 4 of them on Ansible, including "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example", 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 Container with Podman via Ansible — Video Tutorial

Automate the deployment of Apache HTTPD in a Podman container using Ansible. Set up web root, custom index.html, and manage container settings.

Watch on YouTube · Read the written article

Tutorial summary

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
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 - install packages => `ansible.builtin.yum` - custom index.html => `ansible.builtin.copy` - 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 four steps that you could automate with different Ansible modules. Firstly you need to verify that `podman` and it dependency is successfully installed on the target system using the `ansible.builtin.yum` Ansible module. Secondly, you need to create the custom index.html with `ansible.builtin.copy` Ansible module. You could upgrade this step using the `template` module. Thirdly, 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_container` 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 container hosts: all become: true gather_facts: false vars: webroot: "/webroot" 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: webroot present ansible.builtin.file: path: "{{ webroot }}" state: directory owner: "root" group: "root" mode: '0777' setype: "container_share_t" - name: custom index.html ansible.builtin.copy: dest: "{{ webroot }}/index.html" content: | Custom Web Page setype: "container_share_t" - name: run httpd container containers.podman.podman_container: name: webserver image: httpd state: started detach: true expose: - 80 ports: - 8080:80 volume: - "{{ webroot }}:/usr/local/apache2/htdocs/:exec" ``` execution ```bash ansible-pilot $ ansible-playbook -i virtualmachines/demo/inventory container/podman_httpd_redhat2.yml PLAY [deploy httpd on container] ****************************************************************** TASK [podman installed] *************************************************************************** changed: [demo.e

About this tutorial

  • Author: Luca Berton
  • Difficulty: Beginner
  • Read time: 9 min
  • Category: installation

Topics covered

Related video tutorials