This repository has been archived by the owner on Jan 8, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
128 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Molecule managed | ||
|
||
{% if item.registry is defined %} | ||
FROM {{ item.registry.url }}/{{ item.image }} | ||
{% else %} | ||
FROM {{ item.image }} | ||
{% endif %} | ||
|
||
{% if item.env is defined %} | ||
{% for var, value in item.env.items() %} | ||
{% if value %} | ||
ENV {{ var }} {{ value }} | ||
{% endif %} | ||
{% endfor %} | ||
{% endif %} | ||
|
||
RUN if [ $(command -v apt-get) ]; then export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get install -y python3 sudo bash ca-certificates iproute2 python3-apt aptitude && apt-get clean && rm -rf /var/lib/apt/lists/*; \ | ||
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install /usr/bin/python3 /usr/bin/python3-config /usr/bin/dnf-3 sudo bash iproute && dnf clean all; \ | ||
elif [ $(command -v yum) ]; then yum makecache fast && yum install -y /usr/bin/python /usr/bin/python2-config sudo yum-plugin-ovl bash iproute && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \ | ||
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python3 sudo bash iproute2 && zypper clean -a; \ | ||
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python3 sudo bash ca-certificates; \ | ||
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python3 sudo bash ca-certificates iproute2 && xbps-remove -O; fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/usr/bin/env ansible-playbook | ||
--- | ||
- hosts: localhost | ||
connection: local | ||
gather_facts: false | ||
collections: | ||
- containers.podman | ||
vars: | ||
platforms: | ||
# platforms supported as being managed by molecule/ansible, this does | ||
# not mean molecule itself can run on them. | ||
- image: alpine:edge | ||
- image: centos:7 | ||
- image: centos:8 | ||
- image: ubuntu:latest | ||
- image: debian:latest | ||
tasks: | ||
|
||
- name: Create isolated build directories for each image | ||
tempfile: | ||
prefix: "molecule-dockerfile-{{ item.image }}" | ||
state: directory | ||
register: temp_image_dirs | ||
with_items: "{{ platforms }}" | ||
loop_control: | ||
label: "{{ item.image }}" | ||
|
||
- name: Expand Dockerfile templates | ||
template: | ||
src: Dockerfile.j2 | ||
dest: "{{ temp_image_dirs.results[index].path }}/Dockerfile" | ||
register: result | ||
with_items: "{{ platforms }}" | ||
loop_control: | ||
index_var: index | ||
label: "{{ item.image }}" | ||
|
||
- name: Build Dockerfile(s) | ||
podman_image: | ||
name: "{{ item.item.image }}" | ||
path: "{{ temp_image_dirs.results[index].path }}" | ||
state: build | ||
with_items: "{{ result.results }}" | ||
loop_control: | ||
index_var: index | ||
label: "{{ item.item.image }}" | ||
register: result | ||
|
||
- name: Clean up temporary Dockerfile's | ||
file: | ||
path: "{{ item }}" | ||
state: absent | ||
loop: "{{ temp_dockerfiles.results | map(attribute='path') | list }}" | ||
|
||
- debug: var=result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters