【问题标题】:Create group with multiple names - Ansible GCE inventory plugin创建具有多个名称的组 - Ansible GCE 库存插件
【发布时间】:2019-11-18 10:02:12
【问题描述】:

我想创建一个动态清单,并创建一个组来放置我从中抓取数据的节点。我在我的动态清单中使用 gcp_compute 插件。

我想要达到的目标:
我想检索多个主机名/ip 并将它们放在同一个组中。我希望它非常模块化,所以我可以轻松切换节点名。

到目前为止的样子:

plugin: gcp_compute
auth_kind: serviceaccount
cache: true
gather_facts: false
retrieve_image_info: true
service_account_file: servicefile.json
groups:
  node_exporter: "'db-vm' in name"

我想使用类似的东西:node_exporter: "'db-vm' OR 'prometheus-vm' in name" 或类似的东西。我怎样才能做到这一点。

这也是我使用的命令,看看它是否有效:ansible-inventory -i gce_inventory.gcp.yml --graph。我的所有节点都未分组。

【问题讨论】:

    标签: ansible ansible-inventory


    【解决方案1】:

    我很容易就解决了……

    我相信我之前在做条件时犯了一些错误,但现在不小心解决了。

    为了能够检索多个,这里如何:
    node_exporter: "'db-vm' in name or 'prometheus-vm' in name"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-08-21
      • 1970-01-01
      • 2012-11-17
      • 2017-10-16
      • 1970-01-01
      • 2018-11-20
      • 1970-01-01
      • 2016-02-01
      相关资源
      最近更新 更多