From d1f713938e1c7d79a420fb528b6af15cf9584459 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Mon, 23 Sep 2013 14:17:40 -0500 Subject: [PATCH] Modified env fact gathering to use the native python method Also updated CHANGELOG for this feature --- CHANGELOG.md | 3 ++- library/system/setup | 16 +++------------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 750898307a8..377608f9b9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,8 @@ New modules: Misc changes: -* Added `state=touch` to the file module, which functions similarly to the command-line version of `touch` +* Added `ansible_env` to the list of facts returned by the setup module. +* Added `state=touch` to the file module, which functions similarly to the command-line version of `touch`. * Added a -vvvv level, which will show SSH client debugging information in the event of a failure. * Includes now support the more standard syntax, similar to that of role includes and dependencies. It is no longer necessary to specify a special "vas" field for the variables passed to the include. * Changed the `user:` parameter on plays to `remote_user:` to prevent confusion with the module of the same name. Still backwards compatible on play parameters. diff --git a/library/system/setup b/library/system/setup index e919d5bce34..13c1bd8ea42 100755 --- a/library/system/setup +++ b/library/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): """