0

环境:

 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)。

任何指针我做错了什么?再次感谢!!

4

1 回答 1

0

而不是 azure_rm.ini 文件中的“tags=zookeepernodes,kafkanodes”写入:

tags=role:zookeepernodes

您还可以通过执行以下操作包含 kafkanodes 节点:

tags=role:zookeepernodes,role:kafkanodes

它是“键:值”。在您的情况下,角色是一个键,而 zookeepernodes 是一个值。

于 2017-12-24T01:31:21.373 回答