ansible-inventory - 如何让 awx 使用 azure_rm.yml 而不是 ini 版本?
问题描述
我需要使用 azure_rm 的“plugin/azure_rm.yml”版本而不是旧的/已弃用的“script/azure_rm.ini”来收集 Azure 中的动态清单,特别是因为我们需要将规模集中的 VM 包含在清单中。我怎样才能做到这一点?
解决方案
您可以使用清单脚本,该脚本(再次)调用 ansible-inventory,并通过以下方式创建配置文件heredoc
:
#!/usr/bin/env bash
cat > azure_rm.yml <<HEREDOC
---
plugin: azure_rm
include_vmss_resource_groups:
- '*'
hostvar_expressions:
ansible_host: private_ipv4_addresses | first
plain_host_names: true
keyed_groups:
# places each host in a group named 'tag_(tag name)_(tag value)' for each tag on a VM.
- prefix: tag
key: tags
# places each host in a group named 'azure_loc_(location name)', depending on the VM's location
- prefix: azure_loc
key: location
# group by platform (to copy prefix from ec2.py), eg: platform_windows
- prefix: platform
key: os_disk.operating_system_type
HEREDOC
ansible-inventory -i azure_rm.yml --list
rm azure_rm.yml
所以它实际上是有 ansible-inventory 调用 ansible-inventory,但有不同的论点。请注意,为了获得正确订阅的库存,您必须创建一个使用的凭证副本,并带有所需的订阅 ID;您似乎无法通过 yml 环境参数覆盖 AZURE_SUBSCRIPTION_ID 。
推荐阅读
- python - L = a^nb^n 的确定性下推自动机 | n >=0) Python 程序
- javascript - 如何使用反应备忘录
- powershell - Powershell 导入 CSV
- java - Java程序对数组字符串进行排序
- python-3.x - 将 django 模型导出到数据库添加额外的字段
- c++14 - myApplication.exe 中 0x006A549C 处未处理的异常:0xC00000FD:堆栈溢出(参数:0x00000001、0x01202FFC)
- shell - 如何删除shell中某一行之后的所有行?
- request - 使用 Rascal 从用户那里获取输入
- hadoop - Hadoop 文件系统任务 - 错误无法复制流不支持并发 IO 读取或写入操作 SSIS 到 Hadoop
- javascript - React 子组件状态未定义,但可以使用 console.log 查看状态