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 aafb5b2
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 41 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ jobs:
- name: Checkout repo
uses: actions/checkout@v4
with:
path: ansible_collections/redhat_cop/vmware_ops
path: ansible_collections/cloud/vmware_ops

- name: Run
run: |
make integration
working-directory: ansible_collections/redhat_cop/vmware_ops
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
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
40 changes: 20 additions & 20 deletions roles/provision_vm/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
- 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

Check failure on line 2 in roles/provision_vm/tasks/main.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

no-jinja-when

No Jinja2 in when.
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)

Check failure on line 3 in roles/provision_vm/tasks/main.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

yaml[line-length]

Line too long (207 > 160 characters)
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 }}"

Check warning on line 9 in roles/provision_vm/tasks/main.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

jinja[spacing]

Jinja2 spacing could be improved: {{ omit if provision_vm_validate_certs is not defined else provision_vm_validate_certs}} -> {{ omit if provision_vm_validate_certs is not defined else provision_vm_validate_certs }}

Check failure on line 9 in roles/provision_vm/tasks/main.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

jinja[invalid]

template error while templating string: expected token 'end of print statement', got 'not'. String: {{ omit if provision_vm_cluster not defined else provision_vm_cluster }}. expected token 'end of print statement', got 'not'
username: "{{ provision_vm_username }}"
password: "{{ provision_vm_password }}"
validate_certs: "{{ omit if provision_vm_validate_certs is not defined else provision_vm_validate_certs}}"
Expand All @@ -20,11 +20,11 @@

# 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}}"
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 }}"
Expand All @@ -33,8 +33,8 @@
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
12 changes: 11 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,14 @@
---
- name: Security role
- name: Provision VM
ansible.builtin.import_role:
var:
provision_vm_hostname: "test"
provision_vm_username: "test"
provision_vm_password: "test"
validate_certs: false
provision_vm_cluster: "C0"
provision_vm_datacenter: "DC0"
provision_vm_folder: "folder"
provision_vm_vm_name: "vm-test"

name: cloud.vmware_ops.provision_vm

0 comments on commit aafb5b2

Please sign in to comment.