Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

Add equivalent of inventory_hostname for delegated host #86274

@jovial

Description

@jovial

Summary

The special variable inventory_hostname is set to the original host when using delegate_to. It would be nice if there was a counterpart for the delegated host. A suggestion I have seen is delegated_hostname. Currently inventory_hostname_shortname is set to the delegated host, but the issue is that if you are using the a FQDN, this will not reflect the name in the inventory. Perhaps it could default to inventory_hostname if there was no delegation underway.

Issue Type

Feature Idea

Component Name

ansible

Additional Information

- hosts: all
  tasks:
     - command: echo {{ delegated_hostname }}
       delegate_to: groups.controllers.0 

With group_vars/all:

ansible_host: "{{ delegated_hostname }}.{{ dns_domain }}"

See: #71198 (comment)

Code of Conduct

  • I agree to follow the Ansible Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureThis issue/PR relates to a feature request.has_prThis issue has an associated PR.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions