Gate scripts refactoring

Added flexible boot mode configuration for VMs based on BareMetalHost definition.

Change-Id: I1332ff99e7ec539ac280efda515f736b7c18f459
This commit is contained in:
Stanislav Egorov 2020-08-19 12:55:48 -07:00
parent 35cdb66e78
commit 2605cd9159
3 changed files with 25 additions and 19 deletions

View File

@ -60,9 +60,9 @@
- name: clone document model - name: clone document model
command: git clone -q {{ airship_config_primary_repo_url }} {{ remote_work_dir }} command: git clone -q {{ airship_config_primary_repo_url }} {{ remote_work_dir }}
when: remote_work_dir is defined when: remote_work_dir is defined
- name: get MACs from BareMetalHost objects - name: get VM config(MACs and bootMode) from BareMetalHost objects
include_tasks: include_tasks:
file: get-mac-addresses.yaml file: get-vm-config.yaml
vars: vars:
name: "{{ roleinputvar.name }}" name: "{{ roleinputvar.name }}"
path: "{{ roleinputvar.path }}" path: "{{ roleinputvar.path }}"
@ -85,19 +85,19 @@
name: "default" name: "default"
airship_gate_flavors: airship_gate_flavors:
medium: medium:
target_vm_memory_mb: 4096 disk_format: qcow2
target_vm_vcpus: 2 ephemeral_disk_size: 20G
ephemeral_vm_cfg: "{{ ephemeral_vm_cfg }}"
ephemeral_vm_memory_mb: 6124 ephemeral_vm_memory_mb: 6124
ephemeral_vm_vcpus: 4 ephemeral_vm_vcpus: 4
ephemeral_disk_size: 20G
ephemeral_vm_nics: "{{ ephemeral_vm_nics }}"
target_disk_size: 10G target_disk_size: 10G
disk_format: qcow2 target_vm_cfg: "{{ target_vm_cfg }}"
target_vm_memory_mb: 4096
target_vm_vcpus: 2
target_vms_count: 1 target_vms_count: 1
target_vm_nics: "{{ target_vm_nics }}" worker_disk_size: 10G
worker_vm_memory_mb: 1024 worker_vm_memory_mb: 1024
worker_vm_vcpus: 1 worker_vm_vcpus: 1
worker_disk_size: 10G
worker_vms_count: 1 worker_vms_count: 1
airship_gate_file_exchanger: airship_gate_file_exchanger:
servername: "localhost" servername: "localhost"

View File

