Closed palonsoro closed 2 days ago
I think I actually fixed it in https://github.com/karmab/kcli/commit/663f26dea122e15e0aee42ca86a7fcdb2a384fd4 when realizing today that it was legit to reserve a dns entry for a non started vm as long as an ip was provided
regarding the way a plan is handled, I dont have a good solution for that, it's just the way yaml is parsed and I think any "hack" would make the plan more complex to understand
Why not just adding an alt_name
field that overrides the name of the created plan item?
it's not possible because the behaviour or pyyaml with duplicate keys is to override the corresponding entry with the last key. furthermore, yaml spec indicates that keys shouldnt be duplicated in a yaml file so I m thinking that instead I should throw an error with duplicates
I don't mean that.
For example, let's have a look at this snippet:
myvm-vm:
alt_name: myvm # This parameter causes the VM to have "myvm" name and the key is ignored
cpus: 2
memory: 8192
...
myvm-dns:
type: dns
alt_name: myvm # This parameter causes the VM to have "myvm" name and the key is ignored
ip: 192.168.192.34
The idea is to introduce an alt_name
parameter that defines the name of the item to be created and makes the key to be ignored, such that in the snippet above, both the VM and the DNS entry have myvm
name and the myvm-vm
and myvm-dns
keys are ignored (they just need to be different to avoid the collision, but they can be anything because name is defined in alt_name
and not in the key).
To ensure backwards compatibility, alt_name
should be optional and fail back to the key if absent (i.e. to the current behavior)
I need to do a bit of testing but I believe https://github.com/karmab/kcli/pull/698 should address this. It will:
Ok, so basically when #698 is merged, having more than one key equal of different type would be acceptable, right? I just hope it is not problematic with the YAML parser...
It's merged already and works as expected but I hope you can confirm
Confirmed that it works now as expected even when using jinja templating. Thanks!
Use case:
reservedns
is now ignored, because it can cause issues if the IP is not reserved).Problem:
dns
formyvm
vm in the same plan thanmyvm
vm, I cannot because the VM definition hasmyvm
as key, so if I add the dns also withmyvm
key, I am adding two items with the same key to the yaml.Possible solutions:
only_aliases
option so that it only associates the IP to the aliases provided and not to the name of the DNS item created.