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

Next, run the playbook:
ansible-playbook podman.yml

Confirm that Podman successfully installed:
podman --version

Verify the httpd server image was successfully pulled:
podman ps

Check the web server:
curl [ip address]:[port no]

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.
저자 소개
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.
채널별 검색
오토메이션
기술, 팀, 인프라를 위한 IT 자동화 최신 동향
인공지능
고객이 어디서나 AI 워크로드를 실행할 수 있도록 지원하는 플랫폼 업데이트
오픈 하이브리드 클라우드
하이브리드 클라우드로 더욱 유연한 미래를 구축하는 방법을 알아보세요
보안
환경과 기술 전반에 걸쳐 리스크를 감소하는 방법에 대한 최신 정보
엣지 컴퓨팅
엣지에서의 운영을 단순화하는 플랫폼 업데이트
인프라
세계적으로 인정받은 기업용 Linux 플랫폼에 대한 최신 정보
애플리케이션
복잡한 애플리케이션에 대한 솔루션 더 보기
가상화
온프레미스와 클라우드 환경에서 워크로드를 유연하게 운영하기 위한 엔터프라이즈 가상화의 미래