azure.azure_preview_modules

本库不再维护,请前往 AzCollection

azure.azure_preview_modules

这个角色是最完整的,包含所有最新的 Azure 模块。更新和修复问题的速度比官方 Ansible 发布要快。

如果您使用 Ansible 来管理 Azure 资源,强烈建议您安装这个角色。

先决条件

使用此剧本角色需要您已经为 Azure 设置了 Ansible 环境。详细信息请参考 Ansible 教程 开始使用 Azure安装和配置 Ansible

安装

  1. 安装角色。
$ ansible-galaxy install azure.azure_preview_modules
  1. 更新新的 Azure 模块所需的 Azure Python SDK。
$ pip install -r ~/.ansible/roles/azure.azure_preview_modules/files/requirements-azure.txt

    或者

$ sudo pip install -r ~/.ansible/roles/azure.azure_preview_modules/files/requirements-azure.txt

安装 Python SDK 的原因如下:

  • 角色中新增模块,这个模块对应一项新的 Azure 资源,而该资源尚未包含在现有的 Ansible 版本中。需要安装相应的新资源的 SDK。

  • 更新的 SDK 可能会引入 API 重大变更,应该安装特定的可用版本。

所需的 SDK 列在 ~/files/requirements-azure.txt 文件中。该文件可以在安装的角色文件夹中找到,通常位于 ~/.ansible/roles/files 文件夹。

安装位置是个棘手的部分,必须与现有的 Azure Python SDK 安装位置相同。如果执行上述命令时遇到任何错误,请仔细阅读以下部分以检查安装位置。

以 Ubuntu 为例,现有 SDK 可能位于 /home/<your-user-name>/.local/lib/python2.7/site-packages/usr/local/lib/python2.7/dist-packages 文件夹中。前者是用户文件夹,后者是系统文件夹,需要 sudo 权限。这取决于您如何安装 ansible。简而言之,您应该以与安装 ansible 相同的方式安装 SDK,以便 SDK 能放在同一个 site-packages 文件夹中。

在 macOS,现有 SDK 可能位于 /Users/<your-user-name>/Library/Python/2.7/lib/python/site-packages/Library/Python/2.7/site-packages 文件夹中。与 Ubuntu 类似,前者是用户文件夹,后者是系统文件夹。

找出正确的 site-packages 路径的一种方法是检查现有包的详细信息,比如 azure-mgmt-storage,运行下面的命令。

$ pip show azure-mgmt-storage

您可以得到类似的输出。

your-user-name@ansible:~$ pip show azure-mgmt-storage
Name: azure-mgmt-storage
Version: 1.5.0
Summary: Microsoft Azure Storage Management Client Library for Python
Home-page: https://github.com/Azure/azure-sdk-for-python
Author: Microsoft Corporation
Author-email: [email protected]
License: MIT License
Location: /home/<your-user-name>/.local/lib/python2.7/site-packages
Requires: azure-common, azure-mgmt-nspkg, msrestazure

从上述信息中,您可以知道 SDK 安装在 用户 site-packages 文件夹中,并使用 pip install 安装列出的包。如果 SDK 安装在 系统 路径中,使用 sudo pip install 安装列出的包。

角色变量

无。

依赖关系

没有其他角色的依赖。

示例剧本

- hosts: localhost
  roles:
    - { role: azure.azure_preview_modules }
  tasks:
  - name: 创建存储账户
    azure_rm_storageaccount:
      resource_group: 资源组名称
      name: 存储名称
      account_type: Standard_LRS

许可证

MIT

关于项目

latest Azure modules for provisioning Azure resources

安装
ansible-galaxy install azure.azure_preview_modules
许可证
Unknown
下载
60.9k
拥有者
APIs, SDKs and open source projects from Microsoft Azure