diff --git a/doc/source/configuration.rst b/doc/source/configuration.rst index ebe619f5a..88ce29324 100644 --- a/doc/source/configuration.rst +++ b/doc/source/configuration.rst @@ -134,3 +134,25 @@ You can select what to delete prior to the run of quickstart adding a - all: same as virthost but user setup in virthost is deleted too - none: will not teardown anything (useful for testing multiple actions against a deployed overcloud) + +Undercloud customization +------------------------ + +You can perform extra undercloud customization steps, using a script +that will be applied with ``virt-customize`` on the final undercloud +image. To allow that, you need to pass the ``undercloud_customize_script`` +var, that needs to point to an script living on your filesystem. +That script will be copied to working directory, and applied on the +undercloud. The script can be in Jinja template format, so you can benefit +from ansible var substitutions. + +Overcloud customization +----------------------- + +You can perform extra overclud customization steps, using a script +that will be applied with ``virt-customize`` on the overcloud-full +image. To allow that, you need to pass the ``overcloud_customize_script`` +var, that needs to point to an script living on your filesystem. +That script will be copied to working directory, and applied on the +overcloud. The script can be in Jinja template format, so you can benefit +from ansible var substitutions. diff --git a/roles/libvirt/setup/undercloud/tasks/customize_overcloud.yml b/roles/libvirt/setup/undercloud/tasks/customize_overcloud.yml new file mode 100644 index 000000000..ab35d44df --- /dev/null +++ b/roles/libvirt/setup/undercloud/tasks/customize_overcloud.yml @@ -0,0 +1,38 @@ +- name: Create overcloud customize script + template: + src: "{{ overcloud_customize_script }}" + dest: "{{ working_dir }}/overcloud-customize.sh" + mode: 0755 + +- environment: + LIBGUESTFS_BACKEND: direct + LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}" + block: + # We need to extract the overcloud image, if it's not already extracted. + # so we can inject the gating repo into it. + - name: check if overcloud image is already extracted + stat: + path: '{{ working_dir }}/overcloud-full.qcow2' + register: overcloud_image_stat_for_customize + + - name: Extract overcloud-full image + command: > + virt-copy-out -a {{ working_dir }}/undercloud.qcow2 + /home/stack/overcloud-full.qcow2 {{ working_dir }} + register: overcloud_image_extracted_for_customize + when: not overcloud_image_stat_for_customize.stat.exists + + # only customize overcloud-full image if that is not going to be + # used as undercloud + - name: Perform extra overcloud customizations + command: > + virt-customize -a {{ working_dir}}/overcloud-full.qcow2 + --run '{{ working_dir}}/overcloud-customize.sh' + + - name: Copy updated overcloud-full image back to undercloud + command: > + virt-copy-in -a {{ working_dir }}/undercloud.qcow2 + {{ working_dir }}/overcloud-full.qcow2 /home/stack/ + when: overcloud_image_extracted_for_customize is defined and + overcloud_image_extracted_for_customize|changed + diff --git a/roles/libvirt/setup/undercloud/tasks/main.yml b/roles/libvirt/setup/undercloud/tasks/main.yml index 4f2200202..51f1a0757 100644 --- a/roles/libvirt/setup/undercloud/tasks/main.yml +++ b/roles/libvirt/setup/undercloud/tasks/main.yml @@ -87,6 +87,27 @@ owner: stack group: stack + - name: Create undercloud customize script + template: + src: "{{ undercloud_customize_script }}" + dest: "{{ working_dir}}/undercloud-customize.sh" + mode: 0755 + when: undercloud_customize_script is defined + + # This allows to run a customization script on the + # undercloud image, to cover any extra needs. + - name: Perform extra undercloud customizations + command: > + virt-customize -a {{ working_dir }}/undercloud.qcow2 + --run '{{ working_dir }}/undercloud-customize.sh' + when: undercloud_customize_script is defined + + # This allows to run a customization script on the + # overcloud image, to cover any extra needs. + - name: Perform extra overcloud customizations + include: customize_overcloud.yml + when: overcloud_customize_script is defined + # Perform an SELinux relabel on the undercloud image to avoid problems # caused by bad labelling, since by default the undercloud runs in # enforcing mode.