环境:
Ansible version: 2.4
Component name: azure_rm
Cloud: Azure
Terraform:0.11.1
Provider: azure_rm v0.3.3
尝试使用 azure_rm.py 进行ansible工作,并且出于某种原因,它不处理我提供terraform的标签。
我在我的terraform文件中创建了这样的标记:
tags {
environment = "${var.environment_tag}"
role = "${var.zookeeper_role_tag}"
}
variables.tf 的位置我有以下内容:
variable "zookeeper_role_tag" {
description = "ZooKeeper Role Tag"
default = "zookeepernodes"
}
现在,在我的 azure_rm.ini 中,我有以下条目:
[azure]
# Control which resource groups are included. By default all resources groups are included.
# Set resource_groups to a comma separated list of resource groups names.
resource_groups=rgTest
# Control which tags are included. Set tags to a comma separated list of keys or key:value pairs
#tags=zookeeper_role_tag:zookeepernodes,broker_role_tag:kafkanodes
tags=zookeepernodes,kafkanodes
# Control which locations are included. Set locations to a comma separated list (e.g. eastus,eastus2,westus)
locations=eastus
# Include powerstate. If you don't need powerstate information, turning it off improves runtime performance.
include_powerstate=yes
# Control grouping with the following boolean flags. Valid values: yes, no, true, false, True, False, 0, 1.
group_by_resource_group=yes
group_by_location=yes
group_by_security_group=yes
group_by_tag=yes
我使用terraform的 remote-exec :
执行脚本provisioner "remote-exec" {
inline =
"ansible-playbook -i ~/ansible/contrib/inventory/azure_rm.py ~/${var.ansible_file}/ansible_kafka.yml -e 'ansible_user=ansible01 ansible_group=ansgroup kafka_user=kafkauser kafka_group=kafkagroup zookeeper_user=kafkauser zookeeper_group=kafkagroup"
]
}
但是,我收到以下错误:
azurerm_virtual_machine.bastion[0] (remote-exec): PLAY [zookeepernodes:kafkanodes]
***********************************************
azurerm_virtual_machine.bastion[0] (remote-exec): skipping: no hosts matched
azurerm_virtual_machine.bastion[0] (remote-exec): PLAY [zookeepernodes]
**********************************************************
azurerm_virtual_machine.bastion[0] (remote-exec): skipping: no hosts matched
azurerm_virtual_machine.bastion[0] (remote-exec): PLAY [kafkanodes]
**************************************************************
azurerm_virtual_machine.bastion[0] (remote-exec): skipping: no hosts matched
azurerm_virtual_machine.bastion[0] (remote-exec): PLAY [all]
*********************************************************************
azurerm_virtual_machine.bastion.0: Still creating... (4m50s elapsed)
如上所示, azure_rm.py 未获取标记的节点(zookeepernodes, kafkanodes
)。
任何指针是什么我做错了?再次感谢!!
答案 0 :(得分:0)
而不是" tags = zookeepernodes,kafkanodes"在azure_rm.ini文件中写:
tags=role:zookeepernodes
你也可以通过这样做包括kafkanodes节点:
tags=role:zookeepernodes,role:kafkanodes
它"关键:价值"。在你的情况下,role是一个键,zookeepernodes是一个值。