# Ansible Nmap

**URL:** <https://forum.ansible.com/t/ansible-nmap/33979>\
**Category:** Ansible Project\
**Created:** [October 7, 2020, 6:58am UTC](https://forum.ansible.com/t/ansible-nmap/33979 "2020-10-07T06:58:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![maysirahza](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@maysirahza](https://forum.ansible.com/u/maysirahza)\
**Post date:** [October 7, 2020, 6:58am UTC](https://forum.ansible.com/t/ansible-nmap/33979/1 "2020-10-07T06:58:03Z")

</div>

Hello all

I have network 172.130.23.0/20 with a lot of router  
I tried to make inventory file for ansible.

[https://docs.ansible.com/ansible/latest/plugins/inventory/nmap.html](https://docs.ansible.com/ansible/latest/plugins/inventory/nmap.html)

How can I use ansible nmap for scanning my network to make inventory file?

I google it, I didn’t find any

Thank you

Mayang

---

<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:** [October 7, 2020, 7:39pm UTC](https://forum.ansible.com/t/ansible-nmap/33979/2 "2020-10-07T19:39:24Z")

</div>

The nmap inventory plugin does not create a file, it uses nmap every  
time to generate the inventory in memory for ansible.

You can however use `ansible-inventory --list --yaml -i test.nmap.yml

> inventory.yml` to generate a static inventory

it works with any plugin type, so you can do the same with a cloud  
inventory and others.

contents of test.nmap.yml

&nbsp;&nbsp;&nbsp;&nbsp;plugin: nmap  
&nbsp;&nbsp;&nbsp;&nbsp;strict: False  
&nbsp;&nbsp;&nbsp;&nbsp;address: 172.130.23..0/20

---

<div class="post-metadata">

**Author:** ![maysirahza](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@maysirahza](https://forum.ansible.com/u/maysirahza)\
**Post date:** [October 12, 2020, 8:55am UTC](https://forum.ansible.com/t/ansible-nmap/33979/3 "2020-10-12T08:55:42Z")

</div>

Hello Brain,

Sorry for late replay  
I tried and got this error

ansible-inventory --list --yaml -i test.nmap.yml \> inventory.yml  
[WARNING]: \* Failed to parse /Jaks/test.nmap.yml with yaml plugin: Plugin configuration YAML file,  
not YAML inventory  
[WARNING]: \* Failed to parse /Jaks/test.nmap.yml with constructed plugin: Incorrect plugin name in  
file: nmap  
[WARNING]: Unable to parse /Jaks/test.nmap.yml as an inventory source  
[WARNING]: No inventory was parsed, only implicit localhost is available

and when I tried with -vvvv

ansible-inventory --list --yaml -i test.nmap.yml -vvvv  
ansible-inventory 2.9.12  
config file = /etc/ansible/ansible.cfg  
configured module search path = [‘/home/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]  
ansible python module location = /opt/anaconda3/lib/python3.8/site-packages/ansible  
executable location = /opt/anaconda3/bin/ansible-inventory  
python version = 3.8.3 (default, Jul 2 2020, 16:21:59) [GCC 7.3.0]  
Using /etc/ansible/ansible.cfg as config file  
setting up inventory plugins  
host\_list declined parsing /Jaks/test.nmap.yml as it did not pass its verify\_file() method  
virtualbox declined parsing /Jaks/test.nmap.yml as it did not pass its verify\_file() method  
[WARNING]: \* Failed to parse /Jaks/test.nmap.yml with yaml plugin: Plugin configuration YAML file,  
not YAML inventory  
File “/opt/anaconda3/lib/python3.8/site-packages/ansible/inventory/manager.py”, line 280, in parse\_source  
plugin.parse(self.\_inventory, self.\_loader, source, cache=cache)  
File “/opt/anaconda3/lib/python3.8/site-packages/ansible/plugins/inventory/yaml.py”, line 112, in parse  
raise AnsibleParserError(‘Plugin configuration YAML file, not YAML inventory’)  
[WARNING]: \* Failed to parse /Jaks/test.nmap.yml with constructed plugin: Incorrect plugin name in  
file: nmap  
File “/opt/anaconda3/lib/python3.8/site-packages/ansible/inventory/manager.py”, line 280, in parse\_source  
plugin.parse(self.\_inventory, self.\_loader, source, cache=cache)  
File “/opt/anaconda3/lib/python3.8/site-packages/ansible/plugins/inventory/constructed.py”, line 109, in parse  
self.\_read\_config\_data(path)  
File “/opt/anaconda3/lib/python3.8/site-packages/ansible/plugins/inventory/ **init**.py”, line 224, in \_read\_config\_data  
raise AnsibleParserError(“Incorrect plugin name in file: %s” % config.get(‘plugin’, ‘none found’))  
[WARNING]: Unable to parse /Jaks/test.nmap.yml as an inventory source  
[WARNING]: No inventory was parsed, only implicit localhost is available  
all:  
children:  
ungrouped: {}

how to fix this?

---

<div class="post-metadata">

**Author:** ![maysirahza](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@maysirahza](https://forum.ansible.com/u/maysirahza)\
**Post date:** [October 12, 2020, 11:17am UTC](https://forum.ansible.com/t/ansible-nmap/33979/4 "2020-10-12T11:17:46Z")

</div>

I tried edit /etc/ansible/ansible.cfg and add ini and auto in enable\_plugins

---

<div class="post-metadata">

**Author:** ![maysirahza](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@maysirahza](https://forum.ansible.com/u/maysirahza)\
**Post date:** [October 13, 2020, 8:19am UTC](https://forum.ansible.com/t/ansible-nmap/33979/5 "2020-10-13T08:19:29Z")

</div>

Hello all

Sorry I just curious, is this normal result for plugin nmap?

ansible-inventory --list --yaml -i test.nmap.yml -vvvv  
ansible-inventory 2.9.12  
config file = /etc/ansible/ansible.cfg  
configured module search path = [‘/home/oss/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]  
ansible python module location = /opt/anaconda3/lib/python3.8/site-packages/ansible  
executable location = /opt/anaconda3/bin/ansible-inventory  
python version = 3.8.3 (default, Jul 2 2020, 16:21:59) [GCC 7.3.0]  
Using /etc/ansible/ansible.cfg as config file  
setting up inventory plugins  
host\_list declined parsing /Jaks/test.nmap.yml as it did not pass its verify\_file() method  
virtualbox declined parsing /Jaks/test.nmap.yml as it did not pass its verify\_file() method  
Parsed /Jaks/test.nmap.yml inventory source with auto plugin  
all:  
children:  
ungrouped: {}
