1

I have created an inventory script which is used to populate dynamically my inventory.
I would like to pass input data to the script from a configuration file (config.ini)

I am using Ansible Tower, is there a way to include it via the GUI ?

I managed to put it successfully but only by connecting via SSH to the server.

Zeitounator
  • 38,476
  • 7
  • 53
  • 66
Doc
  • 133
  • 1
  • 1
  • 10

1 Answers1

1

I just solved what I think is a similar problem, by having the inventory script create a file via a 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

So here i'm literally having ansible-inventory call ansible-inventory because awx doesn't support the "plugin/yml" version of azure_rm, just the older/deprecated "script/ini" version.

Daryl Banttari
  • 546
  • 3
  • 9