Using an environment variable in dynamic inventory

35 views
Skip to first unread message

Andrew Marshall

unread,
May 6, 2020, 4:43:14 AM5/6/20
to Ansible Project
Hi - 

I have a basic dynamic inventory using the azure plugin:

```
plugin: azure_rm

include_vm_resource_groups:
- my_resource_group
```

However, this script runs in CI and teh resource group is created by a previous step, so it is not static. What I really want to do is this:

```
plugin: azure_rm

include_vm_resource_groups:
- "{{ lookup('env', 'MY_RESOURCE_GROUP') }}"
```

However the lookup syntax doesn't work here, and the variable is not expanded. I have a temporary solution using sed to replace the variable on the fly, but is there a more elegant solution?

Thanks,
Andrew.

Brian Coca

unread,
May 6, 2020, 10:22:42 AM5/6/20
to Ansible Project
IT is something I've been trying to add
https://github.com/ansible/ansible/pull/58288

--
----------
Brian Coca

Reply all
Reply to author
Forward
0 new messages