فهرست منبع

openshift_ovirt: Add a task to create the VMs

The role now will create the VMs using the oVirt.image-template and
oVirt.vm-infra roles. The output vms goes into the inventor, if wait_for_ip is true.

Signed-off-by: Roy Golan <rgolan@redhat.com>
Roy Golan 6 سال پیش
والد
کامیت
e7d694454c

+ 23 - 15
roles/openshift_ovirt/README.md

@@ -2,10 +2,23 @@
 
 OpenShift Provisioned on Red Hat Virtualization and oVirt
 
+The puprpose of the role is to create the VMs, by a recepie, using vars, and generate an inventory. \
+The generated inventory can be merged into and openshift inventory(see examples dir[1]) and to ease the deployment a lot.
+
+- [OpenShift oVirt](#openshift-ovirt)
+  * [Role Tasks](#role-tasks)
+  * [Role Variables](#role-variables)
+  * [Examples](#examples)
+    + [Manifest](#manifest)
+    + [Playbook](#playbook)
+  * [License](#license)
+
 ## Role Tasks
 
-* `build_vm_list.yml`: Creates a list of virtual machine definitions and
+- `main.yaml`: The entrypoint to the role. It invokes the following tasks below.
+- `build_vm_list.yml`: Creates a list of virtual machine definitions and
   affinity groups based on a simple manifest (below)
+- `create_vms.yaml`: consumes the output of the former task and create vms for the nodes of the cluster. It generates an inventory of nodes.
 
 ## Role Variables
 
@@ -26,16 +39,17 @@ Below `nic_mode` we can find this other parameters
 
 | Name            |  Type  | Default value |                                          |
 |-----------------|--------|---------------|------------------------------------------|
-| nic_ip_address  | String | UNDEF         | Static ipaddress for vm interface.       | 
-| nic_netmask     | String | UNDEF         | Static Netmask for vm interface .        | 
-| nic_gateway     | String | UNDEF         | Static Gateway address for vm interface. | 
-| nic_on_boot     | Bool   | True          | The interface will be up on boot.        | 
-| nic_name        | String | 'eth0'        | The Interface name for the vm.           | 
-| dns_servers     | String | UNDEF         | The DNS set on the VM.                   | 
+| nic_ip_address  | String | UNDEF         | Static ipaddress for vm interface.       |
+| nic_netmask     | String | UNDEF         | Static Netmask for vm interface .        |
+| nic_gateway     | String | UNDEF         | Static Gateway address for vm interface. |
+| nic_on_boot     | Bool   | True          | The interface will be up on boot.        |
+| nic_name        | String | 'eth0'        | The Interface name for the vm.           |
+| dns_servers     | String | UNDEF         | The DNS set on the VM.                   |
 
 
 ## Examples
 
+### Manifest
 - **openshift_ovirt_vm_profile**
 
 ```
@@ -148,8 +162,7 @@ openshift_ovirt_vm_manifest:
         dns_servers: "192.168.1.100"
 ```
 
-Example Playbook
-----------------
+### Playbook
 
 ```
 ---
@@ -168,14 +181,9 @@ Example Playbook
         insecure: "{{ engine_insecure | default(true) }}"
       tags:
         - always
-    - name: Build virtual machine facts
-      import_role:
-        name: openshift_ovirt
-        tasks_from: build_vm_list.yml
 
   roles:
-    - oVirt.image-template
-    - oVirt.vm-infra
+    - openshift_ovirt
 
   post_tasks:
     - name: Logout from oVirt

+ 2 - 1
roles/openshift_ovirt/defaults/main.yml

@@ -6,8 +6,9 @@ wait_for_ip: true
 openshift_ovirt_cluster: Default
 template_name: openshift_node
 
-# User must provide the dns zone
+# User must provide those vars:
 openshift_ovirt_dns_zone:
+openshift_ovirt_ssh_key:
 
 # oVirt VM Profiles
 openshift_ovirt_vm_profile:

+ 24 - 0
roles/openshift_ovirt/tasks/create_vms.yaml

@@ -0,0 +1,24 @@
+---
+- debug:
+    var: vms
+- fail:
+    msg: "The vms fact is not set. Run build_vm_list task from this role"
+  when:
+  - vms is none
+
+- name: check if the template already exists
+  ovirt_templates_facts:
+    pattern: "name={{ template_name }} and storage.name={{ openshift_ovirt_data_store }}"
+    auth: "{{ ovirt_auth }}"
+
+# Upload the template if it doesn't exist already
+- import_role:
+    name: oVirt.image-template
+  when:
+    not ovirt_templates
+
+- import_role:
+    name: oVirt.vm-infra
+- name: print all created vms that are in the inventory
+  debug:
+    var: hostvars

+ 4 - 0
roles/openshift_ovirt/tasks/main.yaml

@@ -0,0 +1,4 @@
+---
+- include_tasks: build_vm_list.yaml
+
+- include_tasks: create_vms.yaml