如何让 awx 使用 azure_rm.yml 而不是 ini 版本?

问题描述 投票:0回答:1

我需要使用 "pluginazure_rm.yml "版本的 azure_rm,而不是老式的 "scriptazure_rm.ini "来收集 Azure 中的动态库存,特别是因为我们需要将规模集的虚拟机包含在库存中。 如何才能做到这一点呢?

ansible-inventory ansible-tower ansible-awx
1个回答
0
投票

你可以使用一个清单脚本,(再次)调用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。

© www.soinside.com 2019 - 2024. All rights reserved.