Closed Tiboris closed 2 years ago
I think we should also extend https://github.com/neoave/mrack/blob/master/tests/unit/test_ansible_inventory.py with tests to ensure that hostname, fqdn are generated according to expectations to prevent future regressions. Could be a separate PR. Will you write it or should I?
For referene, verified via:
Input:
domains:
- name: foo.bar
type: ipa
hosts:
# FQDN
- name: first.foo.bar
role: master
group: ipaserver
os: rhel-8.4
# Short name
- name: client
role: client
group: ipaserver
os: rhel-8.4
# Invalid name as it is FQDN which does not belong into domain
- name: client2.invalid
role: client
group: ipaserver
os: rhel-8.4
# Invalid name as it is FQDN with a sub domain - should be defined as
# a separate domain
- name: client2.invalid.foo.bar
role: client
group: ipaserver
os: rhel-8.4
output, reduced to 4 variables per host:
2021-11-25T15:33:42 hosts:
2021-11-25T15:33:42 client:
2021-11-25T15:33:42 meta_dc_record: DC=foo,DC=bar
2021-11-25T15:33:42 meta_domain: foo.bar
2021-11-25T15:33:42 meta_fqdn: client.foo.bar
2021-11-25T15:33:42 meta_hostname: client
2021-11-25T15:33:42 client2.invalid:
2021-11-25T15:33:42 meta_dc_record: DC=foo,DC=bar
2021-11-25T15:33:42 meta_domain: foo.bar
2021-11-25T15:33:42 meta_fqdn: client2.foo.bar
2021-11-25T15:33:42 meta_hostname: client2
2021-11-25T15:33:42 client2.invalid.foo.bar:
2021-11-25T15:33:42 meta_dc_record: DC=foo,DC=bar
2021-11-25T15:33:42 meta_domain: foo.bar
2021-11-25T15:33:42 meta_fqdn: client2.foo.bar
2021-11-25T15:33:42 meta_hostname: client2
2021-11-25T15:33:42 first.foo.bar:
2021-11-25T15:33:42 meta_dc_record: DC=foo,DC=bar
2021-11-25T15:33:42 meta_domain: foo.bar
2021-11-25T15:33:42 meta_fqdn: first.foo.bar
2021-11-25T15:33:42 meta_hostname: first
Append the meta_domain["name"] to the hostname of the resource where name is not fqdn to get one
Signed-off-by: Tibor Dudlák tdudlak@redhat.com