Ansible: TRANSFORM_INVALID_GROUP_CHARS deprecation warning

Posted by ads on Saturday, 2020-01-25
Posted in [Ansible][Linux]

After upgrading Ansible to version 2.8.3, the following deprecation warning appeared many times:

[DEPRECATION WARNING]: The TRANSFORM_INVALID_GROUP_CHARS settings is set to allow bad characters in group names by default, this will change, but still be user configurable on deprecation. This feature will be removed in version 2.10. Deprecation warnings can be
disabled by setting deprecation_warnings=False in ansible.cfg.
 [WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details

Wow, previously valid names in my hosts.cfg file are soon invalid? What’s going on here?

If you search for this problem on GitHub, you find over a 100 Issues, across many different projects. Clearly that hit quite a few people …

The “main” Issue in the Ansible repository, with quite a long discussion, seems to be #56930.

What happened? Someone decided that it is a good idea to make all group names valid Python variables. You know, because Ansible is exposing so much Python code to the Playbook authors, it’s clearly an issue that group names must be valid Python variable names …

A dash (-) is not valid in a Python variable name. A dash however is valid in DNS names, and many people use it in hostnames and group names. Automated systems like GPC or AWS generate such names all the time. And now they are no longer valid in upcoming Ansible versions? Currently this change is set to break every system by default which is using dashes in group names. Good work!

Meme generated using makeameme.org
Meme generated using makeameme.org

The warning can be hidden by setting the following configuration option in ansible.cfg:

1
force_valid_group_names = ignore

But again: you have to set this option. Otherwise your hosts.cfg will be broken in Ansible 2.10.


Categories: [Ansible] [Linux]

Share: