# Question of howto use external variables in the nmap plugin

**URL:** <https://forum.ansible.com/t/question-of-howto-use-external-variables-in-the-nmap-plugin/38478>\
**Category:** Ansible Project\
**Created:** [September 28, 2023, 3:56pm UTC](https://forum.ansible.com/t/question-of-howto-use-external-variables-in-the-nmap-plugin/38478 "2023-09-28T15:56:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cesarjorgemartinez](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/cesarjorgemartinez/32/163_2.png) [@cesarjorgemartinez](https://forum.ansible.com/u/cesarjorgemartinez)\
**Post date:** [September 28, 2023, 3:56pm UTC](https://forum.ansible.com/t/question-of-howto-use-external-variables-in-the-nmap-plugin/38478/1 "2023-09-28T15:56:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Will\_McDonald](https://avatars.discourse-cdn.com/v4/letter/w/f475e1/32.png) [@Will\_McDonald](https://forum.ansible.com/u/Will_McDonald)\
**Post date:** [September 28, 2023, 4:08pm UTC](https://forum.ansible.com/t/question-of-howto-use-external-variables-in-the-nmap-plugin/38478/2 "2023-09-28T16:08:46Z")

</div>

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/community/general/nmap_inventory.html#parameter-address)  
[https://docs.ansible.com/ansible/latest/collections/environment\_variables.html#envvar-ANSIBLE\_NMAP\_ADDRESS](https://docs.ansible.com/ansible/latest/collections/environment_variables.html#envvar-ANSIBLE_NMAP_ADDRESS)

---

<div class="post-metadata">

**Author:** ![cesarjorgemartinez](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/cesarjorgemartinez/32/163_2.png) [@cesarjorgemartinez](https://forum.ansible.com/u/cesarjorgemartinez)\
**Post date:** [September 28, 2023, 4:17pm UTC](https://forum.ansible.com/t/question-of-howto-use-external-variables-in-the-nmap-plugin/38478/3 "2023-09-28T16:17:11Z")

</div>

Many thank, works!!!

Because not work with --extra-vars?

Regards

---

<div class="post-metadata">

**Author:** ![Kosala\_Atapattu1](https://avatars.discourse-cdn.com/v4/letter/k/7feea3/32.png) [@Kosala\_Atapattu1](https://forum.ansible.com/u/Kosala_Atapattu1)\
**Post date:** [September 28, 2023, 6:19pm UTC](https://forum.ansible.com/t/question-of-howto-use-external-variables-in-the-nmap-plugin/38478/4 "2023-09-28T18:19:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [September 28, 2023, 6:42pm UTC](https://forum.ansible.com/t/question-of-howto-use-external-variables-in-the-nmap-plugin/38478/5 "2023-09-28T18:42:05Z")

</div>

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).
