List of invalid character(s)

36 views
Skip to first unread message

b...@tanners.org

unread,
Mar 29, 2019, 4:55:47 PM3/29/19
to Ansible Project
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.

b...@tanners.org

unread,
Mar 29, 2019, 5:08:01 PM3/29/19
to Ansible Project
constants.py:122 

INVALID_VARIABLE_NAMES = re.compile(r'^[\d\W]|[^\w]')

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

What is the recommendation or best practices for moving forward?


[real_time_com]?

Kai Stian Olstad

unread,
Mar 29, 2019, 5:27:08 PM3/29/19
to ansible...@googlegroups.com
On 29.03.2019 22:08, b...@tanners.org wrote:
> 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


> 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.


--
Kai Stian Olstad

James Cassell

unread,
Mar 29, 2019, 5:59:09 PM3/29/19
to Ansible List
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

Reply all
Reply to author
Forward
0 new messages