Skip to content

Commit

Permalink
fixing CI
Browse files Browse the repository at this point in the history
Signed-off-by: Danielle Barda <dbarda@redhat.com>
  • Loading branch information
bardielle committed Mar 3, 2024
1 parent e5b88d6 commit d84fd50
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 49 deletions.
16 changes: 13 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,19 @@ jobs:
- name: Checkout repo
uses: actions/checkout@v4
with:
path: ansible_collections/redhat_cop/vmware_ops
path: ansible_collections/cloud/vmware_ops

- name: Install requirements
run: |
ansible-galaxy collection install -r requirements.yml
working-directory: ansible_collections/cloud/vmware_ops

- name: Install python packages from requirements txt file
run: |
pip3 install -r requirements.txt
working-directory: ansible_collections/cloud/vmware_ops

- name: Run
run: |
make integration
working-directory: ansible_collections/redhat_cop/vmware_ops
ANSIBLE_PYTHON_INTERPRETER=/usr/bin/python make integration
working-directory: ansible_collections/cloud/vmware_ops
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
integration:
ansible-test integration --no-temp-workdir security_test
ansible-test integration --no-temp-workdir
4 changes: 2 additions & 2 deletions playbooks/provision_vm/manage_vm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
roles:
- role: cloud.vmware_ops.provision_vm
vars:
clone_from_template: false
clone_from_vm: false
provision_vm_clone_from_template: false
provision_vm_clone_from_vm: false
4 changes: 2 additions & 2 deletions playbooks/provision_vm/provisioning_vm_from_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
roles:
- role: cloud.vmware_ops.provision_vm
vars:
clone_from_template: true
clone_from_vm: false
provision_vm_clone_from_template: true
provision_vm_clone_from_vm: false
5 changes: 2 additions & 3 deletions playbooks/provision_vm/provisioning_vm_from_vm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
roles:
- role: cloud.vmware_ops.provision_vm
vars:
clone_from_template: false
clone_from_vm: true

provision_vm_clone_from_template: false
provision_vm_clone_from_vm: true
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pyVim
pyVmomi
1 change: 0 additions & 1 deletion roles/create_vm_template/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
---
5 changes: 0 additions & 5 deletions roles/create_vm_template/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +0,0 @@
---
# vm name or vm template
- name: Create VM or template
ansible.builtin.include_tasks: "clone_vm_to_template.yml"

10 changes: 5 additions & 5 deletions roles/provision_vm/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Provision virtual machine
A role to provision a virtual machine, create associated resources if they dont exist (subnets, vCPU, memory configuration, storage configuration, etc)
A role to provision a virtual machine, create associated resources if they don't exist (subnets, vCPU, memory configuration, storage configuration, etc)
This includes cloning and building from VM templates.


Expand Down Expand Up @@ -73,7 +73,7 @@ N/A

- **provision_vm_folder** (string):
Destination folder, absolute path to find an existing guest or create the new guest.
The folder should include the datacenter. ESXis datacenter is ha-datacenter.
The folder should include the datacenter. ESXi's datacenter is ha-datacenter.
This parameter is case sensitive.
If multiple machines are found with same name, this parameter is used to identify
uniqueness of the virtual machine.
Expand Down Expand Up @@ -415,7 +415,7 @@ N/A
Valid values are referenced here: https://code.vmware.com/apis/358/doc/vim.vm.GuestOsDescriptor.GuestOsIdentifier.html

