-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Push the container as molecule side-effect
- Loading branch information
1 parent
4fe95ab
commit ee9b3a7
Showing
2 changed files
with
36 additions
and
1 deletion.
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,34 @@ | ||
--- | ||
# export DOCKER_REGISTRY | ||
# export DOCKER_USERNAME | ||
# export DOCKER_PASSWORD | ||
- name: Commit, tag, and push Docker image | ||
hosts: localhost | ||
gather_facts: false | ||
connection: local | ||
vars: | ||
docker_registry: "{{ lookup('env','DOCKER_REGISTRY') }}" | ||
docker_username: "{{ lookup('env','DOCKER_USERNAME') }}" | ||
docker_password: "{{ lookup('env','DOCKER_PASSWORD') }}" | ||
image_name: "dockpack/{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}" | ||
image_tag: "{{ lookup('pipe', 'date +%Y%m%d%H') }}" # Generates a datetime stamp | ||
tasks: | ||
- name: Commit the container | ||
ansible.builtin.command: | ||
cmd: "docker commit {{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }} {{ image_name }}:{{ image_tag }}" | ||
register: commit_output | ||
|
||
- name: Log in to Docker registry | ||
Check failure on line 21 in molecule/resources/playbooks/side-effect.yml
|
||
community.general.docker_login: | ||
username: "{{ docker_username }}" | ||
password: "{{ docker_password }}" | ||
registry_url: "{{ docker_registry | default(omit) }}" | ||
ignore_errors: true | ||
|
||
- name: Tag and push the Docker image | ||
community.general.docker_image: | ||
name: "{{ docker_registry }}{% if docker_registry | length > 1 %}/{% endif %}{{ image_name }}" | ||
tag: "{{ image_tag }}" | ||
push: true | ||
source: local | ||
|