diff --git a/playbooks/octavia-files.yaml b/playbooks/octavia-files.yaml index 4a4d38877..c7ce5e46f 100644 --- a/playbooks/octavia-files.yaml +++ b/playbooks/octavia-files.yaml @@ -6,6 +6,7 @@ amp_ssh_key_name: "{{ amp_ssh_key_name }}" amp_ssh_key_path: "{{ amp_ssh_key_path }}" amp_ssh_key_data: "{{ amp_ssh_key_data }}" + amp_to_raw: "{{ amp_to_raw | bool }}" auth_username: "{{ auth_username }}" auth_pasword: "{{ auth_password }}" auth_project_name: "{{ auth_project_name }}" diff --git a/playbooks/roles/common/defaults/main.yml b/playbooks/roles/common/defaults/main.yml index 314835802..3b9d778d1 100644 --- a/playbooks/roles/common/defaults/main.yml +++ b/playbooks/roles/common/defaults/main.yml @@ -4,6 +4,7 @@ amp_image_filename: "" amp_image_tag: "amphora-image" amp_ssh_key_name: "octavia-ssh-key" amp_ssh_key_path: "" +amp_to_raw: False auth_username: "octavia" auth_project_name: "service" lb_mgmt_net_name: "lb-mgmt-net" diff --git a/playbooks/roles/octavia-undercloud/tasks/image_mgmt.yml b/playbooks/roles/octavia-undercloud/tasks/image_mgmt.yml index bd16c96e1..a73073f57 100644 --- a/playbooks/roles/octavia-undercloud/tasks/image_mgmt.yml +++ b/playbooks/roles/octavia-undercloud/tasks/image_mgmt.yml @@ -48,10 +48,37 @@ upload_image: true when: current_md5 is not defined or replace_image + - block: + - name: create temporary directory + tempfile: + state: directory + register: amp_tmp_dir + + - name: set RAW file name + set_fact: + raw_filename: "{{ amp_tmp_dir.path }}/{{ image_filename|splitext|first|basename }}.img" + + - name: convert image from qcow2 to raw + shell: | + qemu-img convert -f qcow2 -O raw {{ image_filename }} {{ raw_filename }} + + - name: setting amphora format to raw + set_fact: + raw_format: raw + when: amp_to_raw + - name: upload image to glance shell: | - openstack image create --disk-format qcow2 --container-format bare --tag {{ amp_image_tag }} \ - --file {{ image_filename }} {{ amphora_image }} + openstack image create --disk-format {{ raw_format|default('qcow2') }} \ + --container-format bare --tag {{ amp_image_tag }} \ + --file {{ raw_filename|default(image_filename) }} \ + {{ amphora_image }} register: image_result changed_when: "image_result.stdout != ''" when: image_file_result.stat.exists and upload_image is defined + + - name: delete converted raw image + file: + path: "{{ amp_tmp_dir.path }}" + state: absent + when: amp_to_raw diff --git a/workbooks/octavia_post.yaml b/workbooks/octavia_post.yaml index 3f5553526..9fc846d1b 100644 --- a/workbooks/octavia_post.yaml +++ b/workbooks/octavia_post.yaml @@ -14,6 +14,7 @@ workflows: - amp_ssh_key_name - amp_ssh_key_path - amp_ssh_key_data + - amp_to_raw - auth_username - auth_password - auth_project_name @@ -103,6 +104,7 @@ workflows: amp_ssh_key_name: <% $.amp_ssh_key_name %> amp_ssh_key_path: <% $.amp_ssh_key_path %> amp_ssh_key_data: <% $.amp_ssh_key_data %> + amp_to_raw: <% $.amp_to_raw %> auth_username: <% $.auth_username %> auth_password: <% $.auth_password %> auth_project_name: <% $.auth_project_name %>