Open micahflee opened 6 years ago
Or perhaps, maybe a better way to do this, is to make the createinventory
command do the detection of VM type and split them into groups based on that time. Like, perhaps it can create these groups:
templates
(all templates)fedora_templates
debian_templates
other_templates
standalones
(all standalones)fedora_standalones
debian_standalones
other_standalones
(e.g. maybe a HVMs installed from ISOs)This way, it would be easy to write a playbook that automatically updates all fedora and debian templates and standalone VMs just by using those specific groups (and ignoring the other groups).
I think maybe in order to do this, the createinventory
command may need to power on VMs and run commands in them to detect their OS... it could save some time with the templates by deciding any template with "fedora" in its name is fedora, and any template with "debian" or "whonix" in it's name is debian. But then any other templates, or any standalones, would need to be powered on and to run something like which dnf
and which apt-get
to detect their package managers.
Or perhaps, maybe a better way to do this, is to make the createinventory command do the detection of VM type and split them into groups based on that time. Like, perhaps it can create these groups:
What about a second command for this detailed inventory
file? @micahflee
Like, createinventory
stays the same, and createdetailedinventory
splits your templates and standalones into groups based on their OS? I like that idea.
Also booting up all the vms (every kind) and detecting OS will be time consuming. I want to propose the following flow to make it fast.
feature
to every exists VM (including template+standalone+app) distro=distroname
.feature
value from the template.feature
value to populate the inventory
file.This way things will be still fast enough for the end user while creating the inventory file.
@micahflee @mig5 Your thoughts?
I think that makes sense. Ultimately the goal is to add the distro to each VM, and then collate a list of VMs of type 'template' or 'standalone' grouped by their distro flag ('feature' as you call it).
Whichever way makes sense to do that in the most Pythonic/Ansible-ish way, suits me :)
You could also group appVMs by distro (not sure how useful, but if you can come up with a generic way of grouping by distro and VM type, might as well throw it into the inventory)
Manual sounds like the way to go, if human-error does not turn critical.
A way to make is fast is by giving another command in Ansible module, at first it will create a file in the local directory with the existing VM names and any tag/feature value (best case basis).
The user can then fill up the file, and rerunning the ansible command will apply those values to the VMs.
This way, the user has to type one command twice, much easier than total manual work :)
The
createinventory
command makes a nice inventory file of all VMs. However this means it breaksupdates.yaml
example because all templates are in a single group, instead of in separatefedora_templates
anddebian_templates
groups. This is also true for standalone VMs.How would I go about writing a task that first detects the OS of a host in the inventory, then does one thing if it's fedora and something else if it's debian?