From d8215c6f1d828c29228b3b749370695844e4408b Mon Sep 17 00:00:00 2001 From: shreyas Date: Mon, 1 Aug 2016 12:09:54 +0530 Subject: [PATCH] [Fix] Fixes to replace new installer in erpnext and frappe travis.yml --- playbooks/develop/create_user.yml | 2 +- playbooks/develop/includes/setup_mariadb.yml | 17 +++++++-------- playbooks/develop/ubuntu.yml | 2 +- playbooks/install.py | 23 ++++++++++++++++++-- 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/playbooks/develop/create_user.yml b/playbooks/develop/create_user.yml index 7126a210..8cc1d79a 100644 --- a/playbooks/develop/create_user.yml +++ b/playbooks/develop/create_user.yml @@ -19,5 +19,5 @@ when: ansible_distribution == 'MacOSX' - name: Set /tmp/.bench folder perms - command: 'chown -R {{ frappe_user }}:{{ frappe_user }} /tmp/.bench' + command: 'chown -R {{ frappe_user }}:{{ frappe_user }} {{ repo_path }}' when: ansible_distribution == 'Ubuntu' or ansible_distribution == 'CentOS' diff --git a/playbooks/develop/includes/setup_mariadb.yml b/playbooks/develop/includes/setup_mariadb.yml index 207e2fcd..50b21498 100644 --- a/playbooks/develop/includes/setup_mariadb.yml +++ b/playbooks/develop/includes/setup_mariadb.yml @@ -7,19 +7,18 @@ - name: Set root Password for Ubuntu mysql_user: name: root - host: '{{ item }}' + host: localhost password: '{{ mysql_root_password }}' state: present - with_items: - - localhost - - 127.0.0.1 - - ::1 - become: yes become_user: root - # when you have already defined mysql root password - ignore_errors: yes - when: mysql_root_password is defined and ansible_distribution == 'Ubuntu' + when: ansible_distribution == 'Ubuntu' + + - name: Set root Password + command: mysqladmin -u root password {{ mysql_root_password }} + become: yes + become_user: root + when: mysql_root_password is defined and ansible_distribution != 'Ubuntu' - name: Add configuration template: src={{ mysql_config_template }} dest={{ mysql_conf_dir }}/frappe.cnf owner=root mode=0644 diff --git a/playbooks/develop/ubuntu.yml b/playbooks/develop/ubuntu.yml index ef1ec2e5..839eb07e 100644 --- a/playbooks/develop/ubuntu.yml +++ b/playbooks/develop/ubuntu.yml @@ -97,4 +97,4 @@ # setup development environment - include: includes/setup_dev_env.yml - when: not production and not run_travis + when: not production and not run_travis and not without_bench_setup diff --git a/playbooks/install.py b/playbooks/install.py index f575bcf3..acfdb311 100755 --- a/playbooks/install.py +++ b/playbooks/install.py @@ -86,6 +86,13 @@ def install_bench(args): extra_vars = vars(args) extra_vars.update(frappe_user=args.user) + if os.path.exists(tmp_bench_repo): + repo_path = tmp_bench_repo + + else: + repo_path = os.path.join(os.path.expanduser('~'), 'bench') + + extra_vars.update(repo_path=repo_path) run_playbook('develop/create_user.yml', extra_vars=extra_vars) extra_vars.update(get_passwords(args.run_travis or args.without_bench_setup)) @@ -144,12 +151,19 @@ def clone_bench_repo(args): if os.path.exists(tmp_bench_repo): return 0 + elif args.without_bench_setup: + clone_path = os.path.join(os.path.expanduser('~'), 'bench') + + else: + clone_path = tmp_bench_repo + branch = args.bench_branch or 'master' repo_url = args.repo_url or 'https://github.com/frappe/bench' + success = run_os_command( {'git': 'git clone {repo_url} {bench_repo} --depth 1 --branch {branch}'.format( - repo_url=repo_url, bench_repo=tmp_bench_repo, branch=branch)} + repo_url=repo_url, bench_repo=clone_path, branch=branch)} ) return success @@ -231,7 +245,12 @@ def run_playbook(playbook_name, sudo=False, extra_vars=None): user = extra_vars.get('user') or getpass.getuser() args.extend(['--become', '--become-user={0}'.format(user)]) - success = subprocess.check_call(args, cwd=os.path.join(tmp_bench_repo, 'playbooks')) + if os.path.exists(tmp_bench_repo): + cwd = tmp_bench_repo + else: + cwd = os.path.join(os.path.expanduser('~'), 'bench') + + success = subprocess.check_call(args, cwd=os.path.join(cwd, 'playbooks')) return success def parse_commandline_args():