From b98c7ed27eeb5dd61abb1d0fe8e9eea156cdbc4f Mon Sep 17 00:00:00 2001 From: "Chinmay D. Pai" Date: Mon, 23 Mar 2020 20:59:58 +0530 Subject: [PATCH 01/18] refactor: bench readme * restructure the readme * add docker installation * cite stuff Signed-off-by: Chinmay D. Pai --- README.md | 301 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 195 insertions(+), 106 deletions(-) diff --git a/README.md b/README.md index 294520d8..63e2c322 100755 --- a/README.md +++ b/README.md @@ -1,131 +1,211 @@
-

bench

+

Bench

-bench is a command-line utility that helps you to install apps, manage multiple sites and update Frappe / ERPNext apps on */nix (macOS, Ubuntu, Debian, CentOS, etc) for development and production. +Bench is a command-line utility that helps you to install, update, and manage multiple sites for Frappe/ERPNext applications on *nix systems[^nix] for development and production. +## Table of Contents -> **Note**: If you are looking for easier ways to get started and evaluate ERPNext, [download the Virtual Machine](https://erpnext.com/download) or take [a free trial on erpnext.com](https://erpnext.com/pricing). - ---- - -# Table of Contents - - - [bench CLI](#bench-cli) - - [Usage](#usage) - - [Installation](#installation) - - [Custom Bench commands](#custom-bench-commands) - - [Easy Install Script](#easy-install-script) - - [Release Bench](#release-bench) + - [Installation](#installation) + - [Docker Installation](#docker-installation) + - [Development Setup](#docker-installation-for-development) + - [Production Setup](#docker-installation-for-production) + - [Easy Install Script](#easy-install-script) + - [Manual Installation](#manual-installation) + - [Usage](#usage) + - [Custom Bench commands](#custom-bench-commands) + - [Bench Manager](#bench-manager) - [Guides](#guides) - [Resources](#resources) - [License](#license) ---- -# bench CLI - -Bench is a command line tool that helps you install, setup, manage multiple sites and apps based on Frappe Framework. - ---- - -## Usage - -* Create a new bench - - bench init [bench-name] - -* Add a site under current bench - - bench new-site [site-name] - - **Optional**: If the database for the site does not reside on localhost or listens on a custom port, you can use the flags `--db-host` to set a custom host and/or `--db-port` to set a custom port. - - bench new-site [site-name] --db-host [custom-db-host-ip] --db-port [custom-db-port] - -* Add apps to bench - - bench get-app [app-name] [app-link] - -* Install apps on a particular site - - bench --site [site-name] install-app [app-name] - -* Start bench (only for development) - - bench start - -* Show bench help - - bench --help - -_Note:_ Apart from `bench init`, all other bench commands have to be run having the respective bench directory as the working directory. _(`bench update` may also be run, but it's behaviour is covered in depth in the docs)_ - -For more in depth information on commands and usage follow [here](https://github.com/frappe/bench/blob/master/docs/commands_and_usage.md). As for a consolidated list of bench commands, go through [this page](https://github.com/frappe/bench/blob/master/docs/bench_usage.md). - ---- ## Installation -To do this install, you must have basic information on how Linux works and should be able to use the command-line. bench will also create nginx and supervisor config files, setup backups and much more. If you are using on a VPS make sure it has >= 1Gb of RAM or has swap setup properly. +A typical bench setup provides two types of environments -- Development and Production. - git clone https://github.com/frappe/bench ~/.bench - pip3 install --user -e ~/.bench +The setup for each of these installations can be achieved in multiple ways: -As bench is a python application, its installation really depends on `python` + `pip` + `git`. The Frappe Framework, however has various other system dependencies like `nodejs`, `yarn`, `redis` and a database system like `mariadb` or `postgres`. Go through the [installation requirements](https://github.com/frappe/bench/blob/master/docs/installation.md) for an updated list. + - [Docker Installation](#docker-installation) + - [Easy Install Script](#easy-install-script) + - [Manual Installation](#manual-installation) -If you have questions, please ask them on the [forum](https://discuss.erpnext.com/c/bench) under the "Install / Update" category. +We recommend using either the Docker Installation or the Easy Install Script to setup a Production Environment. For Development, you may choose either of the three methods to setup an instance. + +Otherwise, if you are looking to evaluate ERPNext, you can also download the [Virtual Machine Image](https://erpnext.com/download) or register for [a free trial on erpnext.com](https://erpnext.com/pricing). + + +### Docker Installation + +A Frappe/ERPNext instance can be setup and replicated easily using Docker[^docker]. The officially supported Docker installation can be used to setup either of both Development and Production environments. + +To setup either of the environments, you will need to clone the official docker repository: + +```sh +$ git clone https://github.com/frappe/frappe_docker.git +$ cd frappe_docker +``` + +A quick setup guide for both the envionments can be found below. For more details, check out the [Frappe/ERPNext Docker Repository](https://github.com/frappe/frappe_docker). + +#### Docker Installation for Development + +To setup a development environment for Docker, follow the [Frappe/ERPNext Docker for Development Guide](https://github.com/frappe/frappe_docker/blob/develop/development/README.md). + +#### Docker Installation for Production + +Copy the `env-example` file to `.env` + +```sh +$ cp installation/env-example installation/.env +``` + +Make a directory for handling sites: + +```sh +$ mkdir installation/sites +``` + +Optionally, you may also setup an NGINX Proxy for SSL Certificates[^nginx-ssl] with auto-renewal for your Production instance. We recommend this for instances being accessed over the internet. For this to work, the DNS needs to be configured correctly so that LetsEncrypt[^letsencrypt] can verify the domain. To setup the proxy, run the following commands: + +```sh +$ git clone https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion.git +$ cd docker-compose-letsencrypt-nginx-proxy-companion +$ cp .env.sample .env +$ ./start.sh +``` + +**Note:** The Production setup does not contain, require, or use bench. For a list of substitute commands, check out the [Frappe/ERPNext Docker Site Operations](https://github.com/frappe/frappe_docker/#site-operations). + + +### Easy Install Script + +The Easy Install script should get you going with a Frappe/ERPNext setup with minimal manual intervention and effort. Since there are a lot of configurations being automatically setup, we recommend executing this script on a fresh server. + +**Note:** This script works only on GNU/Linux based server distributions, and has been designed and tested to work on Ubuntu 16.04+, CentOS 7+, and Debian-based systems. + +#### Prerequisites + +You need to install the following packages for the script to run: + + - ##### Ubuntu and Debian-based Distributions: + + ```sh + $ apt install python3-minimal build-essential python3-setuptools + ``` + + - ##### CentOS and other RPM Distributions: + + ```sh + $ dnf groupinstall "Development Tools" + $ dnf install python3 + ``` + +#### Setup + +Download the Easy Install script and execute it: + +```sh +$ wget https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py +$ python3 install.py --production +``` + +The script should then prompt you for the MySQL root password and an Administrator password for the Frappe/ERPNext instance, which will then be saved under `$HOME/passwords.txt` of the user used to setup the instance. This script will then install the required stack, setup bench and a default ERPNext instance. + +When the setup is complete, you will be able to access the system at `http://`, wherein you can use the administrator password to login. + +#### Troubleshooting + +In case the setup fails, the log file is saved under `/tmp/logs/install_bench.log`. You may then: + + - Create an Issue in this repository with the log file attached. + - Search for an existing issue or post the log file on the [Frappe/ERPNext Discuss Forum](https://discuss.erpnext.com/c/bench) with the tag `installation_problem` under "Install/Update" category. + +For more information and advanced setup instructions, check out the [Easy Install Documentation](https://github.com/frappe/bench/blob/master/docs/easy_install.md). + + +### Manual Installation + +Although not recommended, some might want to manually setup a bench instance locally for development. To quickly get started on installing bench the hard way, you can follow [Installing Bench and Frappe](https://frappe.io/docs/user/en/installation). + +For more extensive distribution-dependent documentation, check out the following guides: + + - [Hitchhiker's Guide to Installing Frappe on Linux](https://github.com/frappe/frappe/wiki/The-Hitchhiker%27s-Guide-to-Installing-Frappe-on-Linux) + - [Hitchhiker's Guide to Installing Frappe on MacOS](https://github.com/frappe/frappe/wiki/The-Hitchhiker%27s-Guide-to-Installing-Frappe-on-Mac-OS-X) + + +## Basic Usage + +**Note:** Apart from `bench init`, all other bench commands are expected to be run in the respective bench directory. + + * Create a new bench: + + ```sh + $ bench init [bench-name] + ``` + + * Add a site under current bench: + + ```sh + $ bench new-site [site-name] + ``` + - **Optional**: If the database for the site does not reside on localhost or listens on a custom port, you can use the flags `--db-host` to set a custom host and/or `--db-port` to set a custom port. + + ```sh + $ bench new-site [site-name] --db-host [custom-db-host-ip] --db-port [custom-db-port] + ``` + + * Download and add applications to bench: + + ```sh + $ bench get-app [app-name] [app-link] + ``` + + * Install apps on a particular site + + ```sh + $ bench --site [site-name] install-app [app-name] + ``` + + * Start bench (only for development) + + ```sh + $ bench start + ``` + + * Show bench help: + + ```sh + $ bench help + ``` + + +For more in-depth information on commands and their usage, follow [Commands and Usage](https://github.com/frappe/bench/blob/master/docs/commands_and_usage.md). As for a consolidated list of bench commands, check out [Bench Usage](https://github.com/frappe/bench/blob/master/docs/bench_usage.md). ---- ## Custom Bench Commands -Want to utilize a bench command you've added in your custom Frappe application? [This](https://github.com/frappe/bench/blob/master/docs/bench_custom_cmd.md) guide might be of some help. +If you wish to extend the capabilities of bench with your own custom Frappe Application, you may follow [Adding Custom Bench Commands](https://github.com/frappe/bench/blob/master/docs/bench_custom_cmd.md). ---- -# Easy Install Script +## Bench Manager -- This is an opinionated setup so it is best to setup on a blank server. -- Works on Ubuntu 16.04+, CentOS 7+, Debian 8+ -- You may have to install Python 3 and other essentials by running `apt-get install python3-minimal build-essential python3-setuptools` -- This script will install the pre-requisites, install bench and setup an ERPNext site `(site1.local under frappe-bench)` -- Passwords for Frappe Administrator and MariaDB (root) will be asked and saved under `~/passwoords.txt` -- MariaDB (root) password may be `password` on a fresh server -- You can then login as **Administrator** with the Administrator password -- The log file is saved under `/tmp/logs/install_bench.log` in case you run into any issues during the install. -- If you find any problems, post them on the forum: [https://discuss.erpnext.com](https://discuss.erpnext.com/c/bench) with the `installation_problem` under "Install / Update" category. +[Bench Manager](https://github.com/frappe/bench_manager) is a GUI frontend for Bench with the same functionalties. You can install it by executing the following command: - wget https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py - python3 install.py --production +```sh +$ bench setup manager +``` -Follow [Easy Install Docs](https://github.com/frappe/bench/blob/master/docs/easy_install.md) for more information. + - **Note:** This will create a new site to setup Bench Manager, if you want to set it up on an existing site, run the following commands: ---- + ```sh + $ bench get-app https://github.com/frappe/bench_manager.git + $ bench --site install-app bench_manager + ``` -# Release Bench -Releases can be made for [Frappe](https://github.com/frappe/frappe) apps using bench. More information about this process can be found [here](https://github.com/frappe/bench/blob/master/docs/releasing_frappe_apps.md). - ---- - -# Bench Manager (GUI for Bench) - -[Bench Manager](https://github.com/frappe/bench_manager) is a graphical user interface to emulate the functionalities of Frappe Bench. Like the command line utility it helps you install apps, manage multiple sites, update apps and much more. Install just by executing the following command in the respective bench directory. - - bench setup manager - ---- - -# Docker - -- For official images and resources [Frappe Docker](https://github.com/frappe/frappe_docker) -- Production Installation [README](https://github.com/frappe/frappe_docker/blob/develop/README.md) -- Developer Setup [README](https://github.com/frappe/frappe_docker/blob/develop/development/README.md) - ---- - -# Guides +## Guides - [Configuring HTTPS](https://frappe.io/docs/user/en/bench/guides/configuring-https.html) - [Using Let's Encrypt to setup HTTPS](https://frappe.io/docs/user/en/bench/guides/lets-encrypt-ssl-setup.html) @@ -136,16 +216,25 @@ Releases can be made for [Frappe](https://github.com/frappe/frappe) apps using b - [Setup Multitenancy](https://frappe.io/docs/user/en/bench/guides/setup-multitenancy.html) - [Stopping Production](https://github.com/frappe/bench/wiki/Stopping-Production-and-starting-Development) ---- +For an exhaustive list of guides, check out [Bench Guides](https://frappe.io/docs/user/en/bench/guides). -# Resources -- [Background Services](https://frappe.io/docs/user/en/bench/resources/background-services.html) +## Resources + - [Bench Commands Cheat Sheet](https://frappe.io/docs/user/en/bench/resources/bench-commands-cheatsheet.html) +- [Background Services](https://frappe.io/docs/user/en/bench/resources/background-services.html) - [Bench Procfile](https://frappe.io/docs/user/en/bench/resources/bench-procfile.html) ---- +For an exhaustive list of resources, check out [Bench Resources](https://frappe.io/docs/user/en/bench/resources). -# License -bench is licensed under [GNU GPLv3](LICENSE) +## License + +This repository has been released under the [GNU GPLv3 License](LICENSE). + +###### Footnotes: + +[^nix]: [*nix and unix-like systems](https://en.wikipedia.org/wiki/Unix-like) +[^docker]: [Docker Website](https://docker.com) +[^nginx-ssl]: [Web Proxy using Docker, NGINX and Let's Encrypt](https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion) +[^letsencrypt]: [LetsEncrypt Website](https://letsencrypt.org) From e1fcbf4f5c6a94d64376ee6c5d7a0bd9c90f41a6 Mon Sep 17 00:00:00 2001 From: "Chinmay D. Pai" Date: Mon, 23 Mar 2020 21:01:50 +0530 Subject: [PATCH 02/18] chore: rename license.md to license do not render markdown for license Signed-off-by: Chinmay D. Pai --- LICENSE.md => LICENSE | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename LICENSE.md => LICENSE (100%) diff --git a/LICENSE.md b/LICENSE similarity index 100% rename from LICENSE.md rename to LICENSE From 0abf074ca44a45a596f34794cfebe0f8c198f632 Mon Sep 17 00:00:00 2001 From: Chinmay Pai Date: Mon, 23 Mar 2020 21:04:14 +0530 Subject: [PATCH 03/18] chore: use em dash instead of double hyphens --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 63e2c322..9f55774c 100755 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Bench is a command-line utility that helps you to install, update, and manage mu ## Installation -A typical bench setup provides two types of environments -- Development and Production. +A typical bench setup provides two types of environments — Development and Production. The setup for each of these installations can be achieved in multiple ways: From 4489759ab19bcf756096b397b8e142ccb51223be Mon Sep 17 00:00:00 2001 From: "Chinmay D. Pai" Date: Mon, 23 Mar 2020 21:12:43 +0530 Subject: [PATCH 04/18] chore: replace footnotes with inline links github markdown does not render footnotes for some reason... Signed-off-by: Chinmay D. Pai --- README.md | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 9f55774c..8bce99e8 100755 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@

