Ansible nmap_plugin

This plugin has the same functionality as the script from this repository, but it uses the inventory plugin to get advantage of extra services like caching.

Installing the plugin

You can copy the plugin or make a symbolic link

/bin/mkdir --verbose --parents $HOME/.ansible/plugins/inventory/
# /bin/ln --symbolic --verbose --force $HOME/EnableSysadmin/ExtendingAnsibleWithPython/Inventories/plugins/inventory/ $HOME/.ansible/plugins/inventory/
/bin/cp --verbose $HOME/EnableSysadmin/ExtendingAnsibleWithPython/Inventories/plugins/inventory/ $HOME/.ansible/plugins/inventory/

Confirm than Ansible can locate the nmap_plugin plugin and parse the description

[josevnz@dmaf5 ExtendingAnsibleWithPython]$ ansible-doc -t inventory -l|grep nmap
nmap                Uses nmap to find hosts to target                                                                                                                                                  
nmap_plugin         Returns a dynamic host inventory from Nmap scan                

The plugin is used on an inventory (nmap_plugin_inventory.yaml) file like this one:

# This is the configuration file for my version of the Nmap plugin, nmap_plugin
# Showing required parameters below
plugin: nmap_plugin

Testing it

[josevnz@dmaf5 ExtendingAnsibleWithPython]$ ansible-inventory --inventory Inventories/test/nmap_plugin_inventory.yaml --list
    "_meta": {
        "hostvars": {
            "dmaf5.home": {
                "ip": ""
            "macmini2": {
                "ip": ""
            "raspberrypi": {
                "ip": ""
    "all": {
        "children": [
    "ungrouped": {
        "hosts": [