# List of invalid character(s)

**URL:** <https://forum.ansible.com/t/list-of-invalid-character-s/30029>\
**Category:** Ansible Project\
**Created:** [March 29, 2019, 8:55pm UTC](https://forum.ansible.com/t/list-of-invalid-character-s/30029 "2019-03-29T20:55:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bob](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bob/32/9260_2.png) [@bob](https://forum.ansible.com/u/bob)\
**Post date:** [March 29, 2019, 8:55pm UTC](https://forum.ansible.com/t/list-of-invalid-character-s/30029/1 "2019-03-29T20:55:47Z")

</div>

Is the list of invalid character(s) documented somewhere?

I did have dashes in my group names and I replaced them with underscores but now ansible is complaining the period is invalid!

Makes use FQDN for group names a PITA if you cannot use periods.

---

<div class="post-metadata">

**Author:** ![bob](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bob/32/9260_2.png) [@bob](https://forum.ansible.com/u/bob)\
**Post date:** [March 29, 2019, 9:08pm UTC](https://forum.ansible.com/t/list-of-invalid-character-s/30029/2 "2019-03-29T21:08:01Z")

</div>

constants.py:122

INVALID\_VARIABLE\_NAMES = re.compile(r’\[1\]|[^\w]')

Really makes it hard to do [real-time.com](http://real-time.com) (company domain name)

What is the recommendation or best practices for moving forward?

[real\_time\_com]?

* * *

1. \d\W

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [March 29, 2019, 9:26pm UTC](https://forum.ansible.com/t/list-of-invalid-character-s/30029/3 "2019-03-29T21:26:54Z")

</div>

> constants.py:122
> 
> INVALID\_VARIABLE\_NAMES = re.compile(r'^[\d\W]|[^\w]')

It is document here  
[https://docs.ansible.com/ansible/latest/user\_guide/playbooks\_variables.html#creating-valid-variable-names](https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#creating-valid-variable-names)

> Really makes it hard to do real-time.com (company domain name)

Dash is subtraction in Jinja, so that is why you can't use that.  
Period is used to access attributes in Jinja so foo.bar is the same as foo['bar']

> What is the recommendation or best practices for moving forward?
> 
> [real\_time\_com]?

What works for you is probably the best.  
I use underscore since that makes is more readable that concatenate it or camel case.

---

<div class="post-metadata">

**Author:** ![cassell](https://avatars.discourse-cdn.com/v4/letter/c/ecae2f/32.png) [@cassell](https://forum.ansible.com/u/cassell)\
**Post date:** [March 29, 2019, 9:58pm UTC](https://forum.ansible.com/t/list-of-invalid-character-s/30029/4 "2019-03-29T21:58:58Z")

</div>

Personally I think it's a stupid limitation. I kind of hope it blows up and they revert the change. Apparently users were getting confused why they couldn't use "groups.group-name" instead of "groups['group-name']", so they banned groups with those types of characters so you can always do groups.group\_name. Just don't call your group "get", "copy", "keys", "items", or a host of other special values...

Using "---" as an inventory\_hostname is fine, though.

V/r,  
James Cassell
