Skip to content

Commit

Permalink
Provisioning VM role
Browse files Browse the repository at this point in the history
  • Loading branch information
bardielle committed Feb 28, 2024
1 parent 85a8c25 commit e22e790
Show file tree
Hide file tree
Showing 15 changed files with 610 additions and 20 deletions.
11 changes: 11 additions & 0 deletions playbooks/provision_vm/manage_vm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
- name: Playbook to provision a new VM on VMware
hosts: all
gather_facts: false

vars:
clone_from_template: false
clone_from_vm: false

roles:
- role: redhat_cop.vmware_ops.provisioning_vm
20 changes: 0 additions & 20 deletions playbooks/provision_vm/provision_vm.yml

This file was deleted.

11 changes: 11 additions & 0 deletions playbooks/provision_vm/provisioning_vm_from_template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
- name: Playbook to provision a new VM from template on VMware
hosts: all
gather_facts: false

vars:
clone_from_template: true
clone_from_vm: false

roles:
- role: redhat_cop.vmware_ops.provisioning_vm

Check failure on line 11 in playbooks/provision_vm/provisioning_vm_from_template.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

syntax-check[specific]

the role 'redhat_cop.vmware_ops.provisioning_vm' was not found in /home/runner/work/cloud.vmware_ops/cloud.vmware_ops/playbooks/provision_vm/roles:/home/runner/.cache/ansible-compat/c43c03/roles:/home/runner/work/cloud.vmware_ops/cloud.vmware_ops/roles:/home/runner/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/home/runner/work/cloud.vmware_ops/cloud.vmware_ops/playbooks/provision_vm
12 changes: 12 additions & 0 deletions playbooks/provision_vm/provisioning_vm_from_vm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
- name: Playbook to provision a new VM from an existing VM on VMware
hosts: all
gather_facts: false

vars:
clone_from_template: false
clone_from_vm: true

roles:
- role: redhat_cop.vmware_ops.provisioning_vm

Check failure on line 11 in playbooks/provision_vm/provisioning_vm_from_vm.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

syntax-check[specific]

the role 'redhat_cop.vmware_ops.provisioning_vm' was not found in /home/runner/work/cloud.vmware_ops/cloud.vmware_ops/playbooks/provision_vm/roles:/home/runner/.cache/ansible-compat/c43c03/roles:/home/runner/work/cloud.vmware_ops/cloud.vmware_ops/roles:/home/runner/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/home/runner/work/cloud.vmware_ops/cloud.vmware_ops/playbooks/provision_vm

69 changes: 69 additions & 0 deletions roles/create_vm_template/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
Provision virtual machine
================

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
Boot a VM from these types:
* Windows Server
* RHEL8
* RHEL9


Requirements
------------

vCenter logged in permission

Role Variables
--------------

* **vcenter_hostname** (str): (Required)
* **vcenter_username** (str): (Required)
* **vcenter_password** (str): (Required)
* **vcenter_validate_certs** (str): (Required)
* **provision_virtual_machine_operation** (str): (Required) Operation to perform. Valid values are:
clone_an_existing_vm, clone_template_to_template, clone_vm_to_template, create_new_vm, create_vm_from_template,
deploy_from_template.

Dependencies
------------

N/A

Example Playbook
----------------

All the variables defined in section [Role Variables](#role-variables) can be defined inside the ``vars.yml`` file.

Create a ``playbook.yml`` file like this:

```
---
- hosts: localhost
gather_facts: true
tasks:
- name: Provision a VM
ansible.builtin.import_role:
name: cloud.vmware_ops.provision_virtual_machine
vars:
aa: "{{ }}"
```

Run the playbook:

```shell
ansible-playbook playbook.yml -e "@vars.yml"
```

License
-------

GNU General Public License v3.0 or later

See [LICENCE](https://github.com/ansible-collections/cloud.vmware_ops/blob/main/LICENSE) to see the full text.

Author Information
------------------

- ??
1 change: 1 addition & 0 deletions roles/create_vm_template/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
Empty file.
Empty file.
5 changes: 5 additions & 0 deletions roles/create_vm_template/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
# vm name or vm template
- name: Create VM or template
ansible.builtin.include_tasks: "clone_vm_to_template.yml"

Loading

0 comments on commit e22e790

Please sign in to comment.