From 849d7b282ba9402622d9f587949e31fef32ffd7a Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Fri, 6 Sep 2013 08:55:37 -0400 Subject: [PATCH 1/2] Added collection of user's env Signed-off-by: Brian Coca --- system/setup | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/system/setup b/system/setup index e39910fb4ef..68cf8d03000 100644 --- a/system/setup +++ b/system/setup @@ -146,6 +146,7 @@ class Facts(object): self.get_date_time_facts() self.get_user_facts() self.get_local_facts() + self.get_env_facts() def populate(self): return self.facts @@ -447,6 +448,20 @@ class Facts(object): def get_user_facts(self): self.facts['user_id'] = getpass.getuser() + def get_env_facts(self): + env_bin = module.get_bin_path('env') + (rc, out, err) = module.run_command(env_bin) + if rc == 0: + self.facts['env'] = {} + i = 0 + for line in out.split('\n'): + if len(line) > 0: + try: + (k,v) = line.strip().split('=',1) + self.facts['env'][k] = v + except ValueError, e: + self.facts['env']['ansible_error#%d' % i] = line + i = i + 1 class Hardware(Facts): """ From aadf8175c62b3ed4f2bd7b21dd04c631ff082f65 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Mon, 23 Sep 2013 14:17:40 -0500 Subject: [PATCH 2/2] Modified env fact gathering to use the native python method Also updated CHANGELOG for this feature --- system/setup | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/system/setup b/system/setup index e919d5bce34..13c1bd8ea42 100755 --- a/system/setup +++ b/system/setup @@ -459,19 +459,9 @@ class Facts(object): self.facts['user_id'] = getpass.getuser() def get_env_facts(self): - env_bin = module.get_bin_path('env') - (rc, out, err) = module.run_command(env_bin) - if rc == 0: - self.facts['env'] = {} - i = 0 - for line in out.split('\n'): - if len(line) > 0: - try: - (k,v) = line.strip().split('=',1) - self.facts['env'][k] = v - except ValueError, e: - self.facts['env']['ansible_error#%d' % i] = line - i = i + 1 + self.facts['env'] = {} + for k,v in os.environ.iteritems(): + self.facts['env'][k] = v class Hardware(Facts): """