Ansible Dynamic Inventory Contribution

Hi all, I just written and push simple script to use as ansible dynamic inventory connected to your opennebula cloud.

Sources here: https://github.com/FELDSAM-INC/ansible-one-inv

It automatically loads your running VMs from cloud and group they by Labels. You can run ansible playbooks on this dynamic observed hosts.

See

2 Likes

Hi Kristian, I need to set hostnames automatically for VMs provisioned through opennebula. I believe above script can help me, but i am not sure how to use it as i am new for dev-ops tools . can you guide more how can i achieve expected results.

Hi, I donā€™t understand what you want to do. Thi script is for ansible dynamic inventory - it donā€™t provision any VMs, it just read VMs from API and group by Labels. So you can run ansible playbooks on specific VMs.

I also plan to write opennebula module for ansible, for provisioning VMs, but it is not in near future.

I am provisioning VMs through opennebula, but the provisioned VM hostname is always localhost.localdomain. I need to set hostname of newly provisioned VM automatically.

I tried to do with ansible or puppet, since both are new for meā€¦ I am not able to do it.

Although, from ansible command ā€œansible -m shell -a ā€˜hostname test1ā€™ 192.168.1.228ā€ it can be done, but that is manual taskā€¦ I need to automate either during provisioning of VM through webUI of opennebula by additing script or after that using ansible/puppet.

I had tried below link also, but this will do everything as expected ( update /etc/hosts file, puppet client and master config, cert auto register), but hostname is not getting change in this method also.

https://opennebula.org/automatic-configuration-of-vms-with-puppet/

Can you please help it

So you can add custom var to VM template SET_HOSTNAME and opennebula contexualization script read it and sets it.

Can you share a complete example, as i used to provision VM through wizard only. refer to attach snippet, which i am using.

Replace NODE_NAME by SET_HOSTNAME and use just https://github.com/OpenNebula/addon-context-linux/releases latest version

Thanks for quick supportā€¦ It worked.

welcome :slight_smile: sometimes you just need to read source code of context scripts :slight_smile:

Thanks ā€¦ where I can find all possible variableā€¦which can be used?

look into linked github repo and source code.

Here are scripts which start on system boot

you can also write your own.

Thanksā€¦ I am trying to learn Ansible/Puppet, to automate product deployments and management. Do we have any Orchestration tool with gui or WebUI ? ( :frowning: i dont have scripting skills)

Ansible Tower, but cost is very high. You should learn at least basics.

Hello Kristian,

Sorry for my english.

Iā€™m not pretty sure how to use your script. Did you write some tuttorial to use it ?

Did your script works with vonecloud?

Thank you very much

Hi all, this script is just dynamic hosts inventory, so you can instead of defining fixed hosts inventory in hosts file, use this script and load running VMs by labels a run ansible on them. If you need use ansible to deploy new VMs, them you need look into Ansible Modules Index -> Cloud -> Opennebula

Hi !

I understood the script purpose but I wonder how to use it.

Do I have to install something in my vonecloud vm or should I use another server ? Iā€™m not familiard with code so I need a little explanation to start use it.

thank you very much

Hello, everything is in ansible documentation. You just call my script in ansible command by -i flag. You should also read quick start guide of ansible.

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