@ -21,8 +21,10 @@
environment: environment:
KUSTOMIZE_PLUGIN_HOME: "{{ ansible_env.HOME }}/.airship/kustomize-plugins" KUSTOMIZE_PLUGIN_HOME: "{{ ansible_env.HOME }}/.airship/kustomize-plugins"
KUSTOMIZE_ENABLE_ALPHA_COMMANDS: "true" KUSTOMIZE_ENABLE_ALPHA_COMMANDS: "true"
- set_fact: - set_fact:
bmh: "{{ bmh_command.stdout | from_yaml_all | list }}" bmh: "{{ bmh_command.stdout | from_yaml_all | list }}"
- name: get network configuration for BareMetalHost objects - name: get network configuration for BareMetalHost objects
shell: | shell: |
set -e set -e
@ -35,6 +37,7 @@
KUSTOMIZE_PLUGIN_HOME: "{{ ansible_env.HOME }}/.airship/kustomize-plugins" KUSTOMIZE_PLUGIN_HOME: "{{ ansible_env.HOME }}/.airship/kustomize-plugins"
KUSTOMIZE_ENABLE_ALPHA_COMMANDS: "true" KUSTOMIZE_ENABLE_ALPHA_COMMANDS: "true"
with_items: "{{ bmh }}" with_items: "{{ bmh }}"
- name: get links from network data per BareMetalHost object - name: get links from network data per BareMetalHost object
set_fact: set_fact:
links: | links: |
@ -44,9 +47,10 @@
map(attribute='stringData.networkData') | map('from_yaml') | map(attribute='stringData.networkData') | map('from_yaml') |
map(attribute='links') | list map(attribute='links') | list
}} }}
- name: define list of VM mac addresses
- name: define list of VM mac addresses and VM boot mode
set_fact: set_fact:
vm_nic: "{{ dict(['nat_mac', 'provision_mac'] | zip([nat_mac_list[0], item.spec.bootMACAddress])) }}" vm_cfg: "{{ dict(['boot_mode', 'nat_mac', 'provision_mac'] | zip([item.spec.bootMode, nat_mac_list[0], item.spec.bootMACAddress])) }}"
vars: vars:
nat_mac_list: | nat_mac_list: |
{{ {{
@ -59,6 +63,7 @@
loop: "{{ bmh }}" loop: "{{ bmh }}"
loop_control: loop_control:
index_var: idx index_var: idx
register: vm_nic_fact register: vm_cfg_fact
- set_fact: - set_fact:
"{{ name }}_vm_nics": "{{ vm_nic_fact.results | map(attribute='ansible_facts.vm_nic') | list }}" "{{ name }}_vm_cfg": "{{ vm_cfg_fact.results | map(attribute='ansible_facts.vm_cfg') | list }}"

View File

@ -51,6 +51,7 @@
size: "{{ chosen_flavor.ephemeral_disk_size }}" size: "{{ chosen_flavor.ephemeral_disk_size }}"
pool: "{{ airship_gate_names.pool }}" pool: "{{ airship_gate_names.pool }}"
volume_action: create volume_action: create
- name: Create target volumes - name: Create target volumes
include_role: include_role:
name: libvirt-volume name: libvirt-volume
@ -70,7 +71,7 @@
name: libvirt-domain name: libvirt-domain
vars: vars:
libvirt_domain: libvirt_domain:
boot_mode: UEFI boot_mode: "{{ chosen_flavor.target_vm_cfg[vm_index|int - 1].boot_mode | default('UEFI') }}"
enable_vnc: true enable_vnc: true
console_log_enabled: true console_log_enabled: true
state: shutdown state: shutdown
@ -88,9 +89,9 @@
pool: "{{ airship_gate_names.pool }}" pool: "{{ airship_gate_names.pool }}"
interfaces: interfaces:
- network: "{{ airship_gate_names.nat_network }}" - network: "{{ airship_gate_names.nat_network }}"
mac: "{{ chosen_flavor.target_vm_nics[vm_index|int - 1].nat_mac | default('')}}" mac: "{{ chosen_flavor.target_vm_cfg[vm_index|int - 1].nat_mac | default('') }}"
- network: "{{ airship_gate_names.provision_network }}" - network: "{{ airship_gate_names.provision_network }}"
mac: "{{ chosen_flavor.target_vm_nics[vm_index|int - 1].provision_mac | default('')}}" mac: "{{ chosen_flavor.target_vm_cfg[vm_index|int - 1].provision_mac | default('') }}"
loop_control: loop_control:
loop_var: vm_index loop_var: vm_index
with_sequence: "start=1 end={{ chosen_flavor.target_vms_count }}" with_sequence: "start=1 end={{ chosen_flavor.target_vms_count }}"
@ -100,7 +101,7 @@
name: libvirt-domain name: libvirt-domain
vars: vars:
libvirt_domain: libvirt_domain:
boot_mode: UEFI boot_mode: "{{ chosen_flavor.ephemeral_vm_cfg[0].boot_mode | default('UEFI') }}"
enable_vnc: true enable_vnc: true
console_log_enabled: true console_log_enabled: true
state: shutdown state: shutdown
@ -114,9 +115,9 @@
pool: "{{ airship_gate_names.pool }}" pool: "{{ airship_gate_names.pool }}"
interfaces: interfaces:
- network: "{{ airship_gate_names.nat_network }}" - network: "{{ airship_gate_names.nat_network }}"
mac: "{{ chosen_flavor.ephemeral_vm_nics[0].nat_mac | default('')}}" mac: "{{ chosen_flavor.ephemeral_vm_cfg[0].nat_mac | default('') }}"
- network: "{{ airship_gate_names.provision_network }}" - network: "{{ airship_gate_names.provision_network }}"
mac: "{{ chosen_flavor.ephemeral_vm_nics[0].provision_mac | default('')}}" mac: "{{ chosen_flavor.ephemeral_vm_cfg[0].provision_mac | default('') }}"
- name: Add noauth sushy-emulator to apache - name: Add noauth sushy-emulator to apache
include_role: include_role: