0

我对 ansible 数组有疑问。

我有这样的任务:

  tasks:   
  - name: create member and add to pool 
    bigip_pool_member:
      pool: "{{pool_name}}"
      partition: "{{partition}}"
      host: "{{ip}}"
      name: "{{ip}}"
      port: "{{port}}"
      monitors:
        - "{{item}}"
      loop: "{{monitor}}"
      description: "{{description_member}}" 
      provider:
               ####

我想向池中添加多个监视器。只是它不起作用。我需要在一项任务中执行此操作。我该怎么做呢?

4

1 回答 1

3

该循环将多次运行该任务。看起来您应该直接将数组提供给任务:

  - name: create member and add to pool 
    bigip_pool_member:
      pool: "{{pool_name}}"
      partition: "{{partition}}"
      host: "{{ip}}"
      name: "{{ip}}"
      port: "{{port}}"
      monitors: "{{monitor}}"
      description: "{{description_member}}" 
于 2019-11-04T22:12:37.800 回答