68 lines
2.8 KiB
YAML
68 lines
2.8 KiB
YAML
---
|
|
- name: Find Cirros UEC image
|
|
shell: openstack image list -f value -c Name | grep 'cirros-.*-uec$'
|
|
register: cirros_uec_image_result
|
|
failed_when: cirros_uec_image_result.stdout == ""
|
|
|
|
- name: Find Cirros disk image
|
|
shell: openstack image list -f value -c Name | grep 'cirros-.*-disk$'
|
|
register: cirros_disk_image_result
|
|
failed_when: cirros_disk_image_result.stdout == ""
|
|
|
|
- name: Set image facts for Glance image
|
|
set_fact:
|
|
metalsmith_whole_disk_image: "{{ cirros_disk_image_result.stdout }}"
|
|
metalsmith_partition_image: "{{ cirros_uec_image_result.stdout }}"
|
|
when: not (metalsmith_use_http | default(false))
|
|
|
|
- block:
|
|
- name: Get baremetal HTTP endpoint
|
|
shell: |
|
|
source /opt/stack/devstack/openrc admin admin > /dev/null
|
|
iniget /etc/ironic/ironic.conf deploy http_url
|
|
args:
|
|
executable: /bin/bash
|
|
register: baremetal_endpoint_result
|
|
failed_when: baremetal_endpoint_result.stdout == ""
|
|
|
|
- name: Copy partition images directory
|
|
command: >
|
|
cp -r /opt/stack/devstack/files/images/{{ cirros_uec_image_result.stdout }}
|
|
/opt/stack/data/ironic/httpboot/metalsmith
|
|
args:
|
|
creates: /opt/stack/data/ironic/httpboot/metalsmith
|
|
become: yes
|
|
|
|
- name: Create MD5 checksums file for partition images
|
|
shell: md5sum cirros-* > CHECKSUMS
|
|
args:
|
|
chdir: /opt/stack/data/ironic/httpboot/metalsmith
|
|
become: yes
|
|
|
|
- name: Change ownership of image files
|
|
file:
|
|
path: /opt/stack/data/ironic/httpboot/metalsmith
|
|
state: directory
|
|
owner: "{{ ansible_user }}"
|
|
recurse: yes
|
|
mode: a+r
|
|
become: yes
|
|
|
|
- name: Calculate MD5 checksum for HTTP disk image
|
|
shell: |
|
|
md5sum /opt/stack/devstack/files/{{ cirros_disk_image_result.stdout }}.img \
|
|
| awk '{ print $1; }'
|
|
register: cirros_disk_image_checksum_result
|
|
failed_when: cirros_disk_image_checksum_result.stdout == ""
|
|
|
|
- name: Set facts for HTTP image
|
|
set_fact:
|
|
metalsmith_partition_image: "{{ baremetal_endpoint_result.stdout}}/metalsmith/{{ cirros_uec_image_result.stdout | replace('-uec', '-blank') }}.img"
|
|
metalsmith_partition_kernel_image: "{{ baremetal_endpoint_result.stdout}}/metalsmith/{{ cirros_uec_image_result.stdout | replace('-uec', '-vmlinuz') }}"
|
|
metalsmith_partition_ramdisk_image: "{{ baremetal_endpoint_result.stdout}}/metalsmith/{{ cirros_uec_image_result.stdout | replace('-uec', '-initrd') }}"
|
|
metalsmith_partition_checksum: "{{ baremetal_endpoint_result.stdout}}/metalsmith/CHECKSUMS"
|
|
metalsmith_whole_disk_image: "{{ baremetal_endpoint_result.stdout}}/{{ cirros_disk_image_result.stdout }}.img"
|
|
metalsmith_whole_disk_checksum: "{{ cirros_disk_image_checksum_result.stdout }}"
|
|
|
|
when: metalsmith_use_http | default(false)
|