Commit 51aa1ec9 authored by ale's avatar ale

Use common wrapper for pulling container images

The podman-pull-image command is renamed float-pull-image and it is
meant to work with Docker too: the docker_image Ansible module does
not actually generate a status in a way that is useful to us.
parent 17d7c3a7
Pipeline #6178 failed with stage
in 6 minutes and 11 seconds
......@@ -26,6 +26,12 @@
path: /usr/lib/float/docker
state: directory
- name: Install float-pull-image script
src: float-pull-image.j2
dest: /usr/sbin/float-pull-image
mode: 0755
- include_tasks: start.yml
# Grab the list of currently running containers, and stop / cleanup
......@@ -27,8 +27,3 @@
state: link
force: true
- name: Install podman-pull-image script
src: podman-pull-image
dest: /usr/sbin/podman-pull-image
mode: 0755
......@@ -55,33 +55,24 @@
# right away. Always bump the service if the systemd unit changes.
- name: Set up the services
- name: Pull the Docker images
name: "{{ item.container.image }}"
force: true
register: docker_image
when: "container_runtime == 'docker'"
loop: "{{ float_enabled_containers }}"
- name: Pull the Docker images
# Ansible >= 2.8 ships with podman_image
command: "podman-pull-image {{ item.container.image }}"
register: podman_image
when: "container_runtime == 'podman'"
- name: Pull the container images
command: "float-pull-image {{ item.container.image }}"
register: container_image
loop: "{{ float_enabled_containers }}"
changed_when: "podman_image.rc == 0"
failed_when: "podman_image.rc not in [0, 42]"
changed_when: "container_image.rc == 0"
failed_when: "container_image.rc not in [0, 42]"
- name: Start the systemd units
name: "docker-{{ item.0.tag }}.service"
daemon_reload: "{{ item.2 is changed }}"
state: "{{ 'restarted' if (item.1.changed or item.2.changed or item.3.changed or item.4.changed) else 'started' }}"
state: "{{ 'restarted' if (item.1.changed or item.2.changed or item.3.changed) else 'started' }}"
enabled: yes
masked: no
no_block: yes
#changed_when: false
loop: "{{ float_enabled_containers | zip(docker_systemd_run_script.results, docker_systemd_unit.results, docker_image.results, podman_image.results) | list }}"
loop: "{{ float_enabled_containers | zip(docker_systemd_run_script.results, docker_systemd_unit.results, container_image.results) | list }}"
- debug:
msg: "Failed to set up one or more containers"
# Detect if a different image has been pulled
# Pull a Docker image, and detect if a different image has been pulled
# than the one we knew about before (so we need to restart the container).
set -u
binary={{ container_runtime }}
if [ -z "$image" ]; then
echo "usage: <image url>"
exit 1
pre_version=$(podman inspect --type image --format "{{.Id}}" $image)
pre_version=$($binary inspect --type image --format "{{.Id}}" $image)
podman pull $image
$binary pull $image
if [ $? -gt 0 ]; then
exit 1
post_version=$(podman inspect --type image --format "{{.Id}}" $image)
post_version=$($binary inspect --type image --format "{{.Id}}" $image)
if [ "$pre_version" == "$post_version" ]; then
exit 42
exit 0
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment