在Ansible Tower中,库存脚本的配置文件放在哪里?

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

我已经创建了一个库存脚本,用于动态填充我的库存。我想从配置文件(config.ini)中向脚本传递输入数据。

我正在使用Ansible Tower,有没有办法通过GUI将其包含在内?

我设法把它成功地,但只有通过SSH连接到服务器。

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

我刚刚解决了一个我认为是类似的问题,通过让库存脚本通过一个 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,因为awx不支持 "pluginyml "版本的azure_rm,只支持老版本的 "scriptini"。

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