Question of howto use external variables in the nmap plugin

23 views
Skip to first unread message

J M

unread,
Sep 28, 2023, 11:56:11 AM9/28/23
to Ansible Project
Hi,

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

I have a simple yml:
plugin: nmap
...

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

Will McDonald

unread,
Sep 28, 2023, 12:09:18 PM9/28/23
to ansible...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/5b1c9c10-08cb-4cc3-a8eb-747cedbac6d1n%40googlegroups.com.

J M

unread,
Sep 28, 2023, 12:17:11 PM9/28/23
to Ansible Project
Many thank, works!!!

Because not work with --extra-vars?

Regards

"Kosala Atapattu (කෝසල අතපත්තු)"

unread,
Sep 28, 2023, 2:20:11 PM9/28/23
to ansible...@googlegroups.com
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. 

Sent from my iPhone

On 29/09/2023, at 5:17 AM, J M <cesarjorg...@gmail.com> wrote:

Many thank, works!!!

Brian Coca

unread,
Sep 28, 2023, 2:42:30 PM9/28/23
to ansible...@googlegroups.com
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).


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

Reply all
Reply to author
Forward
0 new messages