Search code examples
ansibleansible-inventory

Reach hosts using FQDN and their hostname only without FQDN


please help:

Is it possible to set up a static inventory so that hosts are accessible using their FQDN, as well as hostname without putting to Ad-hoc or playbook hosts full FQDN?

For example inventory file:

[production]
production1.local.domain

And commands:

ansible production1 -m ping
ansible production1.example.com -m ping

Solution

  • Yes. It's possible. Each entry must be declared. For example

    production1 ansible_host=production1.local.domain
    production1.local.domain
    
    [production]
    production1
    
    [production_fqdn]
    production1.local.domain