是否有 rest api 或 ansible 模块来在 vCenter 中注册 VM
Is there an rest api or ansible module to register an VM in vCenter
我知道我们可以在 PowerCli 中执行此操作,但想知道是否有任何其他方法可以在 vcenter 中注册 VM,例如使用 vcenter api 或 ansible?
为了将机器 vCenter A 迁移到 vCenter B,我的 vRO 没有访问 vcenterB 的权限,但我需要在 vCenter B 中注册机器。如果我可以使用 rest 就容易了 api或 ansible 模块来做到这一点,或者有什么方法可以将 VMWare 转换器与 vRO 一起使用?
最近,Ansible 中添加了一个模块,可以做到这一点。模块:https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/cloud/vmware/vmware_guest_register_operation.py
一些示例代码:
- name: Register VM to inventory
vmware_guest_register_operation:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: no
datacenter: "{{ datacenter }}"
folder: "/vm"
esxi_hostname: "{{ esxi_hostname }}"
name: "{{ vm_name }}"
template: no
path: "[datastore1] vm/vm.vmx"
state: present
我知道我们可以在 PowerCli 中执行此操作,但想知道是否有任何其他方法可以在 vcenter 中注册 VM,例如使用 vcenter api 或 ansible?
为了将机器 vCenter A 迁移到 vCenter B,我的 vRO 没有访问 vcenterB 的权限,但我需要在 vCenter B 中注册机器。如果我可以使用 rest 就容易了 api或 ansible 模块来做到这一点,或者有什么方法可以将 VMWare 转换器与 vRO 一起使用?
最近,Ansible 中添加了一个模块,可以做到这一点。模块:https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/cloud/vmware/vmware_guest_register_operation.py
一些示例代码:
- name: Register VM to inventory
vmware_guest_register_operation:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: no
datacenter: "{{ datacenter }}"
folder: "/vm"
esxi_hostname: "{{ esxi_hostname }}"
name: "{{ vm_name }}"
template: no
path: "[datastore1] vm/vm.vmx"
state: present