我可以为Netbox广告资源插件查找环境变量吗

时间:2019-11-17 17:46:04

标签: ansible

我最近一直在使用netbox动态广告资源插件,但希望让我的其他团队成员更容易使用。插件的配置如下:

plugin: netbox
api_endpoint: http://our-netbox-server.com
validate_certs: False
config_context: False
token: abc123 

group_by:
  - device_roles

query_filters:
  - role: tor-switch
  - role: something
  - role: something_else

我希望可以从我的环境变量中查找token部分,例如:

token: "{{ lookup('env', 'NETBOX_TOKEN') }}"

但是,这根本不起作用。有人对我如何做到这一点有任何建议吗?

1 个答案:

答案 0 :(得分:0)

使用https://github.com/netbox-community/ansible_modules中的社区清单插件。这已经支持环境变量。因此,令牌和API端点无需存储在配置中。

api_endpoint:
    description: Endpoint of the NetBox API
    required: True
    env:
        - name: NETBOX_API
        
token:
    required: False
    description:
      - NetBox API token to be able to read against NetBox.
      - This may not be required depending on the NetBox setup.
    env:
      # in order of precedence
      - name: NETBOX_TOKEN
      - name: NETBOX_API_KEY