ansible - 标签/标签的 Ansible 动态库存过滤器
问题描述
我正在尝试使用 Ansible 运行动态库存列表
ansible-inventory --list -i gcp.yaml
---
plugin: gcp_compute
projects:
- <project name>
auth_kind: serviceaccount
service_account_file: /opt/ansible/inventory/peak-equator-SA.json
filters:
- labels|list = "ansible"
收到以下错误
[WARNING]: * Failed to parse /opt/ansible/inventory/gcp.yaml with auto plugin: [{'message': 'Invalid value for field \'filter\': \'labels|list = "ansible"\'. Invalid
list filter expression.', 'domain': 'global', 'reason': 'invalid'}]
[WARNING]: * Failed to parse /opt/ansible/inventory/gcp.yaml with yaml plugin: Plugin configuration YAML file, not YAML inventory
[WARNING]: * Failed to parse /opt/ansible/inventory/gcp.yaml with ini plugin: Invalid host pattern '---' supplied, '---' is normally a sign this is a YAML file.
[WARNING]: Unable to parse /opt/ansible/inventory/gcp.yaml as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
{
"_meta": {
"hostvars": {}
},
"all": {
"children": [
"ungrouped"
]
}
}
解决方案
我从不使用这个库存模块,但根据模块页面,过滤器应该是这样的:
filters:
- labels = ansible
推荐阅读
- python - 舍入双精度值并转换为整数
- angular - 如何在Angular 4中绑定多个选项/选择
- php - 如果xml节点没有子节点,如何删除它
- python - 使用数组和堆栈递归地评估表达式
- swift - 将数据附加到 Metal 中 MTLBuffer 的现有内容
- android - 如何使用 Cordova 使我的应用程序与旧的 Android 版本兼容?
- powershell - 停止PowerShell的子进程
- xpath - 从 ASX 刮取当前股价数据
- php - PHP Prepared Statement 我很想知道为什么这不起作用
- mysql - docker-compose 如何链接现有的 mariadb 而不是创建一个新的