[BUG] State user.present use shell for unless condition
@twangboy is already working on this.
Since Jan 18, 2022.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Description
If you want to create user.present, with - shell: /bin/false it gets used for unless command run and by that it gets ignored.
By default mysql create user in debian like:
mysql:x:119:128:MySQL Server,,,:/nonexistent:/bin/false
We create that before instalation, because we want to do some preseed operations, with owner setup. This worked without problem on version 3000.2. I was doing upgrades because of CVE to 3002.
Setup
mysql_user:
user.present:
- name: mysql
- system: True
- home: /nonexistent
- createhome: False
- shell: /bin/false
- fullname: MySQL Server
- unless: /bin/grep -i mysql /etc/passwd
Steps to Reproduce the behavior
Use sls above and for diffrent runs try to change - home, by the unless user should not be changes becase he exists.
[WARNING ] Attempt to run a shell command with what may be an invalid shell! Check to ensure that the shell </bin/false> is valid for this user.
[INFO ] Executing command '/bin/grep -i mysql /etc/passwd' in directory '/home/XXXXX'
[INFO ] Executing command ['usermod', '-d', '/nonexistent', 'mysql'] in directory '/home/XXXXX'
if you comment shell setting or use shell like bash, unless works.
Expected behavior
Shell should not be change by setting user shell at least this should be 2 diffrent options.
Versions Report
salt --versions-report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)master and minions are same versions
Salt Version:
Salt: 3002.2
Dependency Versions:
cffi: Not Installed
cherrypy: Not Installed
dateutil: 2.7.3
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 2.10
libgit2: Not Installed
M2Crypto: Not Installed
Mako: Not Installed
msgpack: 0.5.6
msgpack-pure: Not Installed
mysql-python: Not Installed
pycparser: Not Installed
pycrypto: 2.6.1
pycryptodome: 3.6.1
pygit2: Not Installed
Python: 3.7.3 (default, Dec 20 2019, 18:57:59)
python-gnupg: Not Installed
PyYAML: 3.13
PyZMQ: 17.1.2
smmap: Not Installed
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.3.1
System Versions:
dist: debian 10 buster
locale: UTF-8
machine: x86_64
release: 4.19.0-10-amd64
system: Linux
version: Debian GNU/Linux 10 buster
Additional context
Tried to find this in other issues, but cannot find one. If this is duplicity i apologize.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.