azure.azcollection.azure_rm_galleryimageversion 模块 – 管理 Azure SIG 镜像版本实例

注意

此模块是 azure.azcollection 集合(版本 3.1.0)的一部分。

如果您正在使用 ansible 包,则可能已经安装了此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用:ansible-galaxy collection install azure.azcollection。您需要进一步的要求才能使用此模块,请参阅 要求 以了解详细信息。

要在 playbook 中使用它,请指定:azure.azcollection.azure_rm_galleryimageversion

azure.azcollection 0.1.2 中的新增功能

概要

  • 创建、更新和删除 Azure SIG 镜像版本实例。

要求

执行此模块的主机上需要以下要求。

  • python >= 2.7

  • 执行此模块的主机必须通过 galaxy 安装 azure.azcollection 集合

  • 必须通过 pip 在执行来自 azure.azcollection 的模块的主机上安装 collection’s requirements.txt 中列出的所有 python 包

  • 完整的安装说明可以在 https://galaxy.ansible.com/azure/azcollection 中找到

参数

参数

注释

ad_user

string

Active Directory 用户名。当使用 Active Directory 用户而不是服务主体进行身份验证时使用。

adfs_authority_url

string

在 azure.azcollection 0.0.1 中添加

Azure AD 授权 URL。当使用用户名/密码进行身份验证,并且具有您自己的 ADFS 授权时使用。

api_profile

string

在 azure.azcollection 0.0.1 中添加

选择与 Azure 服务通信时使用的 API 配置文件。默认值 latest 适用于公共云;未来的值将允许与 Azure Stack 一起使用。

默认: "latest"

append_tags

boolean

用于控制 tags 字段是规范的还是仅追加到现有 tags。

当为规范时,在 tags 参数中找不到的任何标签都将从对象的元数据中删除。

选项

  • false

  • true ←(默认)

auth_source

string

在 azure.azcollection 0.0.1 中添加

控制用于身份验证的凭据的来源。

也可以通过 ANSIBLE_AZURE_AUTH_SOURCE 环境变量设置。

当设置为 auto(默认值)时,优先级为模块参数 -> env -> credential_file -> cli

当设置为 env 时,将从环境变量中读取凭据

当设置为 credential_file 时,它将从 ~/.azure/credentials 读取配置文件。

当设置为 cli 时,凭据将来自 Azure CLI 配置文件。subscription_id 或环境变量 AZURE_SUBSCRIPTION_ID 可用于标识订阅 ID(如果存在多个订阅 ID),否则使用默认的 az cli 订阅。

当设置为 msi 时,主机必须是具有启用 MSI 扩展的 Azure 资源。subscription_id 或环境变量 AZURE_SUBSCRIPTION_ID 可用于标识订阅 ID(如果资源被授予对多个订阅的访问权限),否则选择第一个订阅。

msi 在 Ansible 2.6 中添加。

选项

  • "auto" ←(默认)

  • "cli"

  • "credential_file"

  • "env"

  • "msi"

cert_validation_mode

string

在 azure.azcollection 0.0.1 中添加

控制 Azure 端点的证书验证行为。默认情况下,所有模块都将验证服务器证书,但是当使用 HTTPS 代理时,或者针对 Azure Stack 时,可能需要通过传递 ignore 来禁用此行为。也可以通过凭据文件配置文件或 AZURE_CERT_VALIDATION 环境变量设置。

选项

  • "ignore"

  • "validate"

client_id

string

Azure 客户端 ID。当使用服务主体或托管标识 (msi) 进行身份验证时使用。

也可以通过 AZURE_CLIENT_ID 环境变量设置。

cloud_environment

string

在 azure.azcollection 0.0.1 中添加

对于美国公共云以外的云环境,可以使用环境名称(由 Azure Python SDK 定义,例如 AzureChinaCloudAzureUSGovernment),或者元数据发现端点 URL(Azure Stack 需要)。也可以通过凭据文件配置文件或 AZURE_CLOUD_ENVIRONMENT 环境变量进行设置。

默认值: "AzureCloud"

disable_instance_discovery

boolean

在 azure.azcollection 2.3.0 中添加

确定在尝试进行身份验证时是否执行实例发现。将其设置为 true 将完全禁用实例发现和授权验证。此功能旨在用于无法访问元数据端点的情况,例如在私有云或 Azure Stack 中。实例发现的过程包括从 https://login.microsoft.com/ 检索授权元数据以验证授权。通过将此项设置为 **True**,将禁用授权验证。因此,务必确保配置的授权主机是有效且可信的。

通过凭据文件配置文件或 AZURE_DISABLE_INSTANCE_DISCOVERY 环境变量设置。

选项

  • false ← (默认)

  • true

字符串 / 必需

要在其中创建映像版本的库映像定义的名称。

字符串 / 必需

共享映像库(映像定义位于其中)的名称。

location

string

资源位置。

log_mode

string

父参数。

log_path

string

父参数。

name

字符串 / 必需

