# RE: \[ansible-project\] Can’t use dash with numbers as hostname

**URL:** <https://forum.ansible.com/t/re-ansible-project-can-t-use-dash-with-numbers-as-hostname/33265>\
**Category:** Ansible Project\
**Created:** [June 25, 2020, 3:35pm UTC](https://forum.ansible.com/t/re-ansible-project-can-t-use-dash-with-numbers-as-hostname/33265 "2020-06-25T15:35:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stu](https://avatars.discourse-cdn.com/v4/letter/s/3ec8ea/32.png) [@Stu](https://forum.ansible.com/u/Stu)\
**Post date:** [June 25, 2020, 3:35pm UTC](https://forum.ansible.com/t/re-ansible-project-can-t-use-dash-with-numbers-as-hostname/33265/1 "2020-06-25T15:35:19Z")

</div>

I’m not getting the same thing happen.

The ansible\_host var is expecting a fqdn or ip so should just show like below.  
what version of ansible are you using?

# cat test

test1 ansible\_host=10-1

test2 ansible\_host=“10-1”

test3 ansible\_host=‘10-1’

ansible-inventory -i test --list

{

“\_meta”: {

“hostvars”: {

“test1”: {

“ansible\_host”: “10-1”

},

“test2”: {

“ansible\_host”: “10-1”

},

“test3”: {

“ansible\_host”: “10-1”

}

}

},

“all”: {

“children”: [

“ungrouped”

]

},

“ungrouped”: {

“hosts”: [

“test1”,

“test2”,

“test3”

]

}

}

---

<div class="post-metadata">

**Author:** ![CWollinger1](https://avatars.discourse-cdn.com/v4/letter/c/35a633/32.png) [@CWollinger1](https://forum.ansible.com/u/CWollinger1)\
**Post date:** [June 26, 2020, 6:33am UTC](https://forum.ansible.com/t/re-ansible-project-can-t-use-dash-with-numbers-as-hostname/33265/2 "2020-06-26T06:33:20Z")

</div>

I think the python version is the problem here.  
I see the behavior with ansible using python 3.6.x on a host system or in the current awx container (12.0.0 or 13.0.0). AWX uses python 3.6 currently.  
When I use ansible with Python 3.8.x, I see the correct result like you described.

Regards  
CWollinger

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [June 26, 2020, 7:02am UTC](https://forum.ansible.com/t/re-ansible-project-can-t-use-dash-with-numbers-as-hostname/33265/3 "2020-06-26T07:02:56Z")

</div>

> I think the python version is the problem here.  
> I see the behavior with ansible using python 3.6.x

You're probably right. I see the problem in FreeBSD too

&nbsp;&nbsp;\> uname -a  
&nbsp;&nbsp;FreeBSD \<sanitized\> 12.1-RELEASE FreeBSD 12.1-RELEASE r354233 GENERIC amd64  
&nbsp;&nbsp;  
&nbsp;&nbsp;\> cat hosts  
&nbsp;&nbsp;test1 ansible\_host=10-1  
&nbsp;&nbsp;test2 ansible\_host="10-1"  
&nbsp;&nbsp;  
&nbsp;&nbsp;\> ansible-inventory-2.7 -i hosts --list  
&nbsp;&nbsp;{  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"\_meta": {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"hostvars": {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"test1": {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"ansible\_host": "10-1"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"test2": {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb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bsp;&nbsp;]  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"ungrouped": {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"hosts": [  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"test1",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"test2"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;]  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
&nbsp;&nbsp;}

---

<div class="post-metadata">

**Author:** ![CWollinger1](https://avatars.discourse-cdn.com/v4/letter/c/35a633/32.png) [@CWollinger1](https://forum.ansible.com/u/CWollinger1)\
**Post date:** [June 26, 2020, 3:03pm UTC](https://forum.ansible.com/t/re-ansible-project-can-t-use-dash-with-numbers-as-hostname/33265/4 "2020-06-26T15:03:12Z")

</div>

Reported to the AWX project: [https://github.com/ansible/awx/issues/7448](https://github.com/ansible/awx/issues/7448)

Reason for the behaviour with python 3.6: [https://github.com/ansible/ansible/issues/70323#issuecomment-650176138](https://github.com/ansible/ansible/issues/70323#issuecomment-650176138)

many thanks to @ryanpetrello

Regards  
CWollinger
