我正在尝试使用Ansible模块管理我的Azure云,但使用official guide没有运气。
我已设置Service Principal并获得凭据,然后按照建议将它们存入$ HOME / .azure / credentials:
[default]
subscription_id=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
client_id=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
secret=xxxxxxxxxxxxxxxxx
tenant=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
当开始测试剧本时,我得到了: “没有提供subscription_id。请设置'AZURE_SUBSCRIPTION_ID'或使用'subscription_id'参数”
然后我设置了环境变量:
export AZURE_CLIENT_ID=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
export AZURE_SECRET=xxxxxxxxxxxxxxxxx
export AZURE_SUBSCRIPTION_ID=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
export AZURE_TENANT=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
现在我收到了错误: “没有提供management_cert_path。请设置'AZURE_CERT_PATH'或使用'management_cert_path'参数”
我可以使用Azure CLI成功登录我的应用程序:
azure account show
info: Executing command account show
data: Name : Visual Studio Enterprise: BizSpark
data: ID : xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
data: State : Enabled
data: Tenant ID : xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
data: Is Default : true
data: Environment : AzureCloud
data: Has Certificate : No
data: Has Access Token : Yes
data: User name : xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
data:
info: account show command OK
我的测试手册:
---
- hosts: localhost
connection: local
tasks:
- name: Azure VM creation
azure:
name: Test_machine
role_size: Basic_A0
image:
offer: CentOS
publisher: OpenLogic
sku: '7.1'
version: latest
location: 'West Europe'
user: admin
password: Password!
storage_account: my-storage-account
wait: yes
P.S。 this question中列出的收据不适合我的情况。
答案 0 :(得分:0)
azure
模块是旧版服务管理模块,可能会在Ansible 2.2中弃用。听起来你已经在使用ARM,而你所指的指南是关于ARM的,所以你应该使用azure_rm_virtualmachine模块。