首页 > 解决方案 > 是否有用于在 vCenter 中注册 VM 的 rest api 或 ansible 模块

问题描述

我知道我们可以在 PowerCli 中执行此操作,但想知道是否有任何其他方法可以在 vcenter 中注册 VM,例如使用 vcenter api 或 ansible ?

为了将机器vCenter A迁移到vCenter B,我的vRO无法访问vcenterB,但我需要在vCenter B中注册机器。如果我可以使用rest api或ansible模块来完成它会很容易或者在那里一种可以将 VMWare 转换器与 vRO 一起使用的方法?

标签: ansiblevspherepowerclivcenter

解决方案


最近这里有一个模块被添加到 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

推荐阅读