I am trying to get the home directory of a certain user in a salt-state.
{% set USER = 'theuser' %}
[... user creation in Linux ...]
{% set HOME = salt["cmd.shell']("getent passwd {{ USER }} | cut -d: -f6 ") %}
unfortunately HOME is empty, I expected it to be something like /home/theuser.
Is there correct/another way to do it?
2018.3.2
heres a way to do it with salt's user execution module:
{% set home_dir = salt['user.info']('ch3ll') %}
echo {{ home_dir['home'] }}:
cmd.run
Thanks, this works as required:
{% set USER = 'theuser' %}
{% set USERINFO = salt['user.info'](USER) %}
{% set HOMEDIR = USERINFO['home'] %}
Most helpful comment
Thanks, this works as required: