2
0
mirror of https://github.com/frappe/bench.git synced 2024-11-14 17:24:04 +00:00

commands to setup pre-requisites and roles

This commit is contained in:
Saurabh 2017-08-30 15:38:17 +05:30
parent f5730b0828
commit c8d8c2b6a2
4 changed files with 34 additions and 38 deletions

View File

@ -47,7 +47,7 @@ def check_uid():
sys.exit(1) sys.exit(1)
def cmd_requires_root(): def cmd_requires_root():
if len(sys.argv) > 2 and sys.argv[2] in ('production', 'sudoers', 'lets-encrypt', 'fonts', 'reload-nginx', 'firewall', 'ssh-port'): if len(sys.argv) > 2 and sys.argv[2] in ('production', 'sudoers', 'lets-encrypt', 'fonts', 'print', 'firewall', 'ssh-port', 'prerequisites', 'role'):
return True return True
if len(sys.argv) >= 2 and sys.argv[1] in ('patch', 'renew-lets-encrypt', 'disable-production'): if len(sys.argv) >= 2 and sys.argv[1] in ('patch', 'renew-lets-encrypt', 'disable-production'):
return True return True

View File

@ -180,6 +180,29 @@ def sync_domains(domain=None, site=None):
# if changed, success, else failure # if changed, success, else failure
sys.exit(0 if changed else 1) sys.exit(0 if changed else 1)
@click.command('prerequisites')
def setup_prerequisites():
"Install prerequisites"
from bench.utils import run_playbook
run_playbook('prerequisites/install_prerequisites.yml')
@click.command('role')
@click.argument('role')
@click.option('--admin_emails', default='')
@click.option('--mysql_root_password')
def setup_roles(role, **kwargs):
"Install dependancies via roles"
from bench.utils import run_playbook
extra_vars = {"production": True}
extra_vars.update(kwargs)
if role:
run_playbook('prerequisites/install_roles.yml', extra_vars=extra_vars, tag=role)
else:
run_playbook('prerequisites/install_roles.yml', extra_vars=extra_vars)
setup.add_command(setup_sudoers) setup.add_command(setup_sudoers)
setup.add_command(setup_nginx) setup.add_command(setup_nginx)
setup.add_command(reload_nginx) setup.add_command(reload_nginx)
@ -200,3 +223,5 @@ setup.add_command(remove_domain)
setup.add_command(sync_domains) setup.add_command(sync_domains)
setup.add_command(setup_firewall) setup.add_command(setup_firewall)
setup.add_command(set_ssh_port) setup.add_command(set_ssh_port)
setup.add_command(setup_prerequisites)
setup.add_command(setup_roles)

View File

@ -761,11 +761,16 @@ def set_git_remote_url(git_url, bench_path='.'):
if os.path.exists(os.path.join(app_dir, '.git')): if os.path.exists(os.path.join(app_dir, '.git')):
exec_cmd("git remote set-url upstream {}".format(git_url), cwd=app_dir) exec_cmd("git remote set-url upstream {}".format(git_url), cwd=app_dir)
def run_playbook(playbook_name, extra_vars=None): def run_playbook(playbook_name, extra_vars=None, tag=None):
if not find_executable('ansible'): if not find_executable('ansible'):
print("Ansible is needed to run this command, please install it using 'pip install ansible'") print("Ansible is needed to run this command, please install it using 'pip install ansible'")
sys.exit(1) sys.exit(1)
args = ['ansible-playbook', '-c', 'local', playbook_name] args = ['ansible-playbook', '-c', 'local', playbook_name]
if extra_vars: if extra_vars:
args.extend(['-e', json.dumps(extra_vars)]) args.extend(['-e', json.dumps(extra_vars)])
if tag:
args.extend(['-t', tag])
subprocess.check_call(args, cwd=os.path.join(os.path.dirname(bench.__path__[0]), 'playbooks')) subprocess.check_call(args, cwd=os.path.join(os.path.dirname(bench.__path__[0]), 'playbooks'))

View File

@ -1,34 +0,0 @@
---
- include: setup_essentials.yml
- name: "Setup prerequisites, mariadb, wkhtmltopdf, nodejs and psutil"
hosts: localhost
become: yes
become_user: root
vars:
mysql_conf_tpl: ../files/mariadb_config.cnf
mysql_secure_installation: True
roles:
- prerequisites
- mariadb
- wkhtmltopdf
- nodejs
- psutil
- name: setup bench and dev environment
hosts: localhost
vars:
bench_repo_path: "/home/{{ ansible_user_id }}/.bench"
bench_path: "/home/{{ ansible_user_id }}/frappe-bench"
tasks:
- debug:
var: run_travis
# setup frappe-bench
- include: includes/setup_bench.yml
when: not run_travis
# setup development environment
- include: includes/setup_dev_env.yml
when: not production and not run_travis