tripleo-quickstart/roles/libvirt/setup/overcloud/tasks/main.yml

93 lines
3.5 KiB
YAML

- when: overcloud_nodes
environment:
LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}"
block:
# Generate MAC addresses that we'll use for the overcloud nodes.
# By generating these in advance we can populate the
# `instackenv.json` file with MAC addresses without running
# introspection.
- name: get a list of MACs to use
generate_macs:
nodes: "{{ overcloud_nodes }}"
networks: "{{ networks }}"
register: node_mac_map
# Create libvirt volumes for the overcloud hosts.
- name: Check if overcloud volumes exist
command: >
virsh vol-info --pool '{{libvirt_volume_pool}}' '{{item.name}}.qcow2'
register: overcloud_vol_check
ignore_errors: true
with_items: "{{ overcloud_nodes }}"
- name: Create overcloud vm storage
command: >
virsh vol-create-as '{{ libvirt_volume_pool }}'
'{{ item.item.name }}'.qcow2 '{{ flavors[item.item.flavor].disk }}'G
--format qcow2
when:
- item|failed
- not fake_nodepool_vms|default("false")|bool
with_items: "{{ overcloud_vol_check.results }}"
# Define (but do not start) the overcloud nodes. These will be
# booted later by ironic during the provisioning process.
- name: Define overcloud vms
virt:
name: "{{ item.name }}"
command: define
xml: "{{ lookup('template', 'baremetalvm.xml.j2') }}"
uri: "{{ libvirt_uri }}"
with_items: "{{ overcloud_nodes }}"
when: not fake_nodepool_vms|default("false")|bool
- name: Define overcloud vms
virt:
name: "{{ item.name }}"
command: define
xml: "{{ lookup('template', 'fakenodepoolvm.xml.j2') }}"
uri: "{{ libvirt_uri }}"
with_items: "{{ overcloud_nodes }}"
when: fake_nodepool_vms|default("false")|bool
- include: fake_nodepool.yml
when: fake_nodepool_vms|default("false")|bool
# Create additional blockdevices for each objectstorage flavor node
# These are sparse files, not using space if unused
- name: Create additional blockdevice for objectstorage nodes
command: >
dd if=/dev/zero of={{ libvirt_volume_path }}/{{ item[0].name }}_{{ item[1] }}.img bs=1 count=0 seek={{ extradisks_size }}
when: flavors[item[0].flavor].extradisks|default(false)
with_nested:
- "{{ overcloud_nodes }}"
- "{{ extradisks_list }}"
- name: Check if additional blockdevices are attached
command: >
virsh domblkinfo {{ item[0].name }} {{ libvirt_volume_path }}/{{ item[0].name }}_{{ item[1] }}.img
when: flavors[item[0].flavor].extradisks|default(false)
changed_when: false
ignore_errors: true
register: overcloud_extradisks_check
with_nested:
- "{{ overcloud_nodes }}"
- "{{ extradisks_list }}"
- name: Attach additional blockdevices to overcloud objectstorage VMs
command: >
virsh attach-disk --config {{ item.item[0].name }} {{ libvirt_volume_path }}/{{ item.item[0].name }}_{{ item.item[1] }}.img {{ item.item[1] }}
when: item|failed
with_items: "{{ overcloud_extradisks_check.results }}"
# Generate the `instackenv.json` configuration file. Note that this
# task *must* occur after the above overcloud tasks, because if
# `overcloud_nodes` is defined the template depends on the
# `node_mac_map` variable.
- name: Write instackenv script
template:
src: "{{ undercloud_instackenv_template }}"
dest: "{{ working_dir }}/instackenv.json"
when: create_instackenv_json|default("true")|bool