Ansible-bender uses Ansible playbooks and Buildah to build container images. All of the configuration, including base images and metadata, is passed as a variable within the playbook. Here is our previous example converted to Ansible syntax:
---
- name: Container image with ansible-bender
hosts: all
vars:
ansible_bender:
base_image: python:3-buster
target_image:
name: hosacpp-gcc
cmd: /usr/bin/gcc
tasks:
- name: Install Apt packages
apt:
pkg:
- build-essential
- gcc
As you see, the ansible_bender variable is responsible for all the configuration specific to containers. The tasks presented below are executed inside the container based on base_image.
One thing to note is that Ansible requires a Python interpreter present in the base image. This is why we had to change ubuntu:bionic used in previous examples to python:3-buster. ubuntu:bionic is an Ubuntu image without a Python interpreter preinstalled.