2
0
mirror of https://github.com/frappe/bench.git synced 2025-01-24 07:28:25 +00:00

[fix] [playbook] ubuntu dev setup ready

This commit is contained in:
Anand Doshi 2016-03-17 15:20:21 +05:30
parent 74821ae13f
commit 6b6de9d2d0
7 changed files with 63 additions and 48 deletions

View File

@ -113,7 +113,7 @@ def setup_env(bench='.'):
exec_cmd('virtualenv -q {} -p {}'.format('env', sys.executable), cwd=bench)
exec_cmd('./env/bin/pip -q install --upgrade pip', cwd=bench)
exec_cmd('./env/bin/pip -q install wheel', cwd=bench)
exec_cmd('./env/bin/pip -q install https://github.com/frappe/MySQLdb1/archive/MySQLdb-1.2.5-patched.tar.gz', cwd=bench)
# exec_cmd('./env/bin/pip -q install https://github.com/frappe/MySQLdb1/archive/MySQLdb-1.2.5-patched.tar.gz', cwd=bench)
exec_cmd('./env/bin/pip -q install -e git+https://github.com/frappe/python-pdfkit.git#egg=pdfkit', cwd=bench)
def setup_socketio(bench='.'):

View File

@ -1,10 +1,16 @@
---
- name: Add apt key
apt_key: keyserver=hkp://keyserver.ubuntu.com:80 id=0xcbcb082a1bb943db state=present
become: yes
become_user: root
- name: Add apt repositry
apt_repository: repo='deb [arch=amd64,i386] http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.1/ubuntu {{ ansible_distribution_release }} main' state=present
become: yes
become_user: root
- name: apt-get install
apt: pkg=mariadb-server update_cache=yes state=present
become: yes
become_user: root

View File

@ -1,6 +1,8 @@
---
- name: install bench
pip: name={{ bench_repo_path }} extra_args='-e'
become: yes
become_user: root
- name: init bench
command: bench init {{ bench_path }}

View File

@ -1,4 +1,9 @@
---
- name: Install MySQLdb in global env
pip: name=mysql-python version=1.2.5
become: yes
become_method: sudo
- name: Set root Password
mysql_user:
name=root
@ -9,9 +14,20 @@
with_items:
- localhost
when: mysql_root_password is defined
become: yes
become_method: sudo
# when you have already defined mysql root password
ignore_errors: yes
- name: Add configuration
template: src={{ mysql_config_template }} dest={{ mysql_conf_dir }}/frappe.cnf owner=root mode=0644
notify: restart mysql
notify:
- restart mysql
become: yes
become_method: sudo
- name: restart mysql
service: name=mysql state=restarted
become: yes
become_method: sudo

View File

@ -3,6 +3,10 @@
get_url:
url=http://download.gna.org/wkhtmltopdf/0.12/{{ wkhtmltopdf_version }}/wkhtmltox-{{ wkhtmltopdf_version }}_linux-{{ ansible_distribution_release }}-{{ "amd64" if ansible_architecture == "x86_64" else "i386"}}.deb
dest="/tmp/"
become: yes
become_user: root
- name: Install wkhtmltopdf deb
apt: deb=/tmp/wkhtmltox-{{ wkhtmltopdf_version }}_linux-{{ ansible_distribution_release }}-{{ "amd64" if ansible_architecture == "x86_64" else "i386"}}.deb
become: yes
become_user: root

View File

@ -7,6 +7,10 @@
mysql_conf_dir: /etc/mysql/conf.d/
wkhtmltopdf_version: 0.12.2.1
vars_prompt:
- name: mysql_root_password
prompt: "MySQL Root Password"
tasks:
# install pre-requisites

View File

@ -2,16 +2,30 @@
import os
import sys
import subprocess
import getpass
from distutils.spawn import find_executable
bench_repo = '/usr/local/frappe/bench-repo'
def install_bench(args):
# pre-requisites for bench repo cloning
install_pip()
install_ansible()
install_git()
run_os_command({
"apt-get": "sudo apt-get update",
})
success = run_os_command({
"apt-get": "sudo apt-get install -y git build-essential python-setuptools python-dev python-pip",
"yum": "sudo yum install -y git",
"brew": "brew install git"
})
if not success:
print "Could not install pre-requisites. Please check for errors or install them manually."
return
success = run_os_command({
"pip": "sudo pip install ansible"
})
if is_sudo_user():
raise Exception("Please run this script as a non-root user with sudo privileges, but without using sudo")
@ -43,54 +57,23 @@ 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_git():
if find_executable("git"):
# git already installed
return
print "Installing Git"
success = run_os_command({
"apt-get": "sudo apt-get install -y git",
"yum": "sudo yum install -y git",
"brew": "brew install git"
})
if not success:
could_not_install("Git")
def install_pip():
"""Install pip for the user or upgrade to latest version if already present"""
try:
import pip
except ImportError:
print "Installing Pip"
success = run_os_command({
"apt-get": "sudo apt-get install -y build-essential python-setuptools python-dev python-pip",
})
if not success:
could_not_install("Python Pip")
# replace current python with python2.7
os.execvp("python2.7", ([] if is_sudo_user() else ["sudo"]) + ["python2.7", __file__] + sys.argv[1:])
def install_ansible():
try:
import ansible
except ImportError:
import pip
pip.main(["install", "ansible"])
def clone_bench_repo():
"""Clones the bench repository in the user folder"""
if os.path.exists(bench_repo):
return 0
os.makedirs('/usr/local/frappe')
run_os_command({
'brew': 'mkdir -p /usr/local/frappe',
'apt-get': 'sudo mkdir -p /usr/local/frappe',
'yum': 'sudo mkdir -p /usr/local/frappe',
})
# change user
run_os_command({
'ls': 'sudo chown -R {user}:{user} /usr/local/frappe'.format(user=getpass.getuser()),
})
success = run_os_command(
{"git": "git clone https://github.com/frappe/bench {bench_repo} --depth 1 --branch new-install".format(bench_repo=bench_repo)}
)