如何使用Ansible从.vhd文件创建Azure映像

时间:2020-09-14 07:24:47

标签: azure ansible

我正在尝试使用ansible-playbook从vhd创建Azure映像。 vhd文件与ansible-playbook位于同一目录中。 剧本如下:

- name: Create an image from vhd file
  hosts: localhost
  connection: local
  tasks:
  - name: Create an Image from the vhd
    azure_rm_image:
      name: myNewImage
      resource_group: myRG
      source: ./system.vhd
      os_type: Linux

运行此剧本时,出现错误,提示虚拟机ID丢失。 我想从该磁盘创建一个映像,而不从任何现有的vm创建一个映像。 执行该剧本的结果如下:

PLAY [Create an image from os disk] ***************************************************************************************************

TASK [Gathering Facts] ****************************************************************************************************************
[DEPRECATION WARNING]: Distribution Ubuntu 18.04 on host localhost should use /usr/bin/python3, but is using /usr/bin/python for
backward compatibility with prior Ansible releases. A future Ansible release will default to using the discovered platform python for
this host. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information. This feature
 will be removed in version 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
ok: [localhost]

TASK [Create an Image from the vhd] ***************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Error creating image myNewImageLH - Azure Error: InvalidParameter\nMessage: Required parameter 'sourceVirtualMachine.Id' is missing (null).\nTarget: sourceVirtualMachine.Id"}

PLAY RECAP ****************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

请建议需要做什么。

0 个答案:

没有答案