Skip to content

[Feat] Allow setting descriptive host names instead of private ips #920

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
pat-s opened this issue Mar 15, 2025 · 1 comment
Open

[Feat] Allow setting descriptive host names instead of private ips #920

pat-s opened this issue Mar 15, 2025 · 1 comment
Labels
feature request New functionality request

Comments

@pat-s
Copy link
Contributor

pat-s commented Mar 15, 2025

Problem

Currently, etcd_cluster and others expect a (private) IP as their host name in the ansible inventory as this information is used within the playbooks.

Description

An alternative would be to query the local addresses dynamically within the playbook and allow setting descriptive host names instead. This would align more closely to the classical Ansible approach.

Importance

nice to have

Proposed implementation

Proof of concept:

- name: Debug
  hosts: etcd_cluster
  become: true
  gather_facts: true

  tasks:
    - name: Extract private IP
      set_fact:
        internal_ip: "{{ ansible_all_ipv4_addresses | ipaddr('private') | first | default('No internal IP found') }}"

    - name: Show the internal IP
      debug:
        msg: 'Internal IP Address: {{ internal_ip }}'

TASK [Show the internal IP] **************************************************************************************************************************************************
ok: [10.10.1.1] => {
    "msg": "Internal IP Address: 10.10.1.1"
}
ok: [10.10.1.2] => {
    "msg": "Internal IP Address: 10.10.1.2"
}
ok: [10.10.1.3] => {
    "msg": "Internal IP Address: 10.10.1.3"
}

In this case, the variable internal_ip could be used within the playbooks.

This logic would need to account for edge cases, e.g. when multiple private interfaces are available. In this case, an optional list variable could be added in which the respective interfaces per node can be set.

@pat-s pat-s added feature request New functionality request needs triage labels Mar 15, 2025
@vitabaks
Copy link
Owner

I think it’s time for us to support this feature, as there have already been several requests to remove the requirement of specifying a private IP in inventory_hostname.

Please also take a look at this PR here, where a similar implementation was attempted.

Additionally, it’s important to maintain backward compatibility with the current approach, as it is used by the Autobase Console when generating the inventory JSON.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New functionality request
Projects
None yet
Development

No branches or pull requests

2 participants