- **provision_vm_hardware** (dictionary):
Manage virtual machines hardware attributes.
Manage virtual machine's hardware attributes.
All parameters case sensitive.
Keys:
* hotadd_cpu:
Expand Down Expand Up @@ -532,7 +532,7 @@ N/A
- **provision_vm_state** (string):
Specify the state the virtual machine should be in.
If present and virtual machine exists, ensure the virtual machine configurations conforms to task arguments.
If absent and virtual machine exists, then the specified virtual machine is removed with its associated components.
If absent and virtual machine exists, then the specified virtual machine is removed with it's associated components.
If set to one of poweredon, powered-on, poweredoff, powered-off, present, restarted, suspended and virtual machine does not exists, virtual machine is deployed with the given parameters.
If set to poweredon or powered-on and virtual machine exists with powerstate other than powered on, then the specified virtual machine is powered on.
If set to poweredoff or powered-off and virtual machine exists with powerstate other than powered off, then the specified virtual machine is powered off.
Expand Down Expand Up @@ -612,7 +612,7 @@ N/A
A list of networks (in the order of the NICs).
Removing NICs is not allowed, while reconfiguring the virtual machine.
All parameters and VMware object names are case sensitive.
The type, ip, netmask, gateway, domain, dns_servers options dont set to a guest when creating a blank new virtual machine. They are set by the customization via vmware-tools. If you want to set the value of the options to a guest, you need to clone from a template with installed OS and vmware-tools(also Perl when Linux).
The type, ip, netmask, gateway, domain, dns_servers options don't set to a guest when creating a blank new virtual machine. They are set by the customization via vmware-tools. If you want to set the value of the options to a guest, you need to clone from a template with installed OS and vmware-tools(also Perl when Linux).
Element keys:
* name:
type: str
Expand Down
46 changes: 23 additions & 23 deletions roles/provision_vm/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---
- name: Fail if cluster and esxi_hostname both weren't set or both were set
when: ("{{ cluster }}" is defined and "{{ esxi_hostname }}" is defined) or ("{{ cluster }}" is not defined and "{{ esxi_hostname }}" is not defined)
- name: Fail if provision_vm_cluster and provision_vm_esxi_hostname both weren't set or both were set
when: ( provision_vm_cluster is defined and provision_vm_esxi_hostname is defined ) or ( provision_vm_cluster is not defined and provision_vm_esxi_hostname is not defined) # noqa: yaml[line-length]
ansible.builtin.fail:
msg: esxi_hostname and cluster are mutually exclusive parameters
msg: provision_vm_esxi_hostname and provision_vm_cluster are mutually exclusive parameters

- name: Create or update the VM
community.vmware.vmware_guest:
hostname: "{{ provision_vm_hostname }}"
hostname: "{{ provision_vm_hostname }}"
username: "{{ provision_vm_username }}"
password: "{{ provision_vm_password }}"
validate_certs: "{{ omit if provision_vm_validate_certs is not defined else provision_vm_validate_certs}}"
validate_certs: "{{ omit if provision_vm_validate_certs is not defined else provision_vm_validate_certs }}"

port: "{{ omit if provision_vm_port is not defined else provision_vm_port }}"
proxy_host: "{{ omit if provision_vm_proxy_host is not defined else provision_vm_proxy_host }}"
Expand All @@ -19,22 +19,22 @@
uuid: "{{ omit if provision_vm_uuid is not defined else provision_vm_uuid }}"

# compute resource:
cluster: "{{ omit if provision_vm_cluster not defined else provision_vm_cluster }}"
esxi_hostname: "{{ omit if provision_vm_esxi_hostname is not defined else provision_vm_esxi_hostname}}"
datacenter: "{{ omit if provision_vm_datacenter is not defined else provision_vm_datacenter}}"
folder: "{{ omit if provision_vm_folder is not defined else provision_vm_folder}}"
datastore: "{{ omit if provision_vm_datastore is not defined else provision_vm_datastore}}"
resource_pool: "{{ omit if provision_vm_resource_pool is not defined else provision_vm_resource_pool}}"
cluster: "{{ omit if provision_vm_cluster is not defined else provision_vm_cluster }}"
esxi_hostname: "{{ omit if provision_vm_esxi_hostname is not defined else provision_vm_esxi_hostname }}"
datacenter: "{{ omit if provision_vm_datacenter is not defined else provision_vm_datacenter }}"
folder: "{{ omit if provision_vm_folder is not defined else provision_vm_folder }}"
datastore: "{{ omit if provision_vm_datastore is not defined else provision_vm_datastore }}"
resource_pool: "{{ omit if provision_vm_resource_pool is not defined else provision_vm_resource_pool }}"

# for cloning VM
template: "{{ provision_vm_template }}"
template: "{{ omit if provision_vm_template is not defined else provision_vm_template }}"
convert: "{{ omit if provision_vm_convert is not defined else provision_vm_convert }}"
linked_clone: "{{ omit if provision_vm_linked_clone is not defined else provision_vm_linked_clone }}"
snapshot_src: "{{ omit if provision_vm_snapshot_src is not defined else provision_vm_snapshot_src }}"

