realraum / noc

No Online Connection
Apache License 2.0
4 stars 0 forks source link

ansible inventory names are not nice to use #13

Closed equinox0815 closed 6 years ago

equinox0815 commented 6 years ago

Imho the currently used naming scheme inside the inventory needs to change. The main problem is that some of the names contain the .mgmt suffix and some don't - which brings all kinds of problems. Because of this inventory_hostname can not directly be used when it comes to naming resources such as logical volumes etc.

Take the current draft of the VM installer role(s) as an example. If you ask me the logical volume as well as the libvirt domain should be named testvm but as the inventory hostname is testvm.mgmt we would need to create a variable with the suffix stripped and use this variable everywhere in the role/playbook. Another example is the name of the host where VM should run on. At the moment we have to set the vm_install_host variable to alfred.mgmt because we need to be able to access hostvars[vm_install_host] when running parts of the installer playbook but it is imho much nicer to be able to set it to just alfred. As it is imho much more likely that future roles and playbooks need the "short" name as well it would make things much easier if this is also the name under which it can be found in the inventory. This is especially annoying since the .mgmt suffix is really more of a hint of how the host can be reached. This means if for some reason the host gets moved to another part of the network it's name changes and we would potentially need to change a number of other variables reflecting that.... Alos how do we deal with hosts that happen to be part of multiple network ranges? With the current scheme the same host could end up with multiple inventory names...

I propose something like creating groups for all hosts which share the same suffix and compute the ansible_host variables as well as the the generated ssh config based on that.