diff --git a/ansible/build.yml b/ansible/build.yml index 1e5537c5e19c56126a0ee520bb9ac0a04ae8054b..b66149a070b2347654389bb46a319c69a7f7546f 100644 --- a/ansible/build.yml +++ b/ansible/build.yml @@ -30,6 +30,10 @@ force_tag: true source: build + - name: Get source image + set_fact: + source_image: "{{ lookup('ansible.builtin.file', '../Dockerfile') | regex_search('FROM (.*):(.*)') | regex_replace('^FROM\\s(.*)$', '\\1') }}" + - name: Remove local image community.docker.docker_image: state: absent @@ -42,6 +46,12 @@ name: "{{ lookup('ansible.builtin.env','CI_REGISTRY_IMAGE') }}:{{ lookup('ansible.builtin.env','CI_COMMIT_SHORT_SHA') }}" force_absent: true + - name: Remove source image + community.docker.docker_image: + state: absent + name: "{{ source_image }}" + force_absent: true + - name: Log out of registry community.docker.docker_login: state: absent