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.
Blockquote
[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
Blockquote
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.
Blockquote
/usr/local/bin/node
Blockquote
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
Regards,
Amit K
Hi,
It is resolved… Thanks for your support.
Regards,
Amit Kumar
hi, would you share your solution? Can be handy for others
Definately…
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
one_vm:
api_username: XXXX
api_password: XXXX
api_url: http://192.X.X.X:2633/RPC2
template_id: 3
labels: "{{ mylabel }}"
attributes:
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 - https://github.com/ansible/ansible/tree/devel/contrib/inventory/. Would you be willing to make this contribution there?
Best,
Michael
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! 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.
Thanks!
Hello,
things have been moving recently in Ansible repo and most of the things including inventory scripts ended up in community.general (https://www.ansible.com/blog/migrating-existing-content-into-a-dedicated-ansible-collection).
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.
Hello, ok, then please also include this inventory plugin. Thanks!
Hello all,
What is the status of this plugin with regards to integration in ansible community?
Also, if I wish to use it, which would be the recommended approach?
Thanks, and good job.
Hello, I did main work, plugin is working good, but they requested to write tests for this plugin. Tests should write another person to make sense. Would somebody help with writing tests?
Hi, sure, there are a lot of examples living in
tests/units/
subdirectories including tests for plugins
The aim is to cover your code as full as possible (maybe split it to more functions would be required). It’ll help be sure the covered things work as expected and will protect the plugin if anybody accidentally breaks something when fixing a bug or adding features.
Some old of them useunittest
but Ansible documentation says to usepytest
. If any questions, feel free to ask.