Question of howto use external variables in the nmap plugin

Hi,

I have a question of howto use external variables in the nmap plugin.

I have a simple yml:
plugin: nmap

address: 192.168.10.0/24

But I need to pass the network range as a external variable, as example:

plugin: nmap

address: ‘{{ mynetrange }}’

I tested this argument also:

use_extra_vars: true

And launch as:
ansible-inventory -i nmap.yml --list -e “mynetrange=192.168.10.0/24”

but I can’t get it to work, someone could help me?

Regards

Could you use the environment variable ANSIBLE_NMAP_ADDRESS as documented below as an alternative?

https://docs.ansible.com/ansible/latest/collections/community/general/nmap_inventory.html#parameter-address
https://docs.ansible.com/ansible/latest/collections/environment_variables.html#envvar-ANSIBLE_NMAP_ADDRESS

Many thank, works!!!

Because not work with --extra-vars?

Regards

Inventory plugins can only read from ENV variables. Not sure why, but seems like a architectural limitation. Most of the inventory plugins either read from files (like AWS) or from ENV variables.

The basic configuration items are not templatable at all as no vars
were accessible when designed, extra vars got added later for
'constructed' features.
We do have plans to make this work, specially with vaults (you can
vault the file, but not use inline vaults).