Bench

-Bench is a command-line utility that helps you to install, update, and manage multiple sites for Frappe/ERPNext applications on *nix systems[^nix] for development and production. +Bench is a command-line utility that helps you to install, update, and manage multiple sites for Frappe/ERPNext applications on [*nix systems](https://en.wikipedia.org/wiki/Unix-like) for development and production. ## Table of Contents @@ -38,7 +38,7 @@ Otherwise, if you are looking to evaluate ERPNext, you can also download the [Vi ### Docker Installation -A Frappe/ERPNext instance can be setup and replicated easily using Docker[^docker]. The officially supported Docker installation can be used to setup either of both Development and Production environments. +A Frappe/ERPNext instance can be setup and replicated easily using [Docker](https://docker.com). The officially supported Docker installation can be used to setup either of both Development and Production environments. To setup either of the environments, you will need to clone the official docker repository: @@ -67,7 +67,7 @@ Make a directory for handling sites: $ mkdir installation/sites ``` -Optionally, you may also setup an NGINX Proxy for SSL Certificates[^nginx-ssl] with auto-renewal for your Production instance. We recommend this for instances being accessed over the internet. For this to work, the DNS needs to be configured correctly so that LetsEncrypt[^letsencrypt] can verify the domain. To setup the proxy, run the following commands: +Optionally, you may also setup an [NGINX Proxy for SSL Certificates](https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion) with auto-renewal for your Production instance. We recommend this for instances being accessed over the internet. For this to work, the DNS needs to be configured correctly so that [LetsEncrypt](https://letsencrypt.org) can verify the domain. To setup the proxy, run the following commands: ```sh $ git clone https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion.git @@ -231,10 +231,3 @@ For an exhaustive list of resources, check out [Bench Resources](https://frappe. ## License This repository has been released under the [GNU GPLv3 License](LICENSE). - -###### Footnotes: - -[^nix]: [*nix and unix-like systems](https://en.wikipedia.org/wiki/Unix-like) -[^docker]: [Docker Website](https://docker.com) -[^nginx-ssl]: [Web Proxy using Docker, NGINX and Let's Encrypt](https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion) -[^letsencrypt]: [LetsEncrypt Website](https://letsencrypt.org) From c260488886d50100d4a765b875d8fb686b518f51 Mon Sep 17 00:00:00 2001 From: "Chinmay D. Pai" Date: Mon, 30 Mar 2020 12:27:27 +0530 Subject: [PATCH 05/18] chore: add complete docker installation to readme Signed-off-by: Chinmay D. Pai --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index 8bce99e8..45f85645 100755 --- a/README.md +++ b/README.md @@ -76,6 +76,31 @@ $ cp .env.sample .env $ ./start.sh ``` +To get the Production instance running, run the following command: + +```sh +$ docker-compose \ + --project-name \ + -f installation/docker-compose-common.yml \ + -f installation/docker-compose-erpnext.yml \ + -f installation/docker-compose-networks.yml \ + --project-directory installation up -d +``` + +Make sure to replace `` with whatever you wish to call it. This should get the instance running through docker. Now, to create a new site on the instance you may run: + +```sh +docker exec -it \ + -e "SITE_NAME=$SITE_NAME" \ + -e "DB_ROOT_USER=$DB_ROOT_USER" \ + -e "MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD" \ + -e "ADMIN_PASSWORD=$ADMIN_PASSWORD" \ + -e "INSTALL_APPS=erpnext" \ # optional, if you want to install any other apps + _erpnext-python_1 docker-entrypoint.sh new +``` + +Once this is done, you may access the instance at `$SITE_NAME`. + **Note:** The Production setup does not contain, require, or use bench. For a list of substitute commands, check out the [Frappe/ERPNext Docker Site Operations](https://github.com/frappe/frappe_docker/#site-operations). From e218a7aa09eb5c0160d086d7a86cb752c939e042 Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Thu, 2 Apr 2020 15:06:24 +0530 Subject: [PATCH 06/18] chore: renamed project to match with PyPI --- bench/__init__.py | 7 ++++--- bench/app.py | 2 +- bench/cli.py | 23 +++++++++++++++++------ bench/commands/__init__.py | 1 - bench/utils.py | 2 +- setup.py | 11 +++-------- 6 files changed, 26 insertions(+), 20 deletions(-) diff --git a/bench/__init__.py b/bench/__init__.py index e120c37b..8f1ef651 100644 --- a/bench/__init__.py +++ b/bench/__init__.py @@ -1,10 +1,11 @@ from jinja2 import Environment, PackageLoader -__version__ = "4.1.0" - +VERSION = "5.0.0" +PROJECT_NAME = "frappe-bench" +FRAPPE_VERSION = None +__version__ = VERSION env = Environment(loader=PackageLoader('bench.config')) -FRAPPE_VERSION = None def set_frappe_version(bench_path='.'): from .app import get_current_frappe_version diff --git a/bench/app.py b/bench/app.py index a8c71b52..db3aff26 100755 --- a/bench/app.py +++ b/bench/app.py @@ -406,7 +406,7 @@ def switch_branch(branch, apps=None, bench_path='.', upgrade=False, check_upgrad if version_upgrade[0] and upgrade: update_requirements() update_node_packages() - reload_module(utils) + reload_module(bench.utils) backup_all_sites() patch_sites() build_assets() diff --git a/bench/cli.py b/bench/cli.py index f5891d0a..d238f193 100755 --- a/bench/cli.py +++ b/bench/cli.py @@ -1,15 +1,27 @@ +# imports - standard imports +import json +import logging +import os +import pwd +import subprocess +import sys + +# imports - third party imports import click -import os, sys, logging, json, pwd, subprocess -from bench.utils import is_root, PatchError, drop_privileges, get_env_cmd, get_cmd_output, get_frappe, log, is_dist_editable, find_parent_bench + +# imports - module imports +import bench from bench.app import get_apps -from bench.config.common_site_config import get_config from bench.commands import bench_command +from bench.config.common_site_config import get_config +from bench.utils import PatchError, drop_privileges, find_parent_bench, get_cmd_output, get_env_cmd, get_frappe, is_dist_editable, is_root, log -logger = logging.getLogger('bench') +logger = logging.getLogger(bench.PROJECT_NAME) from_command_line = False change_uid_msg = "You should not run this command as root" + def cli(): global from_command_line from_command_line = True @@ -19,7 +31,7 @@ def cli(): change_dir() change_uid() - if is_dist_editable("bench"): + if is_dist_editable(bench.PROJECT_NAME): log("bench is installed in editable mode!\n\nThis is not the recommended mode of installation for production. Instead, install the package from PyPI with: `pip install frappe-bench`\n", level=3) if len(sys.argv) > 2 and sys.argv[1] == "frappe": @@ -41,7 +53,6 @@ def cli(): else: try: - # NOTE: this is the main bench command bench_command() except PatchError: sys.exit(1) diff --git a/bench/commands/__init__.py b/bench/commands/__init__.py index 090013c2..59806be7 100755 --- a/bench/commands/__init__.py +++ b/bench/commands/__init__.py @@ -13,7 +13,6 @@ def print_bench_version(ctx, param, value): @click.group() @click.option('--version', is_flag=True, is_eager=True, callback=print_bench_version, expose_value=False) def bench_command(bench_path='.'): - """Bench manager for Frappe""" import bench from bench.utils import setup_logging diff --git a/bench/utils.py b/bench/utils.py index 6fb985fc..1e4faf33 100755 --- a/bench/utils.py +++ b/bench/utils.py @@ -412,7 +412,7 @@ def setup_sudoers(user): def setup_logging(bench_path='.'): if os.path.exists(os.path.join(bench_path, 'logs')): - logger = logging.getLogger('bench') + logger = logging.getLogger(bench.PROJECT_NAME) log_file = os.path.join(bench_path, 'logs', 'bench.log') formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') hdlr = logging.FileHandler(log_file) diff --git a/setup.py b/setup.py index 6cbeddbc..8bba0fa4 100644 --- a/setup.py +++ b/setup.py @@ -1,22 +1,17 @@ from setuptools import setup, find_packages import re, ast -# get version from __version__ variable in bench/__init__.py -_version_re = re.compile(r'__version__\s+=\s+(.*)') +from bench import PROJECT_NAME, VERSION with open('requirements.txt') as f: install_requires = f.read().strip().split('\n') -with open('bench/__init__.py', 'rb') as f: - version = str(ast.literal_eval(_version_re.search( - f.read().decode('utf-8')).group(1))) - setup( - name='bench', + name=PROJECT_NAME, description='Metadata driven, full-stack web framework', author='Frappe Technologies', author_email='info@frappe.io', - version=version, + version=VERSION, packages=find_packages(), zip_safe=False, include_package_data=True, From 1f4994d4347a92ee7cbfb7a0b9015f4837d7f1a5 Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Thu, 2 Apr 2020 17:35:12 +0530 Subject: [PATCH 07/18] fix: move bench.env to bench.config.env changed namespace to allow usage of __init__ file without checking for jinja2 dependencies --- bench/__init__.py | 3 --- bench/config/__init__.py | 2 ++ bench/config/lets_encrypt.py | 2 +- bench/config/nginx.py | 15 ++++----------- bench/config/procfile.py | 2 +- bench/config/redis.py | 2 +- bench/config/supervisor.py | 2 +- bench/config/systemd.py | 26 +++++++++++++------------- bench/utils.py | 4 +--- 9 files changed, 24 insertions(+), 34 deletions(-) diff --git a/bench/__init__.py b/bench/__init__.py index 8f1ef651..12060392 100644 --- a/bench/__init__.py +++ b/bench/__init__.py @@ -1,10 +1,7 @@ -from jinja2 import Environment, PackageLoader - VERSION = "5.0.0" PROJECT_NAME = "frappe-bench" FRAPPE_VERSION = None __version__ = VERSION -env = Environment(loader=PackageLoader('bench.config')) def set_frappe_version(bench_path='.'): diff --git a/bench/config/__init__.py b/bench/config/__init__.py index e69de29b..5b6b5bcb 100644 --- a/bench/config/__init__.py +++ b/bench/config/__init__.py @@ -0,0 +1,2 @@ +from jinja2 import Environment, PackageLoader +env = Environment(loader=PackageLoader('bench.config')) diff --git a/bench/config/lets_encrypt.py b/bench/config/lets_encrypt.py index 4beac157..17f35dd0 100755 --- a/bench/config/lets_encrypt.py +++ b/bench/config/lets_encrypt.py @@ -44,7 +44,7 @@ def setup_letsencrypt(site, custom_domain, bench_path, interactive): def create_config(site, custom_domain): - config = bench.env.get_template('letsencrypt.cfg').render(domain=custom_domain or site) + config = bench.config.env.get_template('letsencrypt.cfg').render(domain=custom_domain or site) config_path = '/etc/letsencrypt/configs/{site}.cfg'.format(site=custom_domain or site) create_dir_if_missing(config_path) diff --git a/bench/config/nginx.py b/bench/config/nginx.py index 9f10c6f7..d2154112 100644 --- a/bench/config/nginx.py +++ b/bench/config/nginx.py @@ -9,6 +9,7 @@ import click from six import string_types # imports - module imports +import bench from bench.utils import get_bench_name, get_sites @@ -19,14 +20,11 @@ def make_nginx_conf(bench_path, yes=False): if not click.confirm('nginx.conf already exists and this will overwrite it. Do you want to continue?'): return - from bench import env - from bench.config.common_site_config import get_config - - template = env.get_template('nginx.conf') + template = bench.config.env.get_template('nginx.conf') bench_path = os.path.abspath(bench_path) sites_path = os.path.join(bench_path, "sites") - config = get_config(bench_path) + config = bench.config.common_site_config.get_config(bench_path) sites = prepare_sites(config, bench_path) bench_name = get_bench_name(bench_path) @@ -58,17 +56,15 @@ def make_nginx_conf(bench_path, yes=False): f.write(nginx_conf) def make_bench_manager_nginx_conf(bench_path, yes=False, port=23624, domain=None): - from bench import env from bench.config.site_config import get_site_config from bench.config.common_site_config import get_config - template = env.get_template('bench_manager_nginx.conf') + template = bench.config.env.get_template('bench_manager_nginx.conf') bench_path = os.path.abspath(bench_path) sites_path = os.path.join(bench_path, "sites") config = get_config(bench_path) site_config = get_site_config(domain, bench_path=bench_path) - sites = prepare_sites(config, bench_path) bench_name = get_bench_name(bench_path) template_vars = { @@ -153,9 +149,6 @@ def prepare_sites(config, bench_path): while site["port"] in ports_in_use: site["port"] += 1 -# if site["port"] in ports_in_use: -# raise Exception("Port {0} is being used by another site {1}".format(site["port"], ports_in_use[site["port"]])) - if site["port"] in ports_in_use and not site["name"] in ports_in_use[site["port"]]: shared_port_exception_found = True ports_in_use[site["port"]].append(site["name"]) diff --git a/bench/config/procfile.py b/bench/config/procfile.py index a6982c83..cf3899b6 100755 --- a/bench/config/procfile.py +++ b/bench/config/procfile.py @@ -10,7 +10,7 @@ def setup_procfile(bench_path, yes=False, skip_redis=False): click.confirm('A Procfile already exists and this will overwrite it. Do you want to continue?', abort=True) - procfile = bench.env.get_template('Procfile').render( + procfile = bench.config.env.get_template('Procfile').render( node=find_executable("node") or find_executable("nodejs"), use_rq=use_rq(bench_path), webserver_port=config.get('webserver_port'), diff --git a/bench/config/redis.py b/bench/config/redis.py index ae9b5b0f..42005b07 100644 --- a/bench/config/redis.py +++ b/bench/config/redis.py @@ -52,7 +52,7 @@ def generate_config(bench_path): os.makedirs(pid_path) def write_redis_config(template_name, context, bench_path): - template = bench.env.get_template(template_name) + template = bench.config.env.get_template(template_name) if "pid_path" not in context: context["pid_path"] = os.path.abspath(os.path.join(bench_path, "config", "pids")) diff --git a/bench/config/supervisor.py b/bench/config/supervisor.py index 43560cf0..9e9b7a89 100644 --- a/bench/config/supervisor.py +++ b/bench/config/supervisor.py @@ -20,7 +20,7 @@ def generate_supervisor_config(bench_path, user=None, yes=False): update_supervisord_conf(user=user) - template = bench.env.get_template('supervisor.conf') + template = bench.config.env.get_template('supervisor.conf') config = get_config(bench_path=bench_path) bench_dir = os.path.abspath(bench_path) diff --git a/bench/config/systemd.py b/bench/config/systemd.py index 72bed1f2..dbf28c06 100644 --- a/bench/config/systemd.py +++ b/bench/config/systemd.py @@ -78,7 +78,7 @@ def setup_systemd_directory(bench_path): def setup_main_config(bench_info, bench_path): # Main config - bench_template = bench.env.get_template('systemd/frappe-bench.target') + bench_template = bench.config.env.get_template('systemd/frappe-bench.target') bench_config = bench_template.render(**bench_info) bench_config_path = os.path.join(bench_path, 'config', 'systemd' , bench_info.get("bench_name") + '.target') @@ -87,11 +87,11 @@ def setup_main_config(bench_info, bench_path): def setup_workers_config(bench_info, bench_path): # Worker Group - bench_workers_target_template = bench.env.get_template('systemd/frappe-bench-workers.target') - bench_default_worker_template = bench.env.get_template('systemd/frappe-bench-frappe-default-worker.service') - bench_short_worker_template = bench.env.get_template('systemd/frappe-bench-frappe-short-worker.service') - bench_long_worker_template = bench.env.get_template('systemd/frappe-bench-frappe-long-worker.service') - bench_schedule_worker_template = bench.env.get_template('systemd/frappe-bench-frappe-schedule.service') + bench_workers_target_template = bench.config.env.get_template('systemd/frappe-bench-workers.target') + bench_default_worker_template = bench.config.env.get_template('systemd/frappe-bench-frappe-default-worker.service') + bench_short_worker_template = bench.config.env.get_template('systemd/frappe-bench-frappe-short-worker.service') + bench_long_worker_template = bench.config.env.get_template('systemd/frappe-bench-frappe-long-worker.service') + bench_schedule_worker_template = bench.config.env.get_template('systemd/frappe-bench-frappe-schedule.service') bench_workers_target_config = bench_workers_target_template.render(**bench_info) bench_default_worker_config = bench_default_worker_template.render(**bench_info) @@ -122,9 +122,9 @@ def setup_workers_config(bench_info, bench_path): def setup_web_config(bench_info, bench_path): # Web Group - bench_web_target_template = bench.env.get_template('systemd/frappe-bench-web.target') - bench_web_service_template = bench.env.get_template('systemd/frappe-bench-frappe-web.service') - bench_node_socketio_template = bench.env.get_template('systemd/frappe-bench-node-socketio.service') + bench_web_target_template = bench.config.env.get_template('systemd/frappe-bench-web.target') + bench_web_service_template = bench.config.env.get_template('systemd/frappe-bench-frappe-web.service') + bench_node_socketio_template = bench.config.env.get_template('systemd/frappe-bench-node-socketio.service') bench_web_target_config = bench_web_target_template.render(**bench_info) bench_web_service_config = bench_web_service_template.render(**bench_info) @@ -145,10 +145,10 @@ def setup_web_config(bench_info, bench_path): def setup_redis_config(bench_info, bench_path): # Redis Group - bench_redis_target_template = bench.env.get_template('systemd/frappe-bench-redis.target') - bench_redis_cache_template = bench.env.get_template('systemd/frappe-bench-redis-cache.service') - bench_redis_queue_template = bench.env.get_template('systemd/frappe-bench-redis-queue.service') - bench_redis_socketio_template = bench.env.get_template('systemd/frappe-bench-redis-socketio.service') + bench_redis_target_template = bench.config.env.get_template('systemd/frappe-bench-redis.target') + bench_redis_cache_template = bench.config.env.get_template('systemd/frappe-bench-redis-cache.service') + bench_redis_queue_template = bench.config.env.get_template('systemd/frappe-bench-redis-queue.service') + bench_redis_socketio_template = bench.config.env.get_template('systemd/frappe-bench-redis-socketio.service') bench_redis_target_config = bench_redis_target_template.render(**bench_info) bench_redis_cache_config = bench_redis_cache_template.render(**bench_info) diff --git a/bench/utils.py b/bench/utils.py index 1e4faf33..750f6a71 100755 --- a/bench/utils.py +++ b/bench/utils.py @@ -379,8 +379,6 @@ def read_crontab(): def setup_sudoers(user): - from bench import env - if not os.path.exists('/etc/sudoers.d'): os.makedirs('/etc/sudoers.d') @@ -394,7 +392,7 @@ def setup_sudoers(user): if set_permissions: os.chmod('/etc/sudoers', 0o440) - template = env.get_template('frappe_sudoers') + template = bench.config.env.get_template('frappe_sudoers') frappe_sudoers = template.render(**{ 'user': user, 'service': find_executable('service'), From 20152f2dce2bbe0f8e0a7c7f682ca1f78e104653 Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Thu, 2 Apr 2020 22:24:21 +0530 Subject: [PATCH 08/18] style: sort and optimize imports --- bench/commands/setup.py | 1 - bench/config/__init__.py | 2 ++ bench/config/lets_encrypt.py | 24 ++++++++++++++---------- bench/config/procfile.py | 12 ++++++++++-- bench/config/production_setup.py | 3 +-- bench/config/site_config.py | 11 ++++++++--- bench/config/systemd.py | 15 +++++++++++---- 7 files changed, 46 insertions(+), 22 deletions(-) diff --git a/bench/commands/setup.py b/bench/commands/setup.py index 96360bea..2e516496 100755 --- a/bench/commands/setup.py +++ b/bench/commands/setup.py @@ -14,7 +14,6 @@ import bench.config.production_setup import bench.config.redis import bench.config.site_config import bench.config.supervisor - import bench.utils from bench.utils import exec_cmd, run_playbook diff --git a/bench/config/__init__.py b/bench/config/__init__.py index 5b6b5bcb..7dd76eb3 100644 --- a/bench/config/__init__.py +++ b/bench/config/__init__.py @@ -1,2 +1,4 @@ +# imports - third party imports from jinja2 import Environment, PackageLoader + env = Environment(loader=PackageLoader('bench.config')) diff --git a/bench/config/lets_encrypt.py b/bench/config/lets_encrypt.py index 17f35dd0..280554ab 100755 --- a/bench/config/lets_encrypt.py +++ b/bench/config/lets_encrypt.py @@ -1,15 +1,20 @@ -import bench, os, click, errno -from bench.utils import exec_cmd, CommandFailedError, update_common_site_config -from bench.config.site_config import update_site_config, remove_domain, get_domains +# imports - standard imports +import errno +import os + +# imports - third party imports +import click +from crontab import CronTab +from six.moves.urllib.request import urlretrieve + +# imports - module imports +import bench +from bench.config.common_site_config import get_config from bench.config.nginx import make_nginx_conf from bench.config.production_setup import service -from bench.config.common_site_config import get_config -from crontab import CronTab +from bench.config.site_config import get_domains, remove_domain, update_site_config +from bench.utils import CommandFailedError, exec_cmd, update_common_site_config -try: - from urllib.request import urlretrieve -except ImportError: - from urllib import urlretrieve def setup_letsencrypt(site, custom_domain, bench_path, interactive): @@ -171,4 +176,3 @@ def setup_wildcard_ssl(domain, email, bench_path, exclude_base_domain): make_nginx_conf(bench_path) print("Restrting Nginx service") service('nginx', 'restart') - diff --git a/bench/config/procfile.py b/bench/config/procfile.py index cf3899b6..1b3f20ed 100755 --- a/bench/config/procfile.py +++ b/bench/config/procfile.py @@ -1,7 +1,15 @@ -import bench, os, click -from bench.utils import find_executable +# imports - standard imports +import os + +# imports - third party imports +import click + +# imports - module imports +import bench from bench.app import use_rq from bench.config.common_site_config import get_config +from bench.utils import find_executable + def setup_procfile(bench_path, yes=False, skip_redis=False): config = get_config(bench_path=bench_path) diff --git a/bench/config/production_setup.py b/bench/config/production_setup.py index dff6a402..4b5fc774 100755 --- a/bench/config/production_setup.py +++ b/bench/config/production_setup.py @@ -1,14 +1,13 @@ # imports - standard imports import os import sys -from distutils.spawn import find_executable # imports - module imports from bench.config.common_site_config import get_config from bench.config.nginx import make_nginx_conf from bench.config.supervisor import generate_supervisor_config from bench.config.systemd import generate_systemd_config -from bench.utils import CommandFailedError, exec_cmd, fix_prod_setup_perms, get_bench_name, get_cmd_output +from bench.utils import CommandFailedError, exec_cmd, find_executable, fix_prod_setup_perms, get_bench_name, get_cmd_output def setup_production_prerequisites(): diff --git a/bench/config/site_config.py b/bench/config/site_config.py index 6db83ea3..696185c8 100644 --- a/bench/config/site_config.py +++ b/bench/config/site_config.py @@ -1,8 +1,13 @@ -import os, json -from bench.utils import get_sites -from bench.config.nginx import make_nginx_conf +# imports - standard imports +import json +import os from collections import defaultdict +# imports - module imports +from bench.config.nginx import make_nginx_conf +from bench.utils import get_sites + + def get_site_config(site, bench_path='.'): config_path = os.path.join(bench_path, 'sites', site, 'site_config.json') if not os.path.exists(config_path): diff --git a/bench/config/systemd.py b/bench/config/systemd.py index dbf28c06..4a414825 100644 --- a/bench/config/systemd.py +++ b/bench/config/systemd.py @@ -1,9 +1,16 @@ -import os, getpass, click +# imports - standard imports +import getpass +import os + +# imports - third partyimports +import click + +# imports - module imports import bench -from bench.utils import exec_cmd from bench.app import get_current_frappe_version, use_rq -from bench.utils import get_bench_name, find_executable -from bench.config.common_site_config import get_config, update_config, get_gunicorn_workers +from bench.config.common_site_config import get_config, get_gunicorn_workers, update_config +from bench.utils import exec_cmd, find_executable, get_bench_name + def generate_systemd_config(bench_path, user=None, yes=False, stop=False, create_symlinks=False, From 84fb7e296a6e163100e9031d007214db1c1d50b6 Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Fri, 3 Apr 2020 14:42:22 +0530 Subject: [PATCH 09/18] chore: codacy import and docstring fixes --- bench/config/__init__.py | 2 ++ bench/config/lets_encrypt.py | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/bench/config/__init__.py b/bench/config/__init__.py index 7dd76eb3..301b515b 100644 --- a/bench/config/__init__.py +++ b/bench/config/__init__.py @@ -1,3 +1,5 @@ +"""Module for setting up system and respective bench configurations""" + # imports - third party imports from jinja2 import Environment, PackageLoader diff --git a/bench/config/lets_encrypt.py b/bench/config/lets_encrypt.py index 280554ab..5f0396b9 100755 --- a/bench/config/lets_encrypt.py +++ b/bench/config/lets_encrypt.py @@ -1,5 +1,4 @@ # imports - standard imports -import errno import os # imports - third party imports From 8a197eed3da7b8a974880062aac634476e915fc0 Mon Sep 17 00:00:00 2001 From: Chinmay Pai Date: Mon, 6 Apr 2020 17:51:10 +0530 Subject: [PATCH 10/18] chore: fix bench help Co-Authored-By: gavin --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 45f85645..8b6129ca 100755 --- a/README.md +++ b/README.md @@ -202,7 +202,7 @@ For more extensive distribution-dependent documentation, check out the following * Show bench help: ```sh - $ bench help + $ bench --help ``` From 78e1f03cc4176b6318e22bf630b498db7d4ec51e Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Fri, 1 May 2020 17:49:11 +0530 Subject: [PATCH 11/18] fix: add playbooks in the python package --- {playbooks => bench/playbooks}/README.md | 0 {playbooks => bench/playbooks}/create_user.yml | 0 {playbooks => bench/playbooks}/install.py | 2 +- {playbooks => bench/playbooks}/macosx.yml | 0 .../roles/bash_screen_wall/files/screen_wall.sh | 0 .../playbooks}/roles/bash_screen_wall/tasks/main.yml | 0 .../playbooks}/roles/bench/tasks/change_ssh_port.yml | 0 .../playbooks}/roles/bench/tasks/main.yml | 0 .../roles/bench/tasks/setup_bench_production.yml | 0 .../playbooks}/roles/bench/tasks/setup_erpnext.yml | 0 .../playbooks}/roles/bench/tasks/setup_firewall.yml | 0 .../playbooks}/roles/bench/tasks/setup_inputrc.yml | 0 .../playbooks}/roles/common/tasks/debian.yml | 0 .../playbooks}/roles/common/tasks/debian_family.yml | 0 .../playbooks}/roles/common/tasks/macos.yml | 0 .../playbooks}/roles/common/tasks/main.yml | 0 .../playbooks}/roles/common/tasks/redhat_family.yml | 0 .../playbooks}/roles/common/tasks/ubuntu.yml | 0 .../playbooks}/roles/dns_caching/handlers/main.yml | 0 .../playbooks}/roles/dns_caching/tasks/main.yml | 0 .../playbooks}/roles/fail2ban/defaults/main.yml | 0 .../playbooks}/roles/fail2ban/handlers/main.yml | 0 .../roles/fail2ban/tasks/configure_nginx_jail.yml | 0 .../playbooks}/roles/fail2ban/tasks/main.yml | 0 .../fail2ban/templates/nginx-proxy-filter.conf.j2 | 0 .../fail2ban/templates/nginx-proxy-jail.conf.j2 | 0 .../roles/frappe_selinux/files/frappe_selinux.te | 0 .../playbooks}/roles/frappe_selinux/tasks/main.yml | 0 .../playbooks}/roles/locale/defaults/main.yml | 0 .../playbooks}/roles/locale/tasks/main.yml | 0 .../playbooks}/roles/logwatch/defaults/main.yml | 0 .../playbooks}/roles/logwatch/tasks/main.yml | 0 .../roles/logwatch/templates/logwatch.conf.j2 | 0 .../playbooks}/roles/mariadb/README.md | 0 .../playbooks}/roles/mariadb/defaults/main.yml | 0 .../roles/mariadb/files/debian_mariadb_config.cnf | 0 .../roles/mariadb/files/mariadb_config.cnf | 0 .../playbooks}/roles/mariadb/handlers/main.yml | 0 .../playbooks}/roles/mariadb/tasks/centos.yml | 0 .../playbooks}/roles/mariadb/tasks/debian.yml | 0 .../playbooks}/roles/mariadb/tasks/main.yml | 0 .../mariadb/tasks/mysql_secure_installation.yml | 0 .../playbooks}/roles/mariadb/tasks/ubuntu-trusty.yml | 0 .../roles/mariadb/tasks/ubuntu-xenial_bionic.yml | 0 .../roles/mariadb/templates/mariadb_centos.repo.j2 | 0 .../roles/mariadb/templates/mariadb_debian.list.j2 | 0 .../roles/mariadb/templates/mariadb_ubuntu.list.j2 | 0 .../playbooks}/roles/mariadb/templates/my.cnf.j2 | 0 .../playbooks}/roles/mariadb/vars/main.yml | 0 {playbooks => bench/playbooks}/roles/nginx/README.md | 0 .../playbooks}/roles/nginx/defaults/main.yml | 0 .../playbooks}/roles/nginx/handlers/main.yml | 0 .../playbooks}/roles/nginx/meta/main.yml | 0 .../playbooks}/roles/nginx/tasks/main.yml | 0 .../playbooks}/roles/nginx/tasks/setup-Debian.yml | 0 .../playbooks}/roles/nginx/tasks/setup-RedHat.yml | 0 .../playbooks}/roles/nginx/tasks/vhosts.yml | 0 .../playbooks}/roles/nginx/templates/nginx.conf.j2 | 0 .../playbooks}/roles/nginx/templates/nginx.repo.j2 | 0 .../playbooks}/roles/nginx/templates/vhosts.j2 | 0 .../playbooks}/roles/nginx/tests/inventory | 0 .../playbooks}/roles/nginx/tests/test.yml | 0 .../playbooks}/roles/nginx/vars/Debian.yml | 0 .../playbooks}/roles/nginx/vars/RedHat.yml | 0 .../playbooks}/roles/nodejs/defaults/main.yml | 0 .../playbooks}/roles/nodejs/tasks/debian_family.yml | 0 .../playbooks}/roles/nodejs/tasks/main.yml | 0 .../playbooks}/roles/nodejs/tasks/redhat_family.yml | 0 .../playbooks}/roles/ntpd/tasks/main.yml | 0 .../playbooks}/roles/packer/tasks/debian_family.yml | 0 .../playbooks}/roles/packer/tasks/main.yml | 0 .../playbooks}/roles/packer/tasks/redhat_family.yml | 0 .../playbooks}/roles/psutil/tasks/main.yml | 0 .../playbooks}/roles/redis/tasks/main.yml | 0 .../playbooks}/roles/supervisor/tasks/main.yml | 0 .../playbooks}/roles/swap/defaults/main.yml | 0 .../playbooks}/roles/swap/tasks/main.yml | 0 .../playbooks}/roles/virtualbox/defaults/main.yml | 0 .../roles/virtualbox/files/virtualbox_centos.repo | 0 .../roles/virtualbox/tasks/debian_family.yml | 0 .../playbooks}/roles/virtualbox/tasks/main.yml | 0 .../roles/virtualbox/tasks/redhat_family.yml | 0 .../playbooks}/roles/wkhtmltopdf/tasks/main.yml | 0 {playbooks => bench/playbooks}/site.yml | 0 {playbooks => bench/playbooks}/vm_build.yml | 0 bench/utils.py | 2 +- setup.py | 12 ++++++++---- 87 files changed, 10 insertions(+), 6 deletions(-) rename {playbooks => bench/playbooks}/README.md (100%) rename {playbooks => bench/playbooks}/create_user.yml (100%) rename {playbooks => bench/playbooks}/install.py (99%) rename {playbooks => bench/playbooks}/macosx.yml (100%) rename {playbooks => bench/playbooks}/roles/bash_screen_wall/files/screen_wall.sh (100%) rename {playbooks => bench/playbooks}/roles/bash_screen_wall/tasks/main.yml (100%) rename {playbooks => bench/playbooks}/roles/bench/tasks/change_ssh_port.yml (100%) rename {playbooks => bench/playbooks}/roles/bench/tasks/main.yml (100%) rename {playbooks => bench/playbooks}/roles/bench/tasks/setup_bench_production.yml (100%) rename {playbooks => bench/playbooks}/roles/bench/tasks/setup_erpnext.yml (100%) rename {playbooks => bench/playbooks}/roles/bench/tasks/setup_firewall.yml (100%) rename {playbooks => bench/playbooks}/roles/bench/tasks/setup_inputrc.yml (100%) rename {playbooks => bench/playbooks}/roles/common/tasks/debian.yml (100%) rename {playbooks => bench/playbooks}/roles/common/tasks/debian_family.yml (100%) rename {playbooks => bench/playbooks}/roles/common/tasks/macos.yml (100%) rename {playbooks => bench/playbooks}/roles/common/tasks/main.yml (100%) rename {playbooks => bench/playbooks}/roles/common/tasks/redhat_family.yml (100%) rename {playbooks => bench/playbooks}/roles/common/tasks/ubuntu.yml (100%) rename {playbooks => bench/playbooks}/roles/dns_caching/handlers/main.yml (100%) rename {playbooks => bench/playbooks}/roles/dns_caching/tasks/main.yml (100%) rename {playbooks => bench/playbooks}/roles/fail2ban/defaults/main.yml (100%) rename {playbooks => bench/playbooks}/roles/fail2ban/handlers/main.yml (100%) rename {playbooks => bench/playbooks}/roles/fail2ban/tasks/configure_nginx_jail.yml (100%) rename {playbooks => bench/playbooks}/roles/fail2ban/tasks/main.yml (100%) rename {playbooks => bench/playbooks}/roles/fail2ban/templates/nginx-proxy-filter.conf.j2 (100%) rename {playbooks => bench/playbooks}/roles/fail2ban/templates/nginx-proxy-jail.conf.j2 (100%) rename {playbooks => bench/playbooks}/roles/frappe_selinux/files/frappe_selinux.te (100%) rename {playbooks => bench/playbooks}/roles/frappe_selinux/tasks/main.yml (100%) rename {playbooks => bench/playbooks}/roles/locale/defaults/main.yml (100%) rename {playbooks => bench/playbooks}/roles/locale/tasks/main.yml (100%) rename {playbooks => bench/playbooks}/roles/logwatch/defaults/main.yml (100%) rename {playbooks => bench/playbooks}/roles/logwatch/tasks/main.yml (100%) rename {playbooks => bench/playbooks}/roles/logwatch/templates/logwatch.conf.j2 (100%) rename {playbooks => bench/playbooks}/roles/mariadb/README.md (100%) rename {playbooks => bench/playbooks}/roles/mariadb/defaults/main.yml (100%) rename {playbooks => bench/playbooks}/roles/mariadb/files/debian_mariadb_config.cnf (100%) rename {playbooks => bench/playbooks}/roles/mariadb/files/mariadb_config.cnf (100%) rename {playbooks => bench/playbooks}/roles/mariadb/handlers/main.yml (100%) rename {playbooks => bench/playbooks}/roles/mariadb/tasks/centos.yml (100%) rename {playbooks => bench/playbooks}/roles/mariadb/tasks/debian.yml (100%) rename {playbooks => bench/playbooks}/roles/mariadb/tasks/main.yml (100%) rename {playbooks => bench/playbooks}/roles/mariadb/tasks/mysql_secure_installation.yml (100%) rename {playbooks => bench/playbooks}/roles/mariadb/tasks/ubuntu-trusty.yml (100%) rename {playbooks => bench/playbooks}/roles/mariadb/tasks/ubuntu-xenial_bionic.yml (100%) rename {playbooks => bench/playbooks}/roles/mariadb/templates/mariadb_centos.repo.j2 (100%) rename {playbooks => bench/playbooks}/roles/mariadb/templates/mariadb_debian.list.j2 (100%) rename {playbooks => bench/playbooks}/roles/mariadb/templates/mariadb_ubuntu.list.j2 (100%) rename {playbooks => bench/playbooks}/roles/mariadb/templates/my.cnf.j2 (100%) rename {playbooks => bench/playbooks}/roles/mariadb/vars/main.yml (100%) rename {playbooks => bench/playbooks}/roles/nginx/README.md (100%) rename {playbooks => bench/playbooks}/roles/nginx/defaults/main.yml (100%) rename {playbooks => bench/playbooks}/roles/nginx/handlers/main.yml (100%) rename {playbooks => bench/playbooks}/roles/nginx/meta/main.yml (100%) rename {playbooks => bench/playbooks}/roles/nginx/tasks/main.yml (100%) rename {playbooks => bench/playbooks}/roles/nginx/tasks/setup-Debian.yml (100%) rename {playbooks => bench/playbooks}/roles/nginx/tasks/setup-RedHat.yml (100%) rename {playbooks => bench/playbooks}/roles/nginx/tasks/vhosts.yml (100%) rename {playbooks => bench/playbooks}/roles/nginx/templates/nginx.conf.j2 (100%) rename {playbooks => bench/playbooks}/roles/nginx/templates/nginx.repo.j2 (100%) rename {playbooks => bench/playbooks}/roles/nginx/templates/vhosts.j2 (100%) rename {playbooks => bench/playbooks}/roles/nginx/tests/inventory (100%) rename {playbooks => bench/playbooks}/roles/nginx/tests/test.yml (100%) rename {playbooks => bench/playbooks}/roles/nginx/vars/Debian.yml (100%) rename {playbooks => bench/playbooks}/roles/nginx/vars/RedHat.yml (100%) rename {playbooks => bench/playbooks}/roles/nodejs/defaults/main.yml (100%) rename {playbooks => bench/playbooks}/roles/nodejs/tasks/debian_family.yml (100%) rename {playbooks => bench/playbooks}/roles/nodejs/tasks/main.yml (100%) rename {playbooks => bench/playbooks}/roles/nodejs/tasks/redhat_family.yml (100%) rename {playbooks => bench/playbooks}/roles/ntpd/tasks/main.yml (100%) rename {playbooks => bench/playbooks}/roles/packer/tasks/debian_family.yml (100%) rename {playbooks => bench/playbooks}/roles/packer/tasks/main.yml (100%) rename {playbooks => bench/playbooks}/roles/packer/tasks/redhat_family.yml (100%) rename {playbooks => bench/playbooks}/roles/psutil/tasks/main.yml (100%) rename {playbooks => bench/playbooks}/roles/redis/tasks/main.yml (100%) rename {playbooks => bench/playbooks}/roles/supervisor/tasks/main.yml (100%) rename {playbooks => bench/playbooks}/roles/swap/defaults/main.yml (100%) rename {playbooks => bench/playbooks}/roles/swap/tasks/main.yml (100%) rename {playbooks => bench/playbooks}/roles/virtualbox/defaults/main.yml (100%) rename {playbooks => bench/playbooks}/roles/virtualbox/files/virtualbox_centos.repo (100%) rename {playbooks => bench/playbooks}/roles/virtualbox/tasks/debian_family.yml (100%) rename {playbooks => bench/playbooks}/roles/virtualbox/tasks/main.yml (100%) rename {playbooks => bench/playbooks}/roles/virtualbox/tasks/redhat_family.yml (100%) rename {playbooks => bench/playbooks}/roles/wkhtmltopdf/tasks/main.yml (100%) rename {playbooks => bench/playbooks}/site.yml (100%) rename {playbooks => bench/playbooks}/vm_build.yml (100%) diff --git a/playbooks/README.md b/bench/playbooks/README.md similarity index 100% rename from playbooks/README.md rename to bench/playbooks/README.md diff --git a/playbooks/create_user.yml b/bench/playbooks/create_user.yml similarity index 100% rename from playbooks/create_user.yml rename to bench/playbooks/create_user.yml diff --git a/playbooks/install.py b/bench/playbooks/install.py similarity index 99% rename from playbooks/install.py rename to bench/playbooks/install.py index 9867d185..cb8ecff8 100644 --- a/playbooks/install.py +++ b/bench/playbooks/install.py @@ -359,7 +359,7 @@ def run_playbook(playbook_name, sudo=False, extra_vars=None): else: cwd = os.path.join(os.path.expanduser('~'), 'bench') - success = subprocess.check_call(args, cwd=os.path.join(cwd, 'playbooks'), stdout=log_stream, stderr=sys.stderr) + success = subprocess.check_call(args, cwd=os.path.join(cwd, 'bench', 'playbooks'), stdout=log_stream, stderr=sys.stderr) return success diff --git a/playbooks/macosx.yml b/bench/playbooks/macosx.yml similarity index 100% rename from playbooks/macosx.yml rename to bench/playbooks/macosx.yml diff --git a/playbooks/roles/bash_screen_wall/files/screen_wall.sh b/bench/playbooks/roles/bash_screen_wall/files/screen_wall.sh similarity index 100% rename from playbooks/roles/bash_screen_wall/files/screen_wall.sh rename to bench/playbooks/roles/bash_screen_wall/files/screen_wall.sh diff --git a/playbooks/roles/bash_screen_wall/tasks/main.yml b/bench/playbooks/roles/bash_screen_wall/tasks/main.yml similarity index 100% rename from playbooks/roles/bash_screen_wall/tasks/main.yml rename to bench/playbooks/roles/bash_screen_wall/tasks/main.yml diff --git a/playbooks/roles/bench/tasks/change_ssh_port.yml b/bench/playbooks/roles/bench/tasks/change_ssh_port.yml similarity index 100% rename from playbooks/roles/bench/tasks/change_ssh_port.yml rename to bench/playbooks/roles/bench/tasks/change_ssh_port.yml diff --git a/playbooks/roles/bench/tasks/main.yml b/bench/playbooks/roles/bench/tasks/main.yml similarity index 100% rename from playbooks/roles/bench/tasks/main.yml rename to bench/playbooks/roles/bench/tasks/main.yml diff --git a/playbooks/roles/bench/tasks/setup_bench_production.yml b/bench/playbooks/roles/bench/tasks/setup_bench_production.yml similarity index 100% rename from playbooks/roles/bench/tasks/setup_bench_production.yml rename to bench/playbooks/roles/bench/tasks/setup_bench_production.yml diff --git a/playbooks/roles/bench/tasks/setup_erpnext.yml b/bench/playbooks/roles/bench/tasks/setup_erpnext.yml similarity index 100% rename from playbooks/roles/bench/tasks/setup_erpnext.yml rename to bench/playbooks/roles/bench/tasks/setup_erpnext.yml diff --git a/playbooks/roles/bench/tasks/setup_firewall.yml b/bench/playbooks/roles/bench/tasks/setup_firewall.yml similarity index 100% rename from playbooks/roles/bench/tasks/setup_firewall.yml rename to bench/playbooks/roles/bench/tasks/setup_firewall.yml diff --git a/playbooks/roles/bench/tasks/setup_inputrc.yml b/bench/playbooks/roles/bench/tasks/setup_inputrc.yml similarity index 100% rename from playbooks/roles/bench/tasks/setup_inputrc.yml rename to bench/playbooks/roles/bench/tasks/setup_inputrc.yml diff --git a/playbooks/roles/common/tasks/debian.yml b/bench/playbooks/roles/common/tasks/debian.yml similarity index 100% rename from playbooks/roles/common/tasks/debian.yml rename to bench/playbooks/roles/common/tasks/debian.yml diff --git a/playbooks/roles/common/tasks/debian_family.yml b/bench/playbooks/roles/common/tasks/debian_family.yml similarity index 100% rename from playbooks/roles/common/tasks/debian_family.yml rename to bench/playbooks/roles/common/tasks/debian_family.yml diff --git a/playbooks/roles/common/tasks/macos.yml b/bench/playbooks/roles/common/tasks/macos.yml similarity index 100% rename from playbooks/roles/common/tasks/macos.yml rename to bench/playbooks/roles/common/tasks/macos.yml diff --git a/playbooks/roles/common/tasks/main.yml b/bench/playbooks/roles/common/tasks/main.yml similarity index 100% rename from playbooks/roles/common/tasks/main.yml rename to bench/playbooks/roles/common/tasks/main.yml diff --git a/playbooks/roles/common/tasks/redhat_family.yml b/bench/playbooks/roles/common/tasks/redhat_family.yml similarity index 100% rename from playbooks/roles/common/tasks/redhat_family.yml rename to bench/playbooks/roles/common/tasks/redhat_family.yml diff --git a/playbooks/roles/common/tasks/ubuntu.yml b/bench/playbooks/roles/common/tasks/ubuntu.yml similarity index 100% rename from playbooks/roles/common/tasks/ubuntu.yml rename to bench/playbooks/roles/common/tasks/ubuntu.yml diff --git a/playbooks/roles/dns_caching/handlers/main.yml b/bench/playbooks/roles/dns_caching/handlers/main.yml similarity index 100% rename from playbooks/roles/dns_caching/handlers/main.yml rename to bench/playbooks/roles/dns_caching/handlers/main.yml diff --git a/playbooks/roles/dns_caching/tasks/main.yml b/bench/playbooks/roles/dns_caching/tasks/main.yml similarity index 100% rename from playbooks/roles/dns_caching/tasks/main.yml rename to bench/playbooks/roles/dns_caching/tasks/main.yml diff --git a/playbooks/roles/fail2ban/defaults/main.yml b/bench/playbooks/roles/fail2ban/defaults/main.yml similarity index 100% rename from playbooks/roles/fail2ban/defaults/main.yml rename to bench/playbooks/roles/fail2ban/defaults/main.yml diff --git a/playbooks/roles/fail2ban/handlers/main.yml b/bench/playbooks/roles/fail2ban/handlers/main.yml similarity index 100% rename from playbooks/roles/fail2ban/handlers/main.yml rename to bench/playbooks/roles/fail2ban/handlers/main.yml diff --git a/playbooks/roles/fail2ban/tasks/configure_nginx_jail.yml b/bench/playbooks/roles/fail2ban/tasks/configure_nginx_jail.yml similarity index 100% rename from playbooks/roles/fail2ban/tasks/configure_nginx_jail.yml rename to bench/playbooks/roles/fail2ban/tasks/configure_nginx_jail.yml diff --git a/playbooks/roles/fail2ban/tasks/main.yml b/bench/playbooks/roles/fail2ban/tasks/main.yml similarity index 100% rename from playbooks/roles/fail2ban/tasks/main.yml rename to bench/playbooks/roles/fail2ban/tasks/main.yml diff --git a/playbooks/roles/fail2ban/templates/nginx-proxy-filter.conf.j2 b/bench/playbooks/roles/fail2ban/templates/nginx-proxy-filter.conf.j2 similarity index 100% rename from playbooks/roles/fail2ban/templates/nginx-proxy-filter.conf.j2 rename to bench/playbooks/roles/fail2ban/templates/nginx-proxy-filter.conf.j2 diff --git a/playbooks/roles/fail2ban/templates/nginx-proxy-jail.conf.j2 b/bench/playbooks/roles/fail2ban/templates/nginx-proxy-jail.conf.j2 similarity index 100% rename from playbooks/roles/fail2ban/templates/nginx-proxy-jail.conf.j2 rename to bench/playbooks/roles/fail2ban/templates/nginx-proxy-jail.conf.j2 diff --git a/playbooks/roles/frappe_selinux/files/frappe_selinux.te b/bench/playbooks/roles/frappe_selinux/files/frappe_selinux.te similarity index 100% rename from playbooks/roles/frappe_selinux/files/frappe_selinux.te rename to bench/playbooks/roles/frappe_selinux/files/frappe_selinux.te diff --git a/playbooks/roles/frappe_selinux/tasks/main.yml b/bench/playbooks/roles/frappe_selinux/tasks/main.yml similarity index 100% rename from playbooks/roles/frappe_selinux/tasks/main.yml rename to bench/playbooks/roles/frappe_selinux/tasks/main.yml diff --git a/playbooks/roles/locale/defaults/main.yml b/bench/playbooks/roles/locale/defaults/main.yml similarity index 100% rename from playbooks/roles/locale/defaults/main.yml rename to bench/playbooks/roles/locale/defaults/main.yml diff --git a/playbooks/roles/locale/tasks/main.yml b/bench/playbooks/roles/locale/tasks/main.yml similarity index 100% rename from playbooks/roles/locale/tasks/main.yml rename to bench/playbooks/roles/locale/tasks/main.yml diff --git a/playbooks/roles/logwatch/defaults/main.yml b/bench/playbooks/roles/logwatch/defaults/main.yml similarity index 100% rename from playbooks/roles/logwatch/defaults/main.yml rename to bench/playbooks/roles/logwatch/defaults/main.yml diff --git a/playbooks/roles/logwatch/tasks/main.yml b/bench/playbooks/roles/logwatch/tasks/main.yml similarity index 100% rename from playbooks/roles/logwatch/tasks/main.yml rename to bench/playbooks/roles/logwatch/tasks/main.yml diff --git a/playbooks/roles/logwatch/templates/logwatch.conf.j2 b/bench/playbooks/roles/logwatch/templates/logwatch.conf.j2 similarity index 100% rename from playbooks/roles/logwatch/templates/logwatch.conf.j2 rename to bench/playbooks/roles/logwatch/templates/logwatch.conf.j2 diff --git a/playbooks/roles/mariadb/README.md b/bench/playbooks/roles/mariadb/README.md similarity index 100% rename from playbooks/roles/mariadb/README.md rename to bench/playbooks/roles/mariadb/README.md diff --git a/playbooks/roles/mariadb/defaults/main.yml b/bench/playbooks/roles/mariadb/defaults/main.yml similarity index 100% rename from playbooks/roles/mariadb/defaults/main.yml rename to bench/playbooks/roles/mariadb/defaults/main.yml diff --git a/playbooks/roles/mariadb/files/debian_mariadb_config.cnf b/bench/playbooks/roles/mariadb/files/debian_mariadb_config.cnf similarity index 100% rename from playbooks/roles/mariadb/files/debian_mariadb_config.cnf rename to bench/playbooks/roles/mariadb/files/debian_mariadb_config.cnf diff --git a/playbooks/roles/mariadb/files/mariadb_config.cnf b/bench/playbooks/roles/mariadb/files/mariadb_config.cnf similarity index 100% rename from playbooks/roles/mariadb/files/mariadb_config.cnf rename to bench/playbooks/roles/mariadb/files/mariadb_config.cnf diff --git a/playbooks/roles/mariadb/handlers/main.yml b/bench/playbooks/roles/mariadb/handlers/main.yml similarity index 100% rename from playbooks/roles/mariadb/handlers/main.yml rename to bench/playbooks/roles/mariadb/handlers/main.yml diff --git a/playbooks/roles/mariadb/tasks/centos.yml b/bench/playbooks/roles/mariadb/tasks/centos.yml similarity index 100% rename from playbooks/roles/mariadb/tasks/centos.yml rename to bench/playbooks/roles/mariadb/tasks/centos.yml diff --git a/playbooks/roles/mariadb/tasks/debian.yml b/bench/playbooks/roles/mariadb/tasks/debian.yml similarity index 100% rename from playbooks/roles/mariadb/tasks/debian.yml rename to bench/playbooks/roles/mariadb/tasks/debian.yml diff --git a/playbooks/roles/mariadb/tasks/main.yml b/bench/playbooks/roles/mariadb/tasks/main.yml similarity index 100% rename from playbooks/roles/mariadb/tasks/main.yml rename to bench/playbooks/roles/mariadb/tasks/main.yml diff --git a/playbooks/roles/mariadb/tasks/mysql_secure_installation.yml b/bench/playbooks/roles/mariadb/tasks/mysql_secure_installation.yml similarity index 100% rename from playbooks/roles/mariadb/tasks/mysql_secure_installation.yml rename to bench/playbooks/roles/mariadb/tasks/mysql_secure_installation.yml diff --git a/playbooks/roles/mariadb/tasks/ubuntu-trusty.yml b/bench/playbooks/roles/mariadb/tasks/ubuntu-trusty.yml similarity index 100% rename from playbooks/roles/mariadb/tasks/ubuntu-trusty.yml rename to bench/playbooks/roles/mariadb/tasks/ubuntu-trusty.yml diff --git a/playbooks/roles/mariadb/tasks/ubuntu-xenial_bionic.yml b/bench/playbooks/roles/mariadb/tasks/ubuntu-xenial_bionic.yml similarity index 100% rename from playbooks/roles/mariadb/tasks/ubuntu-xenial_bionic.yml rename to bench/playbooks/roles/mariadb/tasks/ubuntu-xenial_bionic.yml diff --git a/playbooks/roles/mariadb/templates/mariadb_centos.repo.j2 b/bench/playbooks/roles/mariadb/templates/mariadb_centos.repo.j2 similarity index 100% rename from playbooks/roles/mariadb/templates/mariadb_centos.repo.j2 rename to bench/playbooks/roles/mariadb/templates/mariadb_centos.repo.j2 diff --git a/playbooks/roles/mariadb/templates/mariadb_debian.list.j2 b/bench/playbooks/roles/mariadb/templates/mariadb_debian.list.j2 similarity index 100% rename from playbooks/roles/mariadb/templates/mariadb_debian.list.j2 rename to bench/playbooks/roles/mariadb/templates/mariadb_debian.list.j2 diff --git a/playbooks/roles/mariadb/templates/mariadb_ubuntu.list.j2 b/bench/playbooks/roles/mariadb/templates/mariadb_ubuntu.list.j2 similarity index 100% rename from playbooks/roles/mariadb/templates/mariadb_ubuntu.list.j2 rename to bench/playbooks/roles/mariadb/templates/mariadb_ubuntu.list.j2 diff --git a/playbooks/roles/mariadb/templates/my.cnf.j2 b/bench/playbooks/roles/mariadb/templates/my.cnf.j2 similarity index 100% rename from playbooks/roles/mariadb/templates/my.cnf.j2 rename to bench/playbooks/roles/mariadb/templates/my.cnf.j2 diff --git a/playbooks/roles/mariadb/vars/main.yml b/bench/playbooks/roles/mariadb/vars/main.yml similarity index 100% rename from playbooks/roles/mariadb/vars/main.yml rename to bench/playbooks/roles/mariadb/vars/main.yml diff --git a/playbooks/roles/nginx/README.md b/bench/playbooks/roles/nginx/README.md similarity index 100% rename from playbooks/roles/nginx/README.md rename to bench/playbooks/roles/nginx/README.md diff --git a/playbooks/roles/nginx/defaults/main.yml b/bench/playbooks/roles/nginx/defaults/main.yml similarity index 100% rename from playbooks/roles/nginx/defaults/main.yml rename to bench/playbooks/roles/nginx/defaults/main.yml diff --git a/playbooks/roles/nginx/handlers/main.yml b/bench/playbooks/roles/nginx/handlers/main.yml similarity index 100% rename from playbooks/roles/nginx/handlers/main.yml rename to bench/playbooks/roles/nginx/handlers/main.yml diff --git a/playbooks/roles/nginx/meta/main.yml b/bench/playbooks/roles/nginx/meta/main.yml similarity index 100% rename from playbooks/roles/nginx/meta/main.yml rename to bench/playbooks/roles/nginx/meta/main.yml diff --git a/playbooks/roles/nginx/tasks/main.yml b/bench/playbooks/roles/nginx/tasks/main.yml similarity index 100% rename from playbooks/roles/nginx/tasks/main.yml rename to bench/playbooks/roles/nginx/tasks/main.yml diff --git a/playbooks/roles/nginx/tasks/setup-Debian.yml b/bench/playbooks/roles/nginx/tasks/setup-Debian.yml similarity index 100% rename from playbooks/roles/nginx/tasks/setup-Debian.yml rename to bench/playbooks/roles/nginx/tasks/setup-Debian.yml diff --git a/playbooks/roles/nginx/tasks/setup-RedHat.yml b/bench/playbooks/roles/nginx/tasks/setup-RedHat.yml similarity index 100% rename from playbooks/roles/nginx/tasks/setup-RedHat.yml rename to bench/playbooks/roles/nginx/tasks/setup-RedHat.yml diff --git a/playbooks/roles/nginx/tasks/vhosts.yml b/bench/playbooks/roles/nginx/tasks/vhosts.yml similarity index 100% rename from playbooks/roles/nginx/tasks/vhosts.yml rename to bench/playbooks/roles/nginx/tasks/vhosts.yml diff --git a/playbooks/roles/nginx/templates/nginx.conf.j2 b/bench/playbooks/roles/nginx/templates/nginx.conf.j2 similarity index 100% rename from playbooks/roles/nginx/templates/nginx.conf.j2 rename to bench/playbooks/roles/nginx/templates/nginx.conf.j2 diff --git a/playbooks/roles/nginx/templates/nginx.repo.j2 b/bench/playbooks/roles/nginx/templates/nginx.repo.j2 similarity index 100% rename from playbooks/roles/nginx/templates/nginx.repo.j2 rename to bench/playbooks/roles/nginx/templates/nginx.repo.j2 diff --git a/playbooks/roles/nginx/templates/vhosts.j2 b/bench/playbooks/roles/nginx/templates/vhosts.j2 similarity index 100% rename from playbooks/roles/nginx/templates/vhosts.j2 rename to bench/playbooks/roles/nginx/templates/vhosts.j2 diff --git a/playbooks/roles/nginx/tests/inventory b/bench/playbooks/roles/nginx/tests/inventory similarity index 100% rename from playbooks/roles/nginx/tests/inventory rename to bench/playbooks/roles/nginx/tests/inventory diff --git a/playbooks/roles/nginx/tests/test.yml b/bench/playbooks/roles/nginx/tests/test.yml similarity index 100% rename from playbooks/roles/nginx/tests/test.yml rename to bench/playbooks/roles/nginx/tests/test.yml diff --git a/playbooks/roles/nginx/vars/Debian.yml b/bench/playbooks/roles/nginx/vars/Debian.yml similarity index 100% rename from playbooks/roles/nginx/vars/Debian.yml rename to bench/playbooks/roles/nginx/vars/Debian.yml diff --git a/playbooks/roles/nginx/vars/RedHat.yml b/bench/playbooks/roles/nginx/vars/RedHat.yml similarity index 100% rename from playbooks/roles/nginx/vars/RedHat.yml rename to bench/playbooks/roles/nginx/vars/RedHat.yml diff --git a/playbooks/roles/nodejs/defaults/main.yml b/bench/playbooks/roles/nodejs/defaults/main.yml similarity index 100% rename from playbooks/roles/nodejs/defaults/main.yml rename to bench/playbooks/roles/nodejs/defaults/main.yml diff --git a/playbooks/roles/nodejs/tasks/debian_family.yml b/bench/playbooks/roles/nodejs/tasks/debian_family.yml similarity index 100% rename from playbooks/roles/nodejs/tasks/debian_family.yml rename to bench/playbooks/roles/nodejs/tasks/debian_family.yml diff --git a/playbooks/roles/nodejs/tasks/main.yml b/bench/playbooks/roles/nodejs/tasks/main.yml similarity index 100% rename from playbooks/roles/nodejs/tasks/main.yml rename to bench/playbooks/roles/nodejs/tasks/main.yml diff --git a/playbooks/roles/nodejs/tasks/redhat_family.yml b/bench/playbooks/roles/nodejs/tasks/redhat_family.yml similarity index 100% rename from playbooks/roles/nodejs/tasks/redhat_family.yml rename to bench/playbooks/roles/nodejs/tasks/redhat_family.yml diff --git a/playbooks/roles/ntpd/tasks/main.yml b/bench/playbooks/roles/ntpd/tasks/main.yml similarity index 100% rename from playbooks/roles/ntpd/tasks/main.yml rename to bench/playbooks/roles/ntpd/tasks/main.yml diff --git a/playbooks/roles/packer/tasks/debian_family.yml b/bench/playbooks/roles/packer/tasks/debian_family.yml similarity index 100% rename from playbooks/roles/packer/tasks/debian_family.yml rename to bench/playbooks/roles/packer/tasks/debian_family.yml diff --git a/playbooks/roles/packer/tasks/main.yml b/bench/playbooks/roles/packer/tasks/main.yml similarity index 100% rename from playbooks/roles/packer/tasks/main.yml rename to bench/playbooks/roles/packer/tasks/main.yml diff --git a/playbooks/roles/packer/tasks/redhat_family.yml b/bench/playbooks/roles/packer/tasks/redhat_family.yml similarity index 100% rename from playbooks/roles/packer/tasks/redhat_family.yml rename to bench/playbooks/roles/packer/tasks/redhat_family.yml diff --git a/playbooks/roles/psutil/tasks/main.yml b/bench/playbooks/roles/psutil/tasks/main.yml similarity index 100% rename from playbooks/roles/psutil/tasks/main.yml rename to bench/playbooks/roles/psutil/tasks/main.yml diff --git a/playbooks/roles/redis/tasks/main.yml b/bench/playbooks/roles/redis/tasks/main.yml similarity index 100% rename from playbooks/roles/redis/tasks/main.yml rename to bench/playbooks/roles/redis/tasks/main.yml diff --git a/playbooks/roles/supervisor/tasks/main.yml b/bench/playbooks/roles/supervisor/tasks/main.yml similarity index 100% rename from playbooks/roles/supervisor/tasks/main.yml rename to bench/playbooks/roles/supervisor/tasks/main.yml diff --git a/playbooks/roles/swap/defaults/main.yml b/bench/playbooks/roles/swap/defaults/main.yml similarity index 100% rename from playbooks/roles/swap/defaults/main.yml rename to bench/playbooks/roles/swap/defaults/main.yml diff --git a/playbooks/roles/swap/tasks/main.yml b/bench/playbooks/roles/swap/tasks/main.yml similarity index 100% rename from playbooks/roles/swap/tasks/main.yml rename to bench/playbooks/roles/swap/tasks/main.yml diff --git a/playbooks/roles/virtualbox/defaults/main.yml b/bench/playbooks/roles/virtualbox/defaults/main.yml similarity index 100% rename from playbooks/roles/virtualbox/defaults/main.yml rename to bench/playbooks/roles/virtualbox/defaults/main.yml diff --git a/playbooks/roles/virtualbox/files/virtualbox_centos.repo b/bench/playbooks/roles/virtualbox/files/virtualbox_centos.repo similarity index 100% rename from playbooks/roles/virtualbox/files/virtualbox_centos.repo rename to bench/playbooks/roles/virtualbox/files/virtualbox_centos.repo diff --git a/playbooks/roles/virtualbox/tasks/debian_family.yml b/bench/playbooks/roles/virtualbox/tasks/debian_family.yml similarity index 100% rename from playbooks/roles/virtualbox/tasks/debian_family.yml rename to bench/playbooks/roles/virtualbox/tasks/debian_family.yml diff --git a/playbooks/roles/virtualbox/tasks/main.yml b/bench/playbooks/roles/virtualbox/tasks/main.yml similarity index 100% rename from playbooks/roles/virtualbox/tasks/main.yml rename to bench/playbooks/roles/virtualbox/tasks/main.yml diff --git a/playbooks/roles/virtualbox/tasks/redhat_family.yml b/bench/playbooks/roles/virtualbox/tasks/redhat_family.yml similarity index 100% rename from playbooks/roles/virtualbox/tasks/redhat_family.yml rename to bench/playbooks/roles/virtualbox/tasks/redhat_family.yml diff --git a/playbooks/roles/wkhtmltopdf/tasks/main.yml b/bench/playbooks/roles/wkhtmltopdf/tasks/main.yml similarity index 100% rename from playbooks/roles/wkhtmltopdf/tasks/main.yml rename to bench/playbooks/roles/wkhtmltopdf/tasks/main.yml diff --git a/playbooks/site.yml b/bench/playbooks/site.yml similarity index 100% rename from playbooks/site.yml rename to bench/playbooks/site.yml diff --git a/playbooks/vm_build.yml b/bench/playbooks/vm_build.yml similarity index 100% rename from playbooks/vm_build.yml rename to bench/playbooks/vm_build.yml diff --git a/bench/utils.py b/bench/utils.py index 35c985ad..fc484ad5 100755 --- a/bench/utils.py +++ b/bench/utils.py @@ -961,7 +961,7 @@ def run_playbook(playbook_name, extra_vars=None, tag=None): 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(bench.__path__[0], 'playbooks')) def find_benches(directory=None): diff --git a/setup.py b/setup.py index 6cbeddbc..5f23a676 100644 --- a/setup.py +++ b/setup.py @@ -1,13 +1,16 @@ -from setuptools import setup, find_packages -import re, ast +import ast +import os +import re -# get version from __version__ variable in bench/__init__.py -_version_re = re.compile(r'__version__\s+=\s+(.*)') +from setuptools import find_packages, setup + +playbooks_files = [os.path.join(dp, f) for dp, dn, filenames in os.walk("playbooks") for f in filenames] with open('requirements.txt') as f: install_requires = f.read().strip().split('\n') with open('bench/__init__.py', 'rb') as f: + _version_re = re.compile(r'__version__\s+=\s+(.*)') version = str(ast.literal_eval(_version_re.search( f.read().decode('utf-8')).group(1))) @@ -21,6 +24,7 @@ setup( zip_safe=False, include_package_data=True, install_requires=install_requires, + package_data={ 'bench': playbooks_files }, entry_points=''' [console_scripts] bench=bench.cli:cli From 1ba8c463ded0b3d95e7a3b87e9df1cbeb826ddbc Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Fri, 1 May 2020 19:12:36 +0530 Subject: [PATCH 12/18] fix: updated manifest.in --- MANIFEST.in | 2 ++ setup.py | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index e84c5e61..f9ed1524 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,7 +1,9 @@ include *.md include *.py recursive-include bench *.conf +recursive-include bench *.sh recursive-include bench *.py recursive-include bench *.txt recursive-include bench *.json recursive-include bench/config/templates * +recursive-include bench/playbooks * diff --git a/setup.py b/setup.py index 5f23a676..7f056363 100644 --- a/setup.py +++ b/setup.py @@ -1,10 +1,8 @@ import ast -import os import re from setuptools import find_packages, setup -playbooks_files = [os.path.join(dp, f) for dp, dn, filenames in os.walk("playbooks") for f in filenames] with open('requirements.txt') as f: install_requires = f.read().strip().split('\n') @@ -24,7 +22,6 @@ setup( zip_safe=False, include_package_data=True, install_requires=install_requires, - package_data={ 'bench': playbooks_files }, entry_points=''' [console_scripts] bench=bench.cli:cli From 803fa2d6acf4b1b835825d14f5336822230591c9 Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Sat, 2 May 2020 20:07:16 +0530 Subject: [PATCH 13/18] fix: update easy install location --- .travis.yml | 6 +++--- README.md | 4 ++-- bench/playbooks/install.py => install.py | 0 vm/scripts/debian_family/install_erpnext_develop.sh | 2 +- vm/scripts/debian_family/install_erpnext_production.sh | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) rename bench/playbooks/install.py => install.py (100%) diff --git a/.travis.yml b/.travis.yml index 550aa53e..aa4416c6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -58,17 +58,17 @@ matrix: - name: "Python 3.6 Easy Install" python: 3.6 env: TEST=easy_install - script: sudo python $TRAVIS_BUILD_DIR/playbooks/install.py --user travis --run-travis --production --verbose + script: sudo python $TRAVIS_BUILD_DIR/install.py --user travis --run-travis --production --verbose - name: "Python 3.7 Easy Install" python: 3.7 env: TEST=easy_install - script: sudo python $TRAVIS_BUILD_DIR/playbooks/install.py --user travis --run-travis --production --verbose + script: sudo python $TRAVIS_BUILD_DIR/install.py --user travis --run-travis --production --verbose - name: "Python 3.8 Easy Install" python: 3.8 env: TEST=easy_install - script: sudo python $TRAVIS_BUILD_DIR/playbooks/install.py --user travis --run-travis --production --verbose + script: sudo python $TRAVIS_BUILD_DIR/install.py --user travis --run-travis --production --verbose install: - pip install urllib3 pyOpenSSL ndg-httpsclient pyasn1 diff --git a/README.md b/README.md index 8b6129ca..09ada8ec 100755 --- a/README.md +++ b/README.md @@ -132,7 +132,7 @@ You need to install the following packages for the script to run: Download the Easy Install script and execute it: ```sh -$ wget https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py +$ wget https://raw.githubusercontent.com/frappe/bench/master/install.py $ python3 install.py --production ``` @@ -142,7 +142,7 @@ When the setup is complete, you will be able to access the system at `http:// Date: Mon, 4 May 2020 16:03:17 +0530 Subject: [PATCH 14/18] fix: use easy_install of develop + path update --- README.md | 2 +- docs/easy_install.md | 2 +- vm/scripts/debian_family/install_erpnext_develop.sh | 2 +- vm/scripts/debian_family/install_erpnext_production.sh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 09ada8ec..9497802c 100755 --- a/README.md +++ b/README.md @@ -132,7 +132,7 @@ You need to install the following packages for the script to run: Download the Easy Install script and execute it: ```sh -$ wget https://raw.githubusercontent.com/frappe/bench/master/install.py +$ wget https://raw.githubusercontent.com/frappe/bench/develop/install.py $ python3 install.py --production ``` diff --git a/docs/easy_install.md b/docs/easy_install.md index 8caa7a30..7bf525d0 100644 --- a/docs/easy_install.md +++ b/docs/easy_install.md @@ -36,7 +36,7 @@ If you are on a fresh server and logged in as root, at first create a dedicated Switch to `[frappe-user]` (using `su [frappe-user]`) and start the setup - wget https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py + wget https://raw.githubusercontent.com/frappe/bench/develop/install.py #### 1. Run the install script diff --git a/vm/scripts/debian_family/install_erpnext_develop.sh b/vm/scripts/debian_family/install_erpnext_develop.sh index 6e87cc4d..19b1b705 100644 --- a/vm/scripts/debian_family/install_erpnext_develop.sh +++ b/vm/scripts/debian_family/install_erpnext_develop.sh @@ -1,5 +1,5 @@ #!/bin/bash -eux # Install ERPNext -wget https://raw.githubusercontent.com/frappe/bench/master/install.py +wget https://raw.githubusercontent.com/frappe/bench/develop/install.py python install.py --develop --user frappe --mysql-root-password frappe --admin-password admin \ No newline at end of file diff --git a/vm/scripts/debian_family/install_erpnext_production.sh b/vm/scripts/debian_family/install_erpnext_production.sh index 9dc2ecf2..b8493f1e 100644 --- a/vm/scripts/debian_family/install_erpnext_production.sh +++ b/vm/scripts/debian_family/install_erpnext_production.sh @@ -1,5 +1,5 @@ #!/bin/bash -eux # Install ERPNext -wget https://raw.githubusercontent.com/frappe/bench/master/install.py +wget https://raw.githubusercontent.com/frappe/bench/develop/install.py python install.py --production --user frappe --mysql-root-password frappe --admin-password admin \ No newline at end of file From 03e512fdab3c6b8240a4f290a554f72c686585f5 Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Mon, 4 May 2020 17:43:32 +0530 Subject: [PATCH 15/18] fix: get-app sets up node requirements --- bench/app.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bench/app.py b/bench/app.py index 48f8427e..d57fb9d3 100755 --- a/bench/app.py +++ b/bench/app.py @@ -177,8 +177,8 @@ def install_app(app, bench_path=".", verbose=False, no_cache=False, postprocess= app_path = os.path.join(bench_path, "apps", app) cache_flag = "--no-cache-dir" if no_cache else "" - exec_cmd("{pip} install {quiet} -U -e {app} {no_cache}".format(pip=pip_path, - quiet=quiet_flag, app=app_path, no_cache=cache_flag)) + exec_cmd("{pip} install {quiet} -U -e {app} {no_cache}".format(pip=pip_path, quiet=quiet_flag, app=app_path, no_cache=cache_flag)) + exec_cmd("yarn install", cwd=app_path) add_to_appstxt(app, bench_path=bench_path) if postprocess: From b3842d9b305da87d689bea379049beee3dd1cbbb Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Mon, 4 May 2020 17:44:46 +0530 Subject: [PATCH 16/18] fix: handle app not found under GH frappe erpnext orgs --- bench/app.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bench/app.py b/bench/app.py index d57fb9d3..7115ee32 100755 --- a/bench/app.py +++ b/bench/app.py @@ -111,6 +111,9 @@ def get_app(git_url, branch=None, bench_path='.', skip_assets=False, verbose=Fal if git_url == data['name']: git_url = 'https://github.com/{org}/{app}'.format(org=org, app=git_url) break + else: + bench.utils.log("App {app} not found".format(app=git_url), level=2) + sys.exit(1) # Gets repo name from URL repo_name = git_url.rsplit('/', 1)[1].rsplit('.', 1)[0] @@ -407,7 +410,7 @@ def switch_branch(branch, apps=None, bench_path='.', upgrade=False, check_upgrad if version_upgrade[0] and upgrade: update_requirements() update_node_packages() - reload_module(utils) + reload_module(bench.utils) backup_all_sites() patch_sites() build_assets() From 67fb0a4042d76eb8c988fba6b41b516fb22719e9 Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Wed, 6 May 2020 11:54:34 +0530 Subject: [PATCH 17/18] fix: install node modules if package.json exists --- bench/app.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bench/app.py b/bench/app.py index 7115ee32..8b165b2b 100755 --- a/bench/app.py +++ b/bench/app.py @@ -181,7 +181,10 @@ def install_app(app, bench_path=".", verbose=False, no_cache=False, postprocess= cache_flag = "--no-cache-dir" if no_cache else "" exec_cmd("{pip} install {quiet} -U -e {app} {no_cache}".format(pip=pip_path, quiet=quiet_flag, app=app_path, no_cache=cache_flag)) - exec_cmd("yarn install", cwd=app_path) + + if os.path.exists(os.path.join(app_path, 'package.json')): + exec_cmd("yarn install", cwd=app_path) + add_to_appstxt(app, bench_path=bench_path) if postprocess: From 5c7302caba74e4abfe2f2896359af75abec493f5 Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Wed, 6 May 2020 15:58:19 +0530 Subject: [PATCH 18/18] chore: remove unused imports --- setup.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/setup.py b/setup.py index 992c0d7c..055f0422 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,3 @@ -import ast -import re - from setuptools import find_packages, setup from bench import PROJECT_NAME, VERSION