From 87414d218bdd829628fb3d7ac9c7f175b734a587 Mon Sep 17 00:00:00 2001 From: shreyas Date: Tue, 26 Jul 2016 12:35:04 +0530 Subject: [PATCH] [Fix] Add curl and wget to bench installer. Node v5 installer fixes --- bench/patches/v4/update_node.py | 20 +++++++++++--------- playbooks/develop/centos.yml | 9 ++++----- playbooks/develop/ubuntu.yml | 21 ++++++++++++++------- playbooks/install.py | 17 +++++++++++++++++ 4 files changed, 46 insertions(+), 21 deletions(-) diff --git a/bench/patches/v4/update_node.py b/bench/patches/v4/update_node.py index 5a18e015..d67697f2 100644 --- a/bench/patches/v4/update_node.py +++ b/bench/patches/v4/update_node.py @@ -9,18 +9,20 @@ def execute(bench_path): if node_exec: result = subprocess.check_output([node_exec, '-v']) else: - click.echo('\nNo node executable was found on your machine.\nPlease install node 5.x before\n' - 'running "bench update".\nInstallation instructions for CentOS and Ubuntu can be found on \n' - 'the following link,\n' - '"https://www.metachris.com/2015/10/how-to-install-nodejs-5-on-centos-and-ubuntu/"\n\n') + click.echo(''' + No node executable was found on your machine. + Please install node 5.x before running "bench update". + Installation instructions for CentOS and Ubuntu can be found on the following link, + "https://www.metachris.com/2015/10/how-to-install-nodejs-5-on-centos-and-ubuntu/" + ''') sys.exit(1) node_ver = Version(result.rstrip('\n').lstrip('v')) if node_ver < expected_node_ver: - click.echo('''Please update node version to 5.x before running "bench update". - 'Installation instructions for CentOS and Ubuntu can be found on the following link, - '"https://www.metachris.com/2015/10/how-to-install-nodejs-5-on-centos-and-ubuntu/" - - ''') + click.echo(''' + Please update node version to 5.x before running "bench update". + Installation instructions for CentOS and Ubuntu can be found on the following link, + "https://www.metachris.com/2015/10/how-to-install-nodejs-5-on-centos-and-ubuntu/" + ''') sys.exit(1) diff --git a/playbooks/develop/centos.yml b/playbooks/develop/centos.yml index 357b9947..9b1febb6 100644 --- a/playbooks/develop/centos.yml +++ b/playbooks/develop/centos.yml @@ -47,15 +47,14 @@ yum: name: https://rpm.nodesource.com/pub_5.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm state: present - update_cache: yes become: yes become_user: root - name: Install nodejs v5 - yum: name={{ item }} state=present - with_items: - - nodejs - - npm + yum: + name: nodejs + state: present + update_cache: yes become: yes become_user: root diff --git a/playbooks/develop/ubuntu.yml b/playbooks/develop/ubuntu.yml index 6ca2572f..594a432d 100644 --- a/playbooks/develop/ubuntu.yml +++ b/playbooks/develop/ubuntu.yml @@ -58,17 +58,24 @@ become_user: root - name: Add nodejs v5 repo - shell: 'curl -sL https://deb.nodesource.com/setup_5.x' - args: - executable: /bin/bash + get_url: + url: 'https://deb.nodesource.com/setup_5.x' + dest: '/tmp/setup_5.x' + mode: 0644 + become: yes + become_user: root + + - name: Install setup_5.x + command: /bin/bash /tmp/setup_5.x become: yes become_user: root - name: Update and Install Node v5 - apt: name={{ item }} state=present update_cache=yes force=yes - with_items: - - nodejs - - npm + apt: + name: nodejs + state: present + update_cache: yes + force: yes become: yes become_user: root diff --git a/playbooks/install.py b/playbooks/install.py index 85edddca..d337c7bb 100755 --- a/playbooks/install.py +++ b/playbooks/install.py @@ -6,6 +6,9 @@ tmp_bench_repo = '/tmp/.bench' def install_bench(args): # pre-requisites for bench repo cloning + install_package('curl') + install_package('wget') + success = run_os_command({ 'apt-get': [ 'sudo apt-get update', @@ -122,6 +125,20 @@ def install_python27(): # replace current python with python2.7 os.execvp('python2.7', ([] if is_sudo_user() else ['sudo']) + ['python2.7', __file__] + sys.argv[1:]) +def install_package(package): + package_exec = find_executable(package) + + if not package_exec: + success = run_os_command({ + 'apt-get': ['sudo apt-get install -y {0}'.format(package)], + 'yum': ['sudo yum install -y {0}'.format(package)] + }) + else: + return + + if not success: + could_not_install(package) + def clone_bench_repo(args): '''Clones the bench repository in the user folder''' if os.path.exists(tmp_bench_repo):