Ansible is an open source IT automation engine used to automate application organization, framework computerization, cloud provisioning, and numerous IT administration tasks. Ansible improves the adaptability, consistency, and dependability of the IT climate.
Podman is an open source containerization platform that packages all the dependencies for building, shipping, and running applications as Podman containers. Using container virtualization technology ensures that an application works seamlessly in any environment. Podman CLI can implement almost all the commands from the Docker CLI.
[ Readers also liked: Improved systemd integration with Podman 2.0 ]
In this article, I show you how to automate Podman with Ansible by demonstrating how to automate various operations on the managed node. These are the following operations that you learn how to perform on a managed node:
- Install Podman
- Pull the httpd server image
- Copy the HTML code in the destination directory
- Run the httpd container and expose it to the public
- Start the webserver
For this procedure, I'm using Ansible 2.10.
Playbook for the entire setup
Installing Podman
In the package
module, assign the name of the software you need to install. The state tag is used to describe the desired condition of the software, here I use present, which means install.
- name: installing podman
package:
name: "podman"
state: present
Pull the httpd server image from the Podman image repository
Using the Ansible podman
image module, pull the httpd
image.
- name: Pull an image
containers.podman.podman_image:
name: httpd
Copy webpage
Using the copy
module, copy the webpage from source to destination.
- name: Copying file into home
copy:
src: /root/ws1/index.html
dest: /home
Run the httpd container
Run the container in detached mode and attach the volume to it after exposing its port.
- name: Re-create a redis container
containers.podman.podman_container:
name: sarthak
image: httpd
state: started
detach: true
exposed_ports:
- 80
ports:
- 4444:80
volumes: /home/:/usr/local/apache2/htdocs/
Running playbook to run Podman services
Confirm your managed node has Podman installed
Podman is not installed on this system, so install it by using the podman.yml
playbook.
podman --version
![Results of the podman --version command](/rhdc/managed-files/styles/wysiwyg_full_width/private/sysadmin/2021-03/1.jpg.webp?itok=0kg54AGr)
Next, run the playbook:
ansible-playbook podman.yml
![Playbook](/rhdc/managed-files/styles/wysiwyg_full_width/private/sysadmin/2021-03/2.jpg.webp?itok=C09QzLal)
Confirm that Podman successfully installed:
podman --version
![Updated output from podman --version](/rhdc/managed-files/styles/wysiwyg_full_width/private/sysadmin/2021-03/3.jpg.webp?itok=897CSA1f)
Verify the httpd server image was successfully pulled:
podman ps
![Output of podman ps confirming httpd is running](/rhdc/managed-files/styles/wysiwyg_full_width/private/sysadmin/2021-03/4.jpg.webp?itok=YQpJ2HXO)
Check the web server:
curl [ip address]:[port no]
![Output of curl to confirm the web service is available](/rhdc/managed-files/styles/wysiwyg_full_width/private/sysadmin/2021-03/5.jpg.webp?itok=xVdNQoYJ)
After following all these steps, Podman will be configured in your systems, and the website will be hosted on the 4444 port.
The complete playbook file:
---
- hosts: podman
tasks:
- name: installing podman
package:
name: "podman"
state: present
- name: Pull an image
containers.podman.podman_image:
name: httpd
- name: Copying file into home
copy:
src: /root/ws1/index.html
dest: /home
- name: Re-create a redis container
containers.podman.podman_container:
name: sarthak
image: httpd
state: started
detach: true
exposed_ports:
- 80
ports:
- 4444:80
volumes: /home/:/usr/local/apache2/htdocs/
[ Need more on Ansible? Take a free technical overview course from Red Hat. Ansible Essentials: Simplicity in Automation Technical Overview. ]
Wrap up
Ansible can be used to install Podman and to deploy Podman containers, simplifying your sysadmin life and adding scalability and flexibility to your environment.
À propos de l'auteur
Sarthak Jain is a Pre-Final Year Computer Science undergraduate from the University of Petroleum and Energy Studies (UPES). He is a cloud and DevOps enthusiast, knowing various tools and methodologies of DevOps. Sarthak also Mentored more than 2,000 students Regarding the Latest Tech trends through their community Dot Questionmark.
Parcourir par canal
Automatisation
Les dernières nouveautés en matière d'automatisation informatique pour les technologies, les équipes et les environnements
Intelligence artificielle
Actualité sur les plateformes qui permettent aux clients d'exécuter des charges de travail d'IA sur tout type d'environnement
Cloud hybride ouvert
Découvrez comment créer un avenir flexible grâce au cloud hybride
Sécurité
Les dernières actualités sur la façon dont nous réduisons les risques dans tous les environnements et technologies
Edge computing
Actualité sur les plateformes qui simplifient les opérations en périphérie
Infrastructure
Les dernières nouveautés sur la plateforme Linux d'entreprise leader au monde
Applications
À l’intérieur de nos solutions aux défis d’application les plus difficiles
Programmes originaux
Histoires passionnantes de créateurs et de leaders de technologies d'entreprise
Produits
- Red Hat Enterprise Linux
- Red Hat OpenShift
- Red Hat Ansible Automation Platform
- Services cloud
- Voir tous les produits
Outils
- Formation et certification
- Mon compte
- Assistance client
- Ressources développeurs
- Rechercher un partenaire
- Red Hat Ecosystem Catalog
- Calculateur de valeur Red Hat
- Documentation
Essayer, acheter et vendre
Communication
- Contacter le service commercial
- Contactez notre service clientèle
- Contacter le service de formation
- Réseaux sociaux
À propos de Red Hat
Premier éditeur mondial de solutions Open Source pour les entreprises, nous fournissons des technologies Linux, cloud, de conteneurs et Kubernetes. Nous proposons des solutions stables qui aident les entreprises à jongler avec les divers environnements et plateformes, du cœur du datacenter à la périphérie du réseau.
Sélectionner une langue
Red Hat legal and privacy links
- À propos de Red Hat
- Carrières
- Événements
- Bureaux
- Contacter Red Hat
- Lire le blog Red Hat
- Diversité, équité et inclusion
- Cool Stuff Store
- Red Hat Summit