diff --git a/tasks/octavia_amp_image.yml b/tasks/octavia_amp_image.yml index 591441da..3e25c9f7 100644 --- a/tasks/octavia_amp_image.yml +++ b/tasks/octavia_amp_image.yml @@ -43,47 +43,59 @@ when: - octavia_download_artefact | bool - - name: Get current image id - os_image_facts: - cloud: default - region_name: "{{ octavia_service_region }}" - image: amphora-x64-haproxy - interface: admin - verify: "{{ not keystone_service_adminuri_insecure }}" - register: get_image_facts - until: get_image_facts is success - retries: 5 - delay: 10 - when: - - octavia_download_result | changed - - # This uses command since os_image doesn't support tags. - # TODO(odyssey4me): - # Add tag capability to os_image module and replace this. - - name: Upload new image to glance - command: >- - openstack image create - --os-cloud default - --file {{ octavia_download_result.dest }} - --disk-format qcow2 - --tag {{ octavia_glance_image_tag }} - --private - --project service - amphora-x64-haproxy + - name: Replace existing image with new one when: - octavia_download_result | changed + block: + - name: Get current image id + os_image_facts: + auth: + auth_url: "{{ keystone_service_adminurl }}" + username: "{{ octavia_service_user_name }}" + password: "{{ octavia_service_password }}" + project_name: "{{ octavia_service_project_name }}" + user_domain_name: "{{ octavia_service_user_domain_id }}" + project_domain_name: "{{ octavia_service_project_domain_id }}" + region_name: "{{ octavia_service_region }}" + image: amphora-x64-haproxy + interface: admin + verify: "{{ not keystone_service_adminuri_insecure }}" + register: get_image_facts + until: get_image_facts is success + retries: 5 + delay: 10 - - name: Delete old image from glance - os_image: - cloud: default - state: absent - region_name: "{{ octavia_service_region }}" - id: "{{ openstack.id }}" - interface: admin - verify: "{{ not keystone_service_adminuri_insecure }}" - register: remove_old_image - until: remove_old_image is success - retries: 5 - delay: 10 - when: - - openstack is defined # result from os_image_facts + # This uses command since os_image doesn't support tags. + # TODO(odyssey4me): + # Add tag capability to os_image module and replace this. + - name: Upload new image to glance + command: >- + openstack image create + --os-cloud default + --file {{ octavia_download_result.dest }} + --disk-format qcow2 + --tag {{ octavia_glance_image_tag }} + --private + --project service + amphora-x64-haproxy + + - name: Delete old image from glance + os_image: + auth: + auth_url: "{{ keystone_service_adminurl }}" + username: "{{ octavia_service_user_name }}" + password: "{{ octavia_service_password }}" + project_name: "{{ octavia_service_project_name }}" + user_domain_name: "{{ octavia_service_user_domain_id }}" + project_domain_name: "{{ octavia_service_project_domain_id }}" + state: absent + region_name: "{{ octavia_service_region }}" + name: "{{ openstack_image.id }}" + interface: admin + verify: "{{ not keystone_service_adminuri_insecure }}" + register: remove_old_image + until: remove_old_image is success + retries: 5 + delay: 10 + when: + - openstack_image.id is defined