empty_password in user.present always changes password, even with test=True
Description of Issue/Question
In a state file with user.present and empty_password: True the password is always set when running salt, even if it is already present and salt reports that it did nothing. You can see it on the server in the log line:
passwd[11111]: password for 'casselt' changed by 'root'
The worst thing about this is that it also removes the password if run with test=True, so I removed the passwords of all users on one server by accident. Just glad that I did not run salt '*'…
Setup
casselt:
user.present:
- uid: 1111
- gid: 100
- shell: /bin/bash
- empty_password: True
Steps to Reproduce Issue
- Create state file with content above
- Run
salt 'testserver*' state.sls teststate test=Falseto create the user - Run
salt 'testserver*' state.sls teststate test=Trueand look intojournalctl -rto see the log lines mentioned above - Run
salt 'testserver*' state.sls teststate test=Falseand look intojournalctl -rto see the log lines mentioned above
Output of the second and third salt run should be:
----------
ID: casselt
Function: user.present
Result: True
Comment: User casselt is present and up to date
Started: 08:00:28.640981
Duration: 13.352 ms
Changes:
----------
Workaround
Workaround is to just use password: "" instead of empty_password: True.
Versions Report
Some minions already run 2016.11 on stretch (debian repository):
Salt Version:
Salt: 2016.11.2
Dependency Versions:
cffi: Not Installed
cherrypy: Not Installed
dateutil: 2.5.3
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.9.4
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: Not Installed
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.8
mysql-python: 1.3.7
pycparser: Not Installed
pycrypto: 2.6.1
pygit2: Not Installed
Python: 2.7.13 (default, Jan 19 2017, 14:48:08)
python-gnupg: Not Installed
PyYAML: 3.12
PyZMQ: 16.0.2
RAET: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.4.3
ZMQ: 4.2.1
System Versions:
dist: debian 9.0
machine: x86_64
release: 4.9.0-3-amd64
system: Linux
version: debian 9.0
Salt master and most of the minions are still on jessie and run with 2016.3 (saltstack repository):
Salt Version:
Salt: 2016.3.6
Dependency Versions:
cffi: Not Installed
cherrypy: Not Installed
dateutil: 2.2
gitdb: 0.5.4
gitpython: 0.3.2 RC1
ioflo: Not Installed
Jinja2: 2.9.4
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: Not Installed
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.2
mysql-python: 1.2.3
pycparser: Not Installed
pycrypto: 2.6.1
pygit2: Not Installed
Python: 2.7.9 (default, Jun 29 2016, 13:08:31)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 14.4.0
RAET: Not Installed
smmap: 0.8.2
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.0.5
System Versions:
dist: debian 8.8
machine: x86_64
release: 3.16.0-4-amd64
system: Linux
version: debian 8.8
I think #41543 fixed this issue for the newer releases.
Thanks for the hint. Unfortunately, the PR was merged into the develop branch, but not into any release branch, not even 2017.7 which is RC1 at the moment. This needs to be included in 2017.7 but since 2016.11 is used in debian stretch repositories it is of utmost importance that this is also backported to 2016.11 since debian is widespread to be used as salt master.
@casselt This has been back-ported to the 2016.11 branch and will be available in the 2016.11.7 release.
Thanks for helping out here @CorvinM!