From 943a4cdb6641e0f7da1640dc8a13446535e0ff80 Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Thu, 13 Jul 2017 12:31:45 +0100 Subject: [PATCH] Fix upgrade of docker-registry and opensm containers Previously the docker-registry container would not be upgraded when a new image is downloaded. We now ensure that new images are tagged in the local repository, and pull the image separately from the container upgrade. --- ansible/roles/docker-registry/defaults/main.yml | 6 ++++-- ansible/roles/docker-registry/tasks/deploy.yml | 1 - ansible/roles/docker-registry/tasks/pull.yml | 1 + ansible/roles/docker-registry/tasks/upgrade.yml | 4 +++- ansible/roles/opensm/tasks/deploy.yml | 1 - ansible/roles/opensm/tasks/pull.yml | 1 + ansible/roles/opensm/tasks/upgrade.yml | 4 +++- 7 files changed, 12 insertions(+), 6 deletions(-) mode change 120000 => 100644 ansible/roles/docker-registry/tasks/upgrade.yml mode change 120000 => 100644 ansible/roles/opensm/tasks/upgrade.yml diff --git a/ansible/roles/docker-registry/defaults/main.yml b/ansible/roles/docker-registry/defaults/main.yml index 8ebef1261..5fc946b64 100644 --- a/ansible/roles/docker-registry/defaults/main.yml +++ b/ansible/roles/docker-registry/defaults/main.yml @@ -22,8 +22,10 @@ docker_registry_port: 5000 #################### # Docker #################### -docker_registry_namespace: "library" -docker_registry_image: "{{ docker_registry ~ '/' if docker_registry | default else '' }}{{ docker_registry_namespace }}/registry" +# NOTE: Namespace 'library' causes image task to always be changed and +# container to never update to new images. +docker_registry_namespace: "" +docker_registry_image: "{{ docker_registry ~ '/' if docker_registry | default else '' }}{{ docker_registry_namespace ~ '/' if docker_registry_namespace else '' }}registry" docker_registry_tag: "latest" docker_registry_image_full: "{{ docker_registry_image }}:{{ docker_registry_tag }}" diff --git a/ansible/roles/docker-registry/tasks/deploy.yml b/ansible/roles/docker-registry/tasks/deploy.yml index 157835184..cc492dbb3 100644 --- a/ansible/roles/docker-registry/tasks/deploy.yml +++ b/ansible/roles/docker-registry/tasks/deploy.yml @@ -5,7 +5,6 @@ name: "{{ item.value.container_name }}" ports: "{{ item.value.ports | default(omit) }}" privileged: "{{ item.value.privileged | default(omit) }}" - pull: "{{ action == 'upgrade' }}" read_only: "{{ item.value.read_only | default(omit) }}" restart_policy: "{{ docker_registry_restart_policy }}" restart_retries: "{{ docker_registry_restart_retries }}" diff --git a/ansible/roles/docker-registry/tasks/pull.yml b/ansible/roles/docker-registry/tasks/pull.yml index d3c3430f7..6d5a6e180 100644 --- a/ansible/roles/docker-registry/tasks/pull.yml +++ b/ansible/roles/docker-registry/tasks/pull.yml @@ -2,4 +2,5 @@ - name: Pulling Docker registry container image docker_image: name: "{{ docker_registry_image_full }}" + repository: "{{ docker_registry_image_full }}" state: present diff --git a/ansible/roles/docker-registry/tasks/upgrade.yml b/ansible/roles/docker-registry/tasks/upgrade.yml deleted file mode 120000 index 0412f9220..000000000 --- a/ansible/roles/docker-registry/tasks/upgrade.yml +++ /dev/null @@ -1 +0,0 @@ -deploy.yml \ No newline at end of file diff --git a/ansible/roles/docker-registry/tasks/upgrade.yml b/ansible/roles/docker-registry/tasks/upgrade.yml new file mode 100644 index 000000000..8459b03ca --- /dev/null +++ b/ansible/roles/docker-registry/tasks/upgrade.yml @@ -0,0 +1,3 @@ +--- +- include: pull.yml +- include: deploy.yml diff --git a/ansible/roles/opensm/tasks/deploy.yml b/ansible/roles/opensm/tasks/deploy.yml index bb1037b0d..736cdcc8d 100644 --- a/ansible/roles/opensm/tasks/deploy.yml +++ b/ansible/roles/opensm/tasks/deploy.yml @@ -5,7 +5,6 @@ name: "{{ item.value.container_name }}" network_mode: "host" privileged: "{{ item.value.privileged | default(omit) }}" - pull: "{{ action == 'upgrade' }}" read_only: "{{ item.value.read_only | default(omit) }}" restart_policy: "{{ opensm_restart_policy }}" restart_retries: "{{ opensm_restart_retries }}" diff --git a/ansible/roles/opensm/tasks/pull.yml b/ansible/roles/opensm/tasks/pull.yml index 80c8c54ad..8186e2492 100644 --- a/ansible/roles/opensm/tasks/pull.yml +++ b/ansible/roles/opensm/tasks/pull.yml @@ -2,4 +2,5 @@ - name: Pulling OpenSM container image docker_image: name: "{{ opensm_image_full }}" + repository: "{{ opensm_image_full }}" state: present diff --git a/ansible/roles/opensm/tasks/upgrade.yml b/ansible/roles/opensm/tasks/upgrade.yml deleted file mode 120000 index 0412f9220..000000000 --- a/ansible/roles/opensm/tasks/upgrade.yml +++ /dev/null @@ -1 +0,0 @@ -deploy.yml \ No newline at end of file diff --git a/ansible/roles/opensm/tasks/upgrade.yml b/ansible/roles/opensm/tasks/upgrade.yml new file mode 100644 index 000000000..8459b03ca --- /dev/null +++ b/ansible/roles/opensm/tasks/upgrade.yml @@ -0,0 +1,3 @@ +--- +- include: pull.yml +- include: deploy.yml