1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Expose more facts about user on host system

Adds:
  - `user_uid`
  - `user_gid`
  - `user_gecos`
  - `user_dir`
  - `user_shell`
This commit is contained in:
Marc Abramowitz 2014-09-24 14:05:31 -07:00
parent c4f1785217
commit e0015395de

View file

@ -29,6 +29,7 @@ import socket
import struct import struct
import datetime import datetime
import getpass import getpass
import pwd
import ConfigParser import ConfigParser
import StringIO import StringIO
@ -476,6 +477,12 @@ class Facts(object):
# User # User
def get_user_facts(self): def get_user_facts(self):
self.facts['user_id'] = getpass.getuser() self.facts['user_id'] = getpass.getuser()
pwent = pwd.getpwnam(getpass.getuser())
self.facts['user_uid'] = pwent.pw_uid
self.facts['user_gid'] = pwent.pw_gid
self.facts['user_gecos'] = pwent.pw_gecos
self.facts['user_dir'] = pwent.pw_dir
self.facts['user_shell'] = pwent.pw_shell
def get_env_facts(self): def get_env_facts(self):
self.facts['env'] = {} self.facts['env'] = {}