Migrate remaining modules to use get_bin_path in module_common.py

* Migraed easy_install, pip, service, setup, and user.
* Updated fail_json message in apt_repository
* Fixed easy_install to not hardcode location of virtualenv in
  /usr/local/bin/.
* Made handling of virtualenv more consistent between easy_install and
  pip.
This commit is contained in:
Stephen Fromm
2012-08-29 20:26:22 -07:00
parent 4e7b67a45a
commit e5a635672c
6 changed files with 24 additions and 63 deletions

View File

@@ -19,18 +19,6 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
def _find_easy_install(env):
if env:
return os.path.join(env, 'bin', 'easy_install')
paths = ['/usr/local/bin', '/usr/bin']
for p in paths:
e = p + '/easy_install'
if os.path.exists(e):
return e
def _ensure_virtualenv(env, virtualenv):
if os.path.exists(os.path.join(env, 'bin', 'activate')):
return 0, '', ''
@@ -62,14 +50,20 @@ def main():
name = module.params['name']
env = module.params['virtualenv']
easy_install = _find_easy_install(env)
easy_install = module.get_bin_path('easy_install', ['%s/bin' % env])
if easy_install is None:
module.fail_json(msg='easy_install is not installed')
rc = 0
err = ''
out = ''
if env:
rc_venv, out_venv, err_venv = _ensure_virtualenv(env, '/usr/local/bin/virtualenv')
virtualenv = module.get_bin_path('virtualenv')
if virtualenv is None:
module.fail_json(msg='virtualenv is not installed')
rc_venv, out_venv, err_venv = _ensure_virtualenv(env, virtualenv)
rc += rc_venv
out += out_venv