# on remembering cnames instead of hostnames

**URL:** <https://forum.ansible.com/t/on-remembering-cnames-instead-of-hostnames/12429>\
**Category:** Ansible Project\
**Created:** [February 28, 2013, 12:52am UTC](https://forum.ansible.com/t/on-remembering-cnames-instead-of-hostnames/12429 "2013-02-28T00:52:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fdavis](https://avatars.discourse-cdn.com/v4/letter/f/a698b9/32.png) [@fdavis](https://forum.ansible.com/u/fdavis)\
**Post date:** [February 28, 2013, 12:52am UTC](https://forum.ansible.com/t/on-remembering-cnames-instead-of-hostnames/12429/1 "2013-02-28T00:52:14Z")

</div>

Hello all,

I was running playbooks/commands against a few select hosts at a time:

ansible-playbook update.yml -l host1:host2:host3’s\_cname: …

The problem I was having here, is that the cname isn’t in the inventory, but since  
I was running it against multiple hosts/groups, there isn’t a “no hosts matched”  
or similar warning.

If other people would think it useful, I would propose one of:

A) Warn when no hosts match an argument from ‘–limit’

I would interpret any pattern given to --limit to be given expecting  
a match (or an exclusion if “!” or “&” is used), so a warning when  
some part of it does nothing would be useful.

That way, ansible all -a “echo test” -l host1:fat\_finger  
would warn you that you there is no fat\_finger host or group.

B) Allow cname or alias names in the inventory

This would tell Ansible that I don’t really mean “host3’s cname” and would  
interpret it as “host3”.

This is might be better suited for an inventory plugin.  
The problem with just using "alias"s as mentioned in the docs,  
would be that any other inventory variables for host3 won’t be found  
at hostvars[‘host3s cname’].

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [February 28, 2013, 12:57am UTC](https://forum.ansible.com/t/on-remembering-cnames-instead-of-hostnames/12429/2 "2013-02-28T00:57:01Z")

</div>

> Hello all,
> 
> I was running playbooks/commands against a few select hosts at a time:
> 
> ansible-playbook update.yml -l host1:host2:host3's\_cname: ...
> 
> The problem I was having here, is that the cname isn't in the inventory, but  
> since  
> I was running it against multiple hosts/groups, there isn't a "no hosts  
> matched"  
> or similar warning.
> 
> If other people would think it useful, I would propose one of:
> 
> A) Warn when no hosts match an argument from '--limit'
> 
> I would interpret any pattern given to --limit to be given expecting  
> a match (or an exclusion if "!" or "&" is used), so a warning when  
> some part of it does nothing would be useful.

This seems reasonable.

> That way, ansible all -a "echo test" -l host1:fat\_finger  
> would warn you that you there is no fat\_finger host or group.
> 
> B) Allow cname or alias names in the inventory
> 
> This would tell Ansible that I don't really mean "host3's cname" and would  
> interpret it as "host3".

We can already do "ansible\_ssh\_host" for when the host needs to be  
contacted from a different name but that really puts in more than one  
host record.

The idea of adding aliases though does make sense.
