'Ansible: Error while passing numeric only value as user name to user module
While passing numeric only value as user name to user module an error is thrown "invalid user".
- name: "Create User Task"
user:
name: "'{{ item.user }}'"
state: present
with_items:
- user: user1
- user: user2
- user: 333
But passing as alphanumeric like "uuu" getting passed.
Please help how i can pass numeric value to get success.
Solution 1:[1]
This seems not to be an Ansible Issue itself and not related to programming at all but to the operating system, see
- What characters should I use or not use in usernames on Linux?
- Why can't Linux usernames begin with numbers?
- All-numeric usernames in Red Hat Enterprise Linux
And even if it is possible to have numeric only user names under some circumstances, there will be other restriction later as in Ansible Issue #66544 "file module wrongly interprets numeric username as UID".
At minimum this seems to be non-intuitive behavior that should be documented. It is perfectly POSIX "legal" to have usernames that are integers.
We don't plan to add support for this, but should document it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | U880D |
