Open jakub-vavra-cz opened 1 year ago
Could you highlight the mixing together? I don't see any unexpected behavior in the logs. Logging is using the provided hostname.
For cases where shortnames are the same it is better to use full domain names in domain and FQDN in host's name.
Ah, I see. By mixing together you mean that it probably tries the Fedora login credentials for the windows hosts and that it might be caused by the same ID.
I almost think that the fix for mrack would be to fail if name for 2 hosts is the same and usage of FQDNs for such situation would be recommended.
Originally it was all designed for FQDNs and full domain names. Thus these cases are not well tested.
@Tiboris WDYT? Should mrack allow non-unique hostnames, normalized it into FQDNs for further handling or should it rather fail if hostnames are not unique?
I see some pros and cons with both behaviors.
From user perspective, the normalization makes sense, but I'm not sure how dangerous the change is from size of change/potential of introducing new bugs.
I think there was something about FQDNs being dropped/not recommended due to some openstack/windows issue.
Having two hosts with the same shortname within two domains is a valid use-case. Mrack should probably build and use internally fqdn if it is not in name already.
The wider issue is inconsistency created between metadata, inventory and multihost config.
Metadata : name: Used as a unique identifier for the machine, with domain used to set the hostname of the machine. domain: hostname: Whatever I put there is passed to multihost but not applied on the machine in openstack as a hostname.
Inventory: name: name from metadata meta_fqdn: built from domain and first part of name meta_hostname (==shortname), Contains first part of name ansible_hostname: gained from reverse dns search
MHC:
"name": name from metadata
"hostname": Should contain FQDN according to pytest-multihost doc, not populated when not present in metadata.
"shortname": Should contain first part of name and is missing when not added to metadata.
"external_hostname": gathered from dns reverse search
When I do not put hostname in the metadata it is missing from the pytest multihost configuration same applies for shortname.
I agree that having two host from different domain with the same short name is a valid use case.
The question here is whether to implement it now or postpone - as it is not a cheap change and there is a workaround - defining FQDNs.
Wrt inconsistencies: that's a different issue than this ticket, so I don't want to dive deep there. But to answer the part is that in general it is recommended to use only name
in host sections in job metadata file. Ideally that to be FQDN. Don't use shortname
, hostname
, external_hostname
. The name
is used consistently in all. Various outputs adds additional data.
Inventory:
meta_{fqdn,domain,hostname}
is a normalization so that playbooks can used it without worrying if somebody is using shortnames or FQDNs. ansible_hostname
is a reachable host identification - thus reverse DNS or direct IP. Could be completely different than hostname. It is similar to pytest-multihost external_hostname
.pytest-multihost:
name
: this is the important one. It is also stated in the pytest-multihost projects docs to be used for defining the hostname. It should be shortname or FQDN - mrack is completely consistent with pytest-multihost expectations. hostname
, shortname
- these are not meant to be used in pytest-multihost config. Hostname is normalized into FQDN from name and its domain. shortname is derived from it.external_hostname
, ip
- should use reachable address as it is used for SSH connection
When using shortname in the name and two machines under different domains have the same one, mrack mixes information together.
Reproducer:
Log where both hots are accessed with user fedora despite one of them is a windows machine: