Skip to content

Commit

Permalink
fix: add domain name for fqdn if host has short name
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Tiboris committed Nov 25, 2021
1 parent dada7e3 commit a2d8f17
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/mrack/outputs/ansible_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,21 +134,20 @@ def create_ansible_host(self, name):
ansible_user = get_username(db_host, meta_host, self._config)
password = get_password(db_host, meta_host, self._config)
ssh_key = get_ssh_key(db_host, meta_host, self._config)
dom_name = meta_domain["name"]

# Common attributes
host_info = {
"ansible_host": ansible_host,
"ansible_python_interpreter": python,
"ansible_user": ansible_user,
"meta_fqdn": name,
"meta_fqdn": name if name.endswith(dom_name) else f"{name}.{dom_name}",
"meta_hostname": get_shortname(name),
"meta_domain": meta_domain["name"],
"meta_domain": dom_name,
"meta_provider": db_host.provider.name,
"meta_provider_id": db_host.host_id,
"meta_ip": ip_addr,
"meta_dc_record": ",".join(
"DC=%s" % dc for dc in meta_domain["name"].split(".")
),
"meta_dc_record": ",".join("DC=%s" % dc for dc in dom_name.split(".")),
}

if "restraint_id" in meta_host:
Expand Down

0 comments on commit a2d8f17

Please sign in to comment.