diff --git a/docker/services/opendaylight-api.yaml b/docker/services/opendaylight-api.yaml index f196dd86ad..5de77b22a5 100644 --- a/docker/services/opendaylight-api.yaml +++ b/docker/services/opendaylight-api.yaml @@ -127,7 +127,7 @@ outputs: net: host detach: true user: odl - restart: always + restart: unless-stopped healthcheck: test: /openstack/healthcheck volumes: @@ -185,6 +185,15 @@ outputs: # Containerized deployment upgrade steps - name: ODL container L2 update and upgrade tasks block: &odl_container_upgrade_tasks + - name: Check if ODL container is present + shell: "docker ps -a --format '{{ '{{' }}.Names{{ '}}' }}' | grep '^opendaylight_api$'" + register: opendaylight_api_container_present + failed_when: false + # NOTE: using shell module because of + # https://github.com/ansible/ansible/issues/27960 + - name: Update ODL container restart policy to unless-stopped + shell: "docker update --restart=unless-stopped opendaylight_api" + when: opendaylight_api_container_present.rc == 0 - name: stop previous ODL container docker_container: name: opendaylight_api @@ -242,6 +251,15 @@ outputs: odl_update_level: {get_param: ODLUpdateLevel} - name: Stop ODL container and remove cache block: + - name: Check if ODL container is present + shell: "docker ps -a --format '{{ '{{' }}.Names{{ '}}' }}' | grep '^opendaylight_api$'" + register: opendaylight_api_container_present + failed_when: false + # NOTE: using shell module because of + # https://github.com/ansible/ansible/issues/27960 + - name: Update ODL container restart policy to unless-stopped + shell: "docker update --restart=unless-stopped opendaylight_api" + when: opendaylight_api_container_present.rc == 0 - name: Stop previous ODL container docker_container: name: opendaylight_api