On Ubuntu 14.04 I creating user with disabled password like:
sudo adduser --disabled-password myuser
I need to do same with Ansible
Since Ansible 2.6 the user
module has the option password_lock, which will run usermod -L
(Linux), pw lock
(FreeBSD), or usermod -C
(?):
usermod -L
:
Lock a user's password. This puts a '!' in front of the encrypted password, effectively disabling the password.
pw lock
:
The pw utility supports a simple password locking mechanism for users; it works by prepending the string
*LOCKED*
to the beginning of the password field in master.passwd to prevent successful authentication.
So you could use:
- name: Create password locked user
user:
name: myuser
state: present
password_lock: yes