Ansible Dynamic Inventory Contribution

Thanks, i will try :slight_smile:

Hi everyone,

I’m having trouble to use this script. I thkink I’m missing some prerequisites.

what software should I install on my server ?

When I excute the one-inv script I have an error : /usr/local/bin/node bad interpreter no such file or directory

If someone can guide me to run it successfully .

Thank you

Hi, you need nodejs installed in /usr/local/bin/node and npm.

Hi all, I updated this tool, there are few small fixes and how to use guide was added!

Hi @feldsam… I am following the steps mentioned above, but getting following message.

[amit@ansible-controller ansible-one-inv-1.0.1]$ npm install
ansible-one-inv@1.0.0 /home/amit/ansible/dynamic/ansible-one-inv-1.0.1
├── commander@2.20.0
└─┬ opennebula@1.0.12
├─┬ xml2js@0.4.4
│ ├── sax@0.6.1
│ └── xmlbuilder@13.0.2
└─┬ xmlrpc@1.0.2
├── sax@0.4.3
└── xmlbuilder@0.3.1

npm WARN ansible-one-inv@1.0.0 No repository field.

[amit@ansible-controller ansible-one-inv-1.0.1]$ ./one-inv --list
-bash: ./one-inv: /usr/local/bin/node: bad interpreter: No such file or directory


please suggest.

you dont have nodejs installed in /usr/local/bin/node

Thanks. It is working now.

nodejs were installed but executable were in different directly, as i am usig CentOS… I just created soft link for path suggested by you.




Hi Kristian,

I am using Ansible 2.8 and Opennebula 5.8 along with dynamic inventory. is there any way to provide one_vm paramters as Variable & Prompt while executing playbook ?

Intention is to provide “labels” as input through vars_prompt and dynamic inventory will pick that label. and change in playbook for every execution can be avoided.

please suggest

Amit K


It is resolved… Thanks for your support.

Amit Kumar

hi, would you share your solution? Can be handy for others


Objective: Provision VM ( CentOS or Ubuntu as per user selection ) using command line option and install software (apache or mysql as per user selection ) over it using Ansible playbook with the use of dynamic inventory.

How to: Use dynamic inventory by following Kristian Feldsam recommandation. -> Create 1st playbook with following content

- name: provision VM
    api_username: XXXX
    api_password: XXXX
    api_url: http://192.X.X.X:2633/RPC2
    template_id: 3
    labels: "{{ mylabel }}"
      name: "{{ hostname }}"
  register: vm
- debug:
    msg: "{{ vm.instances[0].networks[0].ip }}"
- wait_for_connection:
  delegate_to: '{{ vm.instances[0].networks[0].ip }}'

Above task will provision VM from cmd line
ansible-playbook -i /etc/ansible/pcloud /home/XXX/ansible/vmbuild1.yml -e “mylabel=web hostname=host1” … This gives me flexibility to provide hostname at cmdline itself. and output of playbook will show me IP of new machine along with setup of label.

Next playbook will is pretty straight, it will use IP received from 1st output
ansible-playbook -i /etc/ansible/one-inv -l 192.X.X.X /home/XXX/ansible/swinstall.yml.

Next Objective: Finding out way to combine both playbooks, so that single command will provision and install the software. It should be registering the new build VM IP of 1st playbook and use that for 2nd playbook as source.

Thanks & Regards,
Amit K

Hi, thanks for sharing. In this case, I think, that dynamic invertory is useless, when you want limit to one instance only by the IP.

Look at this

there is part, where newly created instance is added to host groups on fly

Hello all, I just rewrited this script to python. Actual sources are online in the same repo and you can use it in you ansible project.

One new feature: host group All where sits all hosts
^ @nimbus-tech

@mabdou can we add this to opennebula addons?

Hello @feldsam,

More than being an Add-on within our OpenNebula catalog, this would be more useful being included as part of the Official Playbooks of Ansible. This is a specific functionality that would best be outlined here - Would you be willing to make this contribution there?


Hello @mabdou, Ansible PR. I had to rewrite it again, because Ansible uses inventory plugins now (inventory scripts are deprecated and no more new contribution can be done)


That sounds great, thank you! :+1: Keep us posted about that plugin, please.

Hi all, this inventory plugin pull request is stalling now :(, probably more “likes” “thumb ups” on my pr post can help.

Hello everybody interested in this plugin, would you please help with testing Ansible GitHub PRs, so it can be merged?

Basicly, you should test this plugin and if it works add comment on PR in this format:

Works for me! Tested on Ansible 2.9.0. I verified this on CentOS 7.8 and also Ubuntu 18.04.

Ansible - How to test PRs?

Ansible inventory plugin PR




things have been moving recently in Ansible repo and most of the things including inventory scripts ended up in community.general (

I suppose your PR is obsolete and needs to be migrated to the dedicated collection/galaxy namespace. We will be doing the same for ONE modules. If you agree I will try to include also your inventory script (if possible) to the new location.

1 Like

Hello, ok, then please also include this inventory plugin. Thanks!