Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push the container as molecule side-effect #4

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
extends: default

rules:
line-length:
max: 160
truthy:
check-keys: false
3 changes: 2 additions & 1 deletion molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ dependency:
driver:
name: docker
platforms:
- name: amq-alma8
- name: base_amq
image: dokken/almalinux-8
pre_build_image: true
command: /sbin/init
Expand All @@ -29,6 +29,7 @@ provisioner:
prepare: ../resources/playbooks/prepare.yml
converge: ../resources/playbooks/converge.yml
verify: ../resources/playbooks/verify.yml
side_effect: ../resources/playbooks/side-effect.yml
verifier:
name: ansible
...
25 changes: 25 additions & 0 deletions molecule/resources/playbooks/side-effect.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
# export DOCKER_REGISTRY
- name: Commit, tag, and push Docker image
hosts: localhost
gather_facts: false
connection: local
vars:
github_actions: "{{ lookup('env', 'GITHUB_ACTIONS') }}"
docker_registry: "{{ lookup('env','DOCKER_REGISTRY') }}"
image_name: "dockpack/base_amq"
image_tag: "{{ lookup('pipe', 'date +%Y%m%d%H') }}" # Generates a date hour stamp
tasks:
- name: Commit the container
ansible.builtin.command:
cmd: "docker commit base_amq {{ image_name }}:{{ image_tag }}"
changed_when: true
register: commit_output

- name: Tag and push the Docker image
when: not github_actions | bool
community.docker.docker_image:
name: "{{ docker_registry }}{% if docker_registry | length > 1 %}/{% endif %}{{ image_name }}"
tag: "{{ image_tag }}"
push: true
source: local
3 changes: 3 additions & 0 deletions requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
collections:
- name: community.docker