# optional:
advanced_settings: "{{ omit if provision_vm_advanced_settings is not defined else provision_vm_advanced_settings}}"
annotation: "{{ omit if provision_vm_annotation is not defined else provision_vm_annotation}}"
advanced_settings: "{{ omit if provision_vm_advanced_settings is not defined else provision_vm_advanced_settings }}"
annotation: "{{ omit if provision_vm_annotation is not defined else provision_vm_annotation }}"
cdrom: "{{ omit if provision_vm_cdrom is not defined else provision_vm_cdrom }}"
customization: "{{ omit if provision_vm_customization is not defined else provision_vm_customization }}"
customization_spec: "{{ omit if provision_vm_customization_spec is not defined else provision_vm_customization_spec }}"
Expand All @@ -45,21 +45,21 @@
force: "{{ omit if provision_vm_force is not defined else provision_vm_force }}"
guest_id: "{{ omit if provision_vm_guest_id is not defined else provision_vm_guest_id }}"
hardware: "{{ omit if provision_vm_hardware is not defined else provision_vm_hardware }}"
state: "{{ omit if provision_vm_state is not defined else provision_vm_state}}"
state_change_timeout: "{{ omit if provision_vm_state_change_timeout is not defined else provision_vm_state_change_timeout}}"
vapp_properties: "{{ omit if provision_vm_vapp_properties is not defined else provision_vm_vapp_properties}}"
wait_for_customization: "{{ omit if provision_vm_wait_for_customization is not defined else provision_vm_wait_for_customization}}"
wait_for_customization_timeout: "{{ omit if provision_vm_wait_for_customization_timeout is not defined else provision_vm_wait_for_customization_timeout}}"
wait_for_ip_address: "{{ omit if provision_vm_wait_for_ip_address is not defined else provision_vm_wait_for_ip_address}}"
wait_for_ip_address_timeout: "{{ omit if provision_vm_wait_for_ip_address_timeout is not defined else provision_vm_wait_for_ip_address_timeout}}"
state: "{{ omit if provision_vm_state is not defined else provision_vm_state }}"
state_change_timeout: "{{ omit if provision_vm_state_change_timeout is not defined else provision_vm_state_change_timeout }}"
vapp_properties: "{{ omit if provision_vm_vapp_properties is not defined else provision_vm_vapp_properties }}"
wait_for_customization: "{{ omit if provision_vm_wait_for_customization is not defined else provision_vm_wait_for_customization }}"
wait_for_customization_timeout: "{{ omit if provision_vm_wait_for_customization_timeout is not defined else provision_vm_wait_for_customization_timeout }}"
wait_for_ip_address: "{{ omit if provision_vm_wait_for_ip_address is not defined else provision_vm_wait_for_ip_address }}"
wait_for_ip_address_timeout: "{{ omit if provision_vm_wait_for_ip_address_timeout is not defined else provision_vm_wait_for_ip_address_timeout }}"
networks: "{{ omit if provision_vm_networks is not defined else provision_vm_networks }}"
nvdimm: "{{ omit if provision_vm_nvdimm is not defined else provision_vm_nvdimm }}"
use_instance_uuid: "{{ omit if provision_vm_use_instance_uuid is not defined else provision_vm_use_instance_uuid }}"
use_instance_uuid: "{{ omit if provision_vm_use_instance_uuid is not defined else provision_vm_use_instance_uuid }}"
name_match: "{{ omit if provision_vm_name_match is not defined else provision_vm_name_match }}"

is_template: false
register: my_vm

- name: Print VM information
ansible.builtin.debug:
var: my_vm
var: my_vm
2 changes: 2 additions & 0 deletions tests/integration/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pyVim
pyVmomi
11 changes: 10 additions & 1 deletion tests/integration/targets/provision_vm_test/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
---
- name: Security role
- name: Provision VM
ansible.builtin.import_role:
name: cloud.vmware_ops.provision_vm
vars:
provision_vm_hostname: "test"
provision_vm_username: "test"
provision_vm_password: "test"
provision_vm_validate_certs: false
provision_vm_cluster: "C0"
provision_vm_datacenter: "DC0"
provision_vm_folder: "folder"
provision_vm_vm_name: "vm-test"
3 changes: 0 additions & 3 deletions tests/integration/targets/provision_vm_test/vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,3 @@ provision_vm_cluster: "cluster_test"
provision_vm_datacenter: "dc_test"
provision_vm_folder: "folder_test"
provision_vm_guest_id: "centos64Guest"



0 comments on commit d84fd50

Please sign in to comment.