要创建的库映像版本的名称。

需要遵循语义版本命名模式,允许的字符是数字和句点。

数字必须在 32 位整数的范围内。例如,<主版本号>.<次版本号>.<修补程序版本号>。

password

string

Active Directory 用户密码。当使用 Active Directory 用户而不是服务主体进行身份验证时使用。

profile

string

在 ~/.azure/credentials 文件中找到的安全配置文件。

publishing_profile

字典

发布配置文件。

end_of_life_date

string

库映像版本的生命周期结束日期。

此属性可用于停用目的。

此属性可更新。格式应符合 ISO-8601,例如“2019-06-26”。

exclude_from_latest

boolean

如果exclude_from_latest=true,则从映像定义的最新版本部署的虚拟机将不使用此映像版本。

选项

  • false

  • true

managed_image

任何

托管映像引用,可以是资源 ID,也可以是包含 resource_groupname 的字典

自 2.10 版本起已过时,请改用 storage_profile

replica_count

整数

每个区域要创建的映像版本的副本数。

当未指定 regionalReplicaCount 时,此属性将对区域生效。

此属性可更新。

snapshot

任何

要使用的源快照。

自 2.10 版本起已过时,请改用 storage_profile

storage_account_type

string

指定用于存储映像的存储帐户类型。

此属性不可更新。

选项

  • "Standard_LRS"

  • "Standard_ZRS"

target_regions

列表 / 元素=任何

要将映像版本复制到的目标区域。

此属性可更新。

encryption

字典

允许用户为库项目中的 OS 和数据磁盘加密提供客户管理的密钥。

data_disk_images

列表 / 元素=字典

数据磁盘映像的加密规范列表。

disk_encryption_set_id

string

包含磁盘加密集的资源 ID 的相对 URI。

lun

整数

此属性指定数据磁盘的逻辑单元号。

此值用于标识虚拟机内的数据磁盘,因此必须对于附加到虚拟机的每个数据磁盘都是唯一的。

os_disk_image

字典

包含 OS 磁盘映像的加密设置。

disk_encryption_set_id

string

包含磁盘加密集的资源 ID 的相对 URI。

security_profile

字典

此属性指定 OS 磁盘映像的安全配置文件。

confidential_vm_encryption_type

字典

机密 VM 加密类型。

encrypted_vm_guest_state_only_with_pmk

string

仅使用 PMK 的 VM 来宾状态。

encrypted_with_cmk

string

使用 CMK 加密。

encrypted_with_pmk

string

使用 PMK 加密。

secure_vm_disk_encryption_set_id

string

安全 VM 磁盘加密集 ID。

name

字符串 / 必需

区域名称。

regional_replica_count

整数

每个区域要创建的映像版本的副本数。

当未指定 regionalReplicaCount 时,此属性将对区域生效。

此属性可更新。

storage_account_type

string

存储帐户类型。

resource_group

字符串 / 必需

资源组的名称。

secret

string

Azure 客户端密钥。使用服务主体进行身份验证时使用。

state

string

声明 GalleryImageVersion 的状态。

使用 present 创建或更新 GalleryImageVersion,使用 absent 将其删除。

选项

  • "absent"

  • "present" ← (默认)

storage_profile

字典

存储配置文件

创建时必需。

data_disks

列表 / 元素=任何

数据磁盘快照列表

与 source_image 互斥

host_caching

string

主机磁盘缓存

选项

  • "None" ← (默认)

  • "ReadOnly"

  • "ReadWrite"

lun

整数

数据磁盘的 lun

source

任何

对数据磁盘快照的引用。可以是资源 ID,也可以是包含 resource_groupname 的字典

os_disk

字典

os 磁盘快照

与 source_image 互斥

host_caching

string

主机磁盘缓存

选项

  • "None" ← (默认)

  • "ReadOnly"

  • "ReadWrite"

source

任何

对 os 磁盘快照的引用。

可以是资源 ID。

可以是包含 resource_groupname 的字典。

如果快照存储为存储帐户容器中的 PageBlob,则可以是包含 resource_groupstorage_accounturi 的字典。

source_image

任何

对托管映像或库映像版本的引用

可以是托管映像的资源 ID,也可以是包含 resource_groupname 的字典

可以是映像版本的资源 ID,也可以是包含 resource_groupgallery_namegallery_image_nameversion 的字典

与 os_disk 和 data_disks 互斥

subscription_id

string

您的 Azure 订阅 ID。

tags

字典

要分配为对象元数据的字符串:字符串对的字典。

对象的元数据标记将使用任何提供的值进行更新。

要删除标记,请将 append_tags 选项设置为 false。

当前,Azure DNS 区域和流量管理器服务也不允许在标记中使用空格。

Azure Front Door 不支持使用

Azure Automation 和 Azure CDN 仅支持资源上的 15 个标记。

tenant

string

Azure 租户 ID。使用服务主体进行身份验证时使用。

thumbprint

string

在 azure.azcollection 1.14.0 中添加

