【发布时间】:2020-04-29 17:07:05
【问题描述】:
我创建了一个库存脚本,用于动态填充我的库存。
我想将输入数据从配置文件 (config.ini) 传递给脚本
我正在使用 Ansible Tower,有没有办法通过 GUI 包含它?
我设法把它成功了,但只能通过 SSH 连接到服务器。
【问题讨论】:
标签: ansible ansible-inventory ansible-tower ansible-awx
我创建了一个库存脚本,用于动态填充我的库存。
我想将输入数据从配置文件 (config.ini) 传递给脚本
我正在使用 Ansible Tower,有没有办法通过 GUI 包含它?
我设法把它成功了,但只能通过 SSH 连接到服务器。
【问题讨论】:
标签: ansible ansible-inventory ansible-tower ansible-awx
我刚刚解决了我认为类似的问题,让库存脚本通过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 不支持 azure_rm 的“plugin/yml”版本,只支持较旧/已弃用的“script/ini”版本。
【讨论】: