[AIR-134] Add airship gate role
airship-libvirt-gate role is designed to build a fully functioning all-in-one type infrastructure for development, testing or gating purpose on top of libvirt + qemu. It has concept of `Flavor` which would allow users to pick fingerprint (size of the env). In this commit only flavor called `small` is introduced. In near future we will add other flavors. For default usecases please see examples/playbooks/gate directory. Change-Id: Ifefd299592b91ce2810794eb29050874977397f2
This commit is contained in:
parent
cd8fa89488
commit
3f0f471ed3
9
examples/playbooks/gate/airship.yml
Normal file
9
examples/playbooks/gate/airship.yml
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
- hosts: primary
|
||||
tasks:
|
||||
- name: deploy-gate
|
||||
include_role:
|
||||
name: airship-libvirt-gate
|
||||
vars:
|
||||
gate_flavor: small
|
||||
gate_action: build-infra
|
86
roles/airship-libvirt-gate/defaults/main.yml
Normal file
86
roles/airship-libvirt-gate/defaults/main.yml
Normal file
@ -0,0 +1,86 @@
|
||||
airship_gate_names:
|
||||
provision_network: air_prov
|
||||
provision_network_bridge: "prov_br"
|
||||
nat_network: "air_nat"
|
||||
nat_network_bridge: "nat_br"
|
||||
ephemeral_vm: air-ephemeral
|
||||
target_vm_prefix: "air-target"
|
||||
target_separator: "-"
|
||||
target_volume_prefix: "vol_target"
|
||||
ephemeral_volume: "vol_ephemeral"
|
||||
pool: airship
|
||||
|
||||
airship_gate_ipam:
|
||||
nat_network:
|
||||
bridge_ip: "10.23.25.1"
|
||||
dhcp_start: "10.23.25.100"
|
||||
dhcp_end: "10.23.25.199"
|
||||
provision_network:
|
||||
bridge_ip: "10.23.24.1"
|
||||
|
||||
airship_gate_redfish:
|
||||
port: 8000
|
||||
bind_address: "127.0.0.1"
|
||||
|
||||
airship_gate_flavors:
|
||||
small:
|
||||
target_vm_memory_mb: 1024
|
||||
target_vm_vcpus: 1
|
||||
ephemeral_vm_memory_mb: 1024
|
||||
ephemeral_vm_vcpus: 1
|
||||
ephemeral_disk_size: 20G
|
||||
target_disk_size: 10G
|
||||
disk_format: qcow2
|
||||
target_vms_count: 3
|
||||
|
||||
airship_gate_libvirt_pools:
|
||||
- path: /var/lib/libvirt/airship
|
||||
name: "{{ airship_gate_names.pool }}"
|
||||
|
||||
airship_gate_libvirt_domain:
|
||||
state: running
|
||||
name: 'vm1'
|
||||
memory_mb: 2048
|
||||
vcpus: 1
|
||||
volumes:
|
||||
- name: 'volume-1'
|
||||
device: 'disk'
|
||||
format: 'qcow2'
|
||||
pool: 'airship'
|
||||
interfaces:
|
||||
- network: "{{ airship_gate_names.nat_network }}"
|
||||
- network: "{{ airship_gate_names.provision_network }}"
|
||||
|
||||
airship_gate_libvirt_networks:
|
||||
- network_action: create
|
||||
autostart: false
|
||||
name: "{{ airship_gate_names.nat_network }}"
|
||||
spec:
|
||||
forward:
|
||||
mode: nat
|
||||
nat:
|
||||
port:
|
||||
- start: 1024
|
||||
end: 65535
|
||||
bridge:
|
||||
name: "{{ airship_gate_names.nat_network_bridge }}"
|
||||
stp: 'on'
|
||||
delay: '0'
|
||||
ip:
|
||||
address: "{{ airship_gate_ipam.nat_network.bridge_ip }}"
|
||||
netmask: "255.255.255.0"
|
||||
dhcp:
|
||||
- range:
|
||||
start: "{{ airship_gate_ipam.nat_network.dhcp_start }}"
|
||||
end: "{{ airship_gate_ipam.nat_network.dhcp_end }}"
|
||||
- network_action: create
|
||||
autostart: false
|
||||
name: "{{ airship_gate_names.provision_network }}"
|
||||
spec:
|
||||
bridge:
|
||||
name: "{{ airship_gate_names.provision_network_bridge }}"
|
||||
stp: 'on'
|
||||
delay: '0'
|
||||
ip:
|
||||
address: "{{ airship_gate_ipam.provision_network.bridge_ip }}"
|
||||
netmask: "255.255.255.0"
|
103
roles/airship-libvirt-gate/tasks/build-infra.yml
Normal file
103
roles/airship-libvirt-gate/tasks/build-infra.yml
Normal file
@ -0,0 +1,103 @@
|
||||
- name: verify that gate flavor is defined
|
||||
assert:
|
||||
that:
|
||||
- gate_flavor is defined
|
||||
|
||||
- name: set flavor variables.
|
||||
set_fact:
|
||||
chosen_flavor: "{{ airship_gate_flavors[gate_flavor] }}"
|
||||
|
||||
- name: install libvirt
|
||||
include_role:
|
||||
name: libvirt-install
|
||||
|
||||
- name: create pool
|
||||
include_role:
|
||||
name: libvirt-pool
|
||||
vars:
|
||||
libvirt_pool: "{{ item }}"
|
||||
ansible_become: true
|
||||
with_items: "{{ airship_gate_libvirt_pools }}"
|
||||
|
||||
- name: create networks
|
||||
include_role:
|
||||
name: libvirt-network
|
||||
with_items: "{{ airship_gate_libvirt_networks }}"
|
||||
vars:
|
||||
ansible_become: true
|
||||
libvirt_network: "{{ item }}"
|
||||
network_action: create
|
||||
|
||||
- name: Create ephemeral volume
|
||||
include_role:
|
||||
name: libvirt-volume
|
||||
vars:
|
||||
libvirt_volume:
|
||||
name: "{{ airship_gate_names.ephemeral_volume }}"
|
||||
size: "{{ chosen_flavor.ephemeral_disk_size }}"
|
||||
pool: "{{ airship_gate_names.pool }}"
|
||||
volume_action: create
|
||||
ansible_become: true
|
||||
- name: Create target volumes
|
||||
include_role:
|
||||
name: libvirt-volume
|
||||
vars:
|
||||
ansible_become: true
|
||||
libvirt_volume:
|
||||
name: "{{ airship_gate_names.target_volume_prefix }}-{{ vm_index }}"
|
||||
size: "{{ chosen_flavor.target_disk_size }}"
|
||||
pool: "{{ airship_gate_names.pool }}"
|
||||
format: "{{ chosen_flavor.disk_format }}"
|
||||
volume_action: create
|
||||
loop_control:
|
||||
loop_var: vm_index
|
||||
with_sequence: "start=1 end={{ chosen_flavor.target_vms_count }}"
|
||||
|
||||
- name: Create target domains
|
||||
include_role:
|
||||
name: libvirt-domain
|
||||
vars:
|
||||
ansible_become: true
|
||||
libvirt_domain:
|
||||
state: shutdown
|
||||
name: "{{ airship_gate_names.target_vm_prefix }}-{{ vm_index }}"
|
||||
memory_mb: "{{ chosen_flavor.target_vm_memory_mb }}"
|
||||
vcpus: "{{ chosen_flavor.target_vm_vcpus }}"
|
||||
volumes:
|
||||
- name: "{{ airship_gate_names.target_volume_prefix }}-{{ vm_index }}"
|
||||
device: "disk"
|
||||
format: "{{ chosen_flavor.disk_format }}"
|
||||
pool: "{{ airship_gate_names.pool }}"
|
||||
interfaces:
|
||||
- network: "{{ airship_gate_names.nat_network }}"
|
||||
- network: "{{ airship_gate_names.provision_network }}"
|
||||
loop_control:
|
||||
loop_var: vm_index
|
||||
with_sequence: "start=1 end={{ chosen_flavor.target_vms_count }}"
|
||||
|
||||
- name: Create ephemeral domain
|
||||
include_role:
|
||||
name: libvirt-domain
|
||||
vars:
|
||||
ansible_become: true
|
||||
libvirt_domain:
|
||||
state: shutdown
|
||||
name: "{{ airship_gate_names.ephemeral_vm }}"
|
||||
memory_mb: "{{ chosen_flavor.ephemeral_vm_memory_mb }}"
|
||||
vcpus: "{{ chosen_flavor.ephemeral_vm_vcpus }}"
|
||||
volumes:
|
||||
- name: "{{ airship_gate_names.ephemeral_volume }}"
|
||||
device: "disk"
|
||||
format: "{{ chosen_flavor.disk_format }}"
|
||||
pool: "{{ airship_gate_names.pool }}"
|
||||
interfaces:
|
||||
- network: "{{ airship_gate_names.nat_network }}"
|
||||
- network: "{{ airship_gate_names.provision_network }}"
|
||||
|
||||
- name: install and start redfish emulator
|
||||
include_role:
|
||||
name: redfish-emulator
|
||||
vars:
|
||||
redfish_action: "install"
|
||||
redfish_emulator_bind_ip: "{{ airship_gate_redfish.bind_address }}"
|
||||
redfish_emulator_bind_port: "{{ airship_gate_redfish.port }}"
|
1
roles/airship-libvirt-gate/tasks/main.yml
Normal file
1
roles/airship-libvirt-gate/tasks/main.yml
Normal file
@ -0,0 +1 @@
|
||||
- include_tasks: "{{ gate_action }}.yml"
|
41
roles/airship-libvirt-gate/tests/main.yml
Normal file
41
roles/airship-libvirt-gate/tests/main.yml
Normal file
@ -0,0 +1,41 @@
|
||||
- name: Include test variables.
|
||||
include_vars:
|
||||
file: vars.yml
|
||||
|
||||
- name: deploy-gate
|
||||
include_role:
|
||||
name: airship-libvirt-gate
|
||||
vars:
|
||||
gate_flavor: small
|
||||
gate_action: build-infra
|
||||
|
||||
- name: query redfish to make sure it has runnig domains
|
||||
uri:
|
||||
url: http://{{ airship_gate_redfish.bind_address }}:{{ airship_gate_redfish.port }}/redfish/v1/Systems?format=json
|
||||
method: GET
|
||||
return_content: yes
|
||||
register: redfish_response
|
||||
|
||||
- name: debug redfish machines
|
||||
debug:
|
||||
var: redfish_response
|
||||
|
||||
- name: save ids to list
|
||||
uri:
|
||||
url: "http://{{ airship_gate_redfish.bind_address }}:{{ airship_gate_redfish.port }}{{ item.value }}?format=json"
|
||||
method: GET
|
||||
return_content: yes
|
||||
with_dict: "{{ redfish_response.json.Members }}"
|
||||
register: systems_details
|
||||
|
||||
- name: deploy ephemeral host
|
||||
set_fact:
|
||||
ephemeral_domain_id: "{{ systems_details | json_query(query_string) | join('') }}"
|
||||
vars:
|
||||
query_string: "results[?json.Name=='{{ airship_gate_names.ephemeral_vm }}'].json.Id"
|
||||
|
||||
- name: verify that id is not empty
|
||||
assert:
|
||||
that:
|
||||
- ephemeral_domain_id is defined
|
||||
- (ephemeral_domain_id | length) > 1
|
15
roles/airship-libvirt-gate/tests/vars.yml
Normal file
15
roles/airship-libvirt-gate/tests/vars.yml
Normal file
@ -0,0 +1,15 @@
|
||||
airship_gate_redfish:
|
||||
port: 8000
|
||||
bind_address: "127.0.0.1"
|
||||
|
||||
airship_gate_names:
|
||||
provision_network: air_prov
|
||||
provision_network_bridge: "prov_br"
|
||||
nat_network: "air_nat"
|
||||
nat_network_bridge: "nat_br"
|
||||
ephemeral_vm: air-ephemeral
|
||||
target_vm_prefix: "air-target"
|
||||
target_separator: "-"
|
||||
target_volume_prefix: "vol_target"
|
||||
ephemeral_volume: "vol_ephemeral"
|
||||
pool: airship
|
@ -9,6 +9,7 @@
|
||||
- libvirt-volume
|
||||
- libvirt-domain
|
||||
- redfish-emulator
|
||||
- airship-libvirt-gate
|
||||
- name: run tests against defined roles
|
||||
include_tasks: "../../roles/{{ role_name }}/tests/main.yml"
|
||||
with_items: "{{ test_subject_roles | default(test_subject_roles_default) }}"
|
||||
|
@ -24,4 +24,14 @@
|
||||
- libvirt-pool
|
||||
- libvirt-volume
|
||||
- libvirt-domain
|
||||
- redfish-emulator
|
||||
nodeset: ubuntu-single-airship
|
||||
|
||||
- job:
|
||||
name: zuul-airship-roles-test-airship-gate
|
||||
run: tests/ansible/role-test-runner.yml
|
||||
vars:
|
||||
test_subject_roles:
|
||||
- airship-libvirt-gate
|
||||
nodeset: ubuntu-single-airship
|
||||
|
||||
|
@ -3,7 +3,9 @@
|
||||
jobs:
|
||||
- ansible-lint-airship
|
||||
- zuul-airship-roles-test-libvirt
|
||||
- zuul-airship-roles-test-airship-gate
|
||||
gate:
|
||||
jobs:
|
||||
- ansible-lint-airship
|
||||
- zuul-airship-roles-test-libvirt
|
||||
- zuul-airship-roles-test-airship-gate
|
||||
|
Loading…
x
Reference in New Issue
Block a user