【问题标题】:Issue using a variable inside api_filter with netbox.netbox.nb_lookup使用带有 netbox.netbox.nb_lookup 的 api_filter 中的变量时出现问题
【发布时间】:2021-08-27 14:28:07
【问题描述】:

我有一个从 Tower 调查中设置的变量,我正在使用它来检索 netbox 中的关联 IP 地址。当我使用方括号以及使用 {{ 或 ' 或 " 时,我无法匹配所有内容并返回我的整个 IPAM 数据库。

vars:
    location: "{{ LOCATION }}"
    c_description: "{{CIRCUIT_DESC}}"
    prefix_length: "{{PREFIX}}"
  
  tasks:

  - name: "Print IP"
      debug:
        msg: "{{ query('netbox.netbox.nb_lookup', 'ip-addresses', api_filter= 'description=
              [c_description]', api_endpoint='http://netbox', token='', validate_certs='False') }}"

这是我的输出:

TASK [Print IP] ****************************************************************

ok: [localhost] => {
    "msg": []
}

【问题讨论】:

    标签: ansible netbox


    【解决方案1】:

    在另一个论坛使用 tilda 解决:

    - name: "Print IP"
      debug:
         msg: "{{ query('netbox.netbox.nb_lookup', 'ip-addresses', api_filter='description=' ~ c_description, 
                  api_endpoint='http://netbox.', token='', validate_certs='False') }}"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-29
      相关资源
      最近更新 更多