x509_certificate_path 中指定的私钥的指纹。

使用服务主体进行身份验证时使用。

如果定义了 x509_certificate_path,则为必需项。

x509_certificate_path

路径

在 azure.azcollection 1.14.0 中添加

用于以 PEM 格式创建服务主体的 X509 证书的路径。

证书必须附加到私钥。

使用服务主体进行身份验证时使用。

备注

注意

  • 对于 Azure 身份验证,您可以传递参数、设置环境变量、使用存储在 ~/.azure/credentials 中的配置文件,或者在使用 az login 运行任务或 playbook 之前登录。

  • 也可以使用服务主体或 Active Directory 用户进行身份验证。

  • 要通过服务主体进行身份验证,请传递 subscription_id、client_id、secret 和 tenant 或设置环境变量 AZURE_SUBSCRIPTION_ID、AZURE_CLIENT_ID、AZURE_SECRET 和 AZURE_TENANT。

  • 要通过 Active Directory 用户进行身份验证,请传递 ad_user 和 password,或在环境中设置 AZURE_AD_USER 和 AZURE_PASSWORD。

  • 或者,凭据可以存储在 ~/.azure/credentials 中。这是一个 ini 文件,其中包含 [default] 部分和以下键:subscription_id、client_id、secret 和 tenant 或 subscription_id、ad_user 和 password。还可以添加其他配置文件。通过传递配置文件或在环境中设置 AZURE_PROFILE 来指定配置文件。

另请参阅

另请参阅

使用 Azure CLI 登录

如何使用 az login 命令进行身份验证。

示例

- name: Create a gallery image version form a managed image
  azure_rm_galleryimageversion:
    resource_group: myResourceGroup
    gallery_name: myGallery
    gallery_image_name: myGalleryImage
    name: 1.1.0
    location: East US
    publishing_profile:
      end_of_life_date: "2020-10-01t00:00:00+00:00"
      exclude_from_latest: true
      replica_count: 4
      storage_account_type: Standard_LRS
      target_regions:
        - name: West US
          regional_replica_count: 1
        - name: East US
          regional_replica_count: 3
          storage_account_type: Standard_LRS
    storage_profile:
      source_image: /subscriptions/sub123/resourceGroups/group123/providers/Microsoft.Compute/images/myOsImage

- name: Create a gallery image version from another gallery image version
  azure_rm_galleryimageversion:
    resource_group: myResourceGroup
    gallery_name: myGallery
    gallery_image_name: myGalleryImage
    name: 1.2.0
    location: East US
    publishing_profile:
      end_of_life_date: "2020-10-01t00:00:00+00:00"
      exclude_from_latest: true
      replica_count: 4
      storage_account_type: Standard_LRS
      target_regions:
        - name: West US
          regional_replica_count: 1
        - name: East US
          regional_replica_count: 3
          storage_account_type: Standard_LRS
    storage_profile:
      source_image:
        version: 1.1.0
        gallery_name: myGallery2
        gallery_image_name: myGalleryImage2

- name: Create gallery image by using one os dist snapshot and zero or many data disk snapshots
  azure_rm_galleryimageversion:
    resource_group: myRsourceGroup
    gallery_name: myGallery
    gallery_image_name: myGalleryImage
    name: 3.4.0
    location: East  US
    publishing_profile:
      end_of_life_date: "2020-10-01t00:00:00+00:00"
      exclude_from_latest: true
      replica_count: 1
      storage_account_type: Standard_LRS
      target_regions:
        - name: East US
          regional_replica_count: 1
          storage_account_type: Standard_LRS
    storage_profile:
      os_disk:
        source: "/subscriptions/mySub/resourceGroups/myGroup/providers/Microsoft.Compute/snapshots/os_snapshot_vma"
      data_disks:
        - lun: 0
          source:
            name: data_snapshot_vma
        - lun: 1
          source: "/subscriptions/mySub/resourceGroups/myGroup/providers/Microsoft.Compute/snapshots/data_snapshot_vmb"

- name: Create gallery image by using a os disk snapshot stored in Storage Account container
  azure_rm_galleryimageversion:
    resource_group: myResourceGroup
    gallery_name: myGallery
    gallery_image_name: myGalleryImage
    name: 3.4.0
    location: East  US
    publishing_profile:
      end_of_life_date: "2020-10-01t00:00:00+00:00"
      exclude_from_latest: true
      replica_count: 1
      storage_account_type: Standard_LRS
      target_regions:
        - name: East US
          regional_replica_count: 1
          storage_account_type: Standard_LRS
    storage_profile:
      os_disk:
        source:
          resource_group: myResourceGroup
          storage_account: myStorageAccount
          uri: "https://myStorageAccount.blob.core.windows.net/myContainer/myImage.vhd"

返回值

通用返回值记录在此处,以下是此模块特有的字段

描述

id

string

资源 ID。

返回: 始终

示例: "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalle ry1283/images/myImage/versions/10.1.3"

作者

  • Zim Kalinowski (@zikalino)