mirror of
https://github.com/frappe/bench.git
synced 2024-11-11 15:51:03 +00:00
Merge branch 'master' into bench-update-exclude-app
This commit is contained in:
commit
85802a64a4
37
README.md
37
README.md
@ -1,3 +1,4 @@
|
||||
|
||||
<div align="center">
|
||||
<img src="https://github.com/frappe/design/blob/master/logos/bench-logo.svg" height="128">
|
||||
<h2>Frappe Bench</h2>
|
||||
@ -5,7 +6,7 @@
|
||||
|
||||
[![Build Status](https://travis-ci.org/frappe/bench.svg?branch=master)](https://travis-ci.org/frappe/bench)
|
||||
|
||||
The bench is a command-line utility that helps you to install apps, manage multiple sites and update Frappe / ERPNext apps on */nix (CentOS 6, Debian 7, Ubuntu, etc) for development and production. Bench will also create nginx and supervisor config files, setup backups and much more.
|
||||
The bench is a command-line utility that helps you to install apps, manage multiple sites and update Frappe / ERPNext apps on */nix (CentOS, Debian, Ubuntu, etc) for development and production. 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.
|
||||
|
||||
@ -15,19 +16,33 @@ If you have questions, please ask them on the [forum](https://discuss.erpnext.co
|
||||
|
||||
## Installation
|
||||
|
||||
## Manual Install
|
||||
### Installation Requirements
|
||||
|
||||
To manually install frappe/erpnext here are the steps
|
||||
You will need a computer/server. Options include:
|
||||
|
||||
- A Normal Computer/VPS/Baremetal Server: This is strongly recommended. Frappe/ERPNext installs properly and works well on these
|
||||
- A Raspberry Pi, SAN Appliance, Network Router, Gaming Console, etc.: Although you may be able to install Frappe/ERPNext on specialized hardware, it is unlikely to work well and will be difficult for us to support. Strongly consider using a normal computer/VPS/baremetal server instead. **We do not support specialized hardware**.
|
||||
- A Toaster, Car, Firearm, Thermostat, etc.: Yes, many modern devices now have embedded computing capability. We live in interesting times. However, you should not install Frappe/ERPNext on these devices. Instead, install it on a normal computer/VPS/baremetal server. **We do not support installing on noncomputing devices**.
|
||||
|
||||
To install the Frappe/ERPNext server software, you will need an operating system on your normal computer which is not Windows. Note that the command line interface does work on Windows, and you can use Frappe/ERPNext from any operating system with a web browser. However, the server software does not run on Windows. It does run on other operating systems, so choose one of these instead:
|
||||
|
||||
- Linux: Debian, Ubuntu, CentOS are the preferred distros and are well tested. [Arch Linux](https://github.com/frappe/bench/wiki/Install-ERPNext-on-ArchLinux) can also be used
|
||||
- Mac OS X
|
||||
|
||||
### Manual Install
|
||||
|
||||
To manually install frappe/erpnext, you can follow this [this wiki](https://github.com/frappe/frappe/wiki/The-Hitchhiker's-Guide-to-Installing-Frapp%C3%A9-on-Linux-OS) for Linux and [this wiki](https://github.com/frappe/frappe/wiki/The-Hitchhiker's-Guide-to-Installing-Frapp%C3%A9-on-Mac-OS-X) for MacOS. It gives an excellent explanation about the stack. You can also follow the steps mentioned below:
|
||||
|
||||
#### 1. Install Pre-requisites
|
||||
|
||||
- Python 2.7
|
||||
- Python 2.7 [Python3.5+ also supported, but not recommended for production]
|
||||
- MariaDB 10+
|
||||
- Nginx (for production)
|
||||
- Nodejs
|
||||
- yarn
|
||||
- Redis
|
||||
- cron (crontab is required)
|
||||
- wkhtmltopdf with patched Qt (for pdf generation)
|
||||
- wkhtmltopdf with patched Qt (version 0.12.3) (for pdf generation)
|
||||
|
||||
#### 2. Install Bench
|
||||
|
||||
@ -83,7 +98,7 @@ Note: Please do not remove the bench directory the above commands will create
|
||||
## Easy Install
|
||||
|
||||
- This is an opinionated setup so it is best to setup on a blank server.
|
||||
- Works on Ubuntu 14.04 to 16.04, CentOS 7+, Debian 7 to 8 and MacOS X.
|
||||
- Works on Ubuntu 16.04, CentOS 7+, Debian 8+
|
||||
- You may have to install Python 2.7 (eg on Ubuntu 16.04+) by running `apt-get install python-minimal`
|
||||
- You may also have to install build-essential and python-setuptools by running `apt-get install build-essential python-setuptools`
|
||||
- This script will install the pre-requisites, install bench and setup an ERPNext site
|
||||
@ -100,16 +115,6 @@ For Linux:
|
||||
|
||||
wget https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py
|
||||
|
||||
For Mac OSX:
|
||||
|
||||
Install X Code (from App store) and HomeBrew (http://brew.sh/) first
|
||||
|
||||
brew install python
|
||||
brew install git
|
||||
|
||||
Download the Script
|
||||
|
||||
curl "https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py" -o install.py
|
||||
|
||||
#### 2. Run the install script
|
||||
|
||||
|
@ -31,12 +31,11 @@ def bench_command(bench_path='.'):
|
||||
setup_logging(bench_path=bench_path)
|
||||
|
||||
|
||||
from bench.commands.make import init, get_app, new_app, remove_app, new_site
|
||||
from bench.commands.make import init, get_app, new_app, remove_app
|
||||
bench_command.add_command(init)
|
||||
bench_command.add_command(get_app)
|
||||
bench_command.add_command(new_app)
|
||||
bench_command.add_command(remove_app)
|
||||
bench_command.add_command(new_site)
|
||||
|
||||
|
||||
from bench.commands.update import update, retry_upgrade, switch_to_branch, switch_to_master, switch_to_develop
|
||||
|
@ -68,13 +68,3 @@ def include_app_for_update(app_name):
|
||||
"Include app from updating"
|
||||
from bench.app import remove_from_excluded_apps_txt
|
||||
remove_from_excluded_apps_txt(app_name)
|
||||
|
||||
|
||||
@click.command('new-site')
|
||||
@click.option('--mariadb-root-password', help="MariaDB root password")
|
||||
@click.option('--admin-password', help="admin password to set for site")
|
||||
@click.argument('site')
|
||||
def new_site(site, mariadb_root_password=None, admin_password=None):
|
||||
"Create a new site in the bench"
|
||||
from bench.utils import new_site
|
||||
new_site(site, mariadb_root_password=mariadb_root_password, admin_password=admin_password)
|
||||
|
@ -1,4 +1,6 @@
|
||||
from bench.utils import exec_cmd
|
||||
import click, sys, json
|
||||
import os
|
||||
|
||||
@click.group()
|
||||
def setup():
|
||||
@ -51,6 +53,12 @@ def setup_fonts():
|
||||
def setup_production(user, yes=False):
|
||||
"setup bench for production"
|
||||
from bench.config.production_setup import setup_production
|
||||
from bench.utils import run_playbook
|
||||
# Install prereqs for production
|
||||
exec_cmd("sudo pip install ansible")
|
||||
exec_cmd("bench setup role fail2ban")
|
||||
exec_cmd("bench setup role nginx")
|
||||
exec_cmd("bench setup role supervisor")
|
||||
setup_production(user=user, yes=yes)
|
||||
|
||||
|
||||
@ -146,6 +154,27 @@ def setup_node_requirements():
|
||||
from bench.utils import update_node_packages
|
||||
update_node_packages()
|
||||
|
||||
|
||||
@click.command('manager')
|
||||
def setup_manager():
|
||||
"Setup bench-manager.local site with the bench_manager app installed on it"
|
||||
from six.moves import input
|
||||
create_new_site = True
|
||||
if 'bench-manager.local' in os.listdir('sites'):
|
||||
ans = input('Site aleady exists. Overwrite existing new site? [Y/n]: ')
|
||||
while ans.lower() not in ['y', 'n', '']:
|
||||
ans = input('Please type "y" or "n". Site aleady exists. Overwrite existing new site? [Y/n]: ')
|
||||
if ans=='n': create_new_site = False
|
||||
if create_new_site: exec_cmd("bench new-site --force bench-manager.local")
|
||||
|
||||
if 'bench_manager' in os.listdir('apps'):
|
||||
print('App aleady exists. Skipping downloading the app')
|
||||
else:
|
||||
exec_cmd("bench get-app bench_manager")
|
||||
|
||||
exec_cmd("bench --site bench-manager.local install-app bench_manager")
|
||||
|
||||
|
||||
@click.command('config')
|
||||
def setup_config():
|
||||
"overwrite or make config.json"
|
||||
@ -239,6 +268,7 @@ setup.add_command(setup_env)
|
||||
setup.add_command(setup_procfile)
|
||||
setup.add_command(setup_socketio)
|
||||
setup.add_command(setup_requirements)
|
||||
setup.add_command(setup_manager)
|
||||
setup.add_command(setup_config)
|
||||
setup.add_command(setup_fonts)
|
||||
setup.add_command(add_domain)
|
||||
@ -247,4 +277,4 @@ setup.add_command(sync_domains)
|
||||
setup.add_command(setup_firewall)
|
||||
setup.add_command(set_ssh_port)
|
||||
setup.add_command(setup_roles)
|
||||
setup.add_command(setup_nginx_proxy_jail)
|
||||
setup.add_command(setup_nginx_proxy_jail)
|
||||
|
@ -56,7 +56,7 @@ def run_certbot_and_setup_ssl(site, custom_domain, bench_path):
|
||||
get_certbot()
|
||||
|
||||
try:
|
||||
exec_cmd("{path} --config /etc/letsencrypt/configs/{site}.cfg certonly".format(path=get_certbot_path(), site=custom_domain or site))
|
||||
exec_cmd("{path} -n --config /etc/letsencrypt/configs/{site}.cfg certonly".format(path=get_certbot_path(), site=custom_domain or site))
|
||||
except CommandFailedError:
|
||||
service('nginx', 'start')
|
||||
print("There was a problem trying to setup SSL for your site")
|
||||
|
@ -9,9 +9,9 @@ watch: bench watch
|
||||
{% endif %}
|
||||
{% if use_rq -%}
|
||||
schedule: bench schedule
|
||||
worker_short: bench worker --queue short
|
||||
worker_long: bench worker --queue long
|
||||
worker_default: bench worker --queue default
|
||||
worker_short: bench worker --queue short --quiet
|
||||
worker_long: bench worker --queue long --quiet
|
||||
worker_default: bench worker --queue default --quiet
|
||||
{% else %}
|
||||
workerbeat: sh -c 'cd sites && exec ../env/bin/python -m frappe.celery_app beat -s scheduler.schedule'
|
||||
worker: sh -c 'cd sites && exec ../env/bin/python -m frappe.celery_app worker -n jobs@%h -Ofair --soft-time-limit 360 --time-limit 390'
|
||||
|
@ -176,35 +176,6 @@ def setup_socketio(bench_path='.'):
|
||||
exec_cmd("npm install socket.io redis express superagent cookie babel-core less chokidar \
|
||||
babel-cli babel-preset-es2015 babel-preset-es2016 babel-preset-es2017 babel-preset-babili", cwd=bench_path)
|
||||
|
||||
def new_site(site, mariadb_root_password=None, admin_password=None, bench_path='.'):
|
||||
"""
|
||||
Creates a new site in the specified bench, default is current bench
|
||||
"""
|
||||
|
||||
logger.info('creating new site {}'.format(site))
|
||||
|
||||
# consider an existing passwords.txt file
|
||||
passwords_file_path = os.path.join(os.path.expanduser('~'), 'passwords.txt')
|
||||
if os.path.isfile(passwords_file_path):
|
||||
with open(passwords_file_path, 'r') as f:
|
||||
passwords = json.load(f)
|
||||
mariadb_root_password, admin_password = passwords['mysql_root_password'], passwords['admin_password']
|
||||
|
||||
mysql_root_password_fragment = '--root_password {}'.format(mariadb_root_password) if mariadb_root_password else ''
|
||||
admin_password_fragment = '--admin_password {}'.format(admin_password) if admin_password else ''
|
||||
|
||||
exec_cmd("{frappe} {site} --install {db_name} {mysql_root_password_fragment} {admin_password_fragment}".format(
|
||||
frappe=get_frappe(bench_path=bench_path),
|
||||
site=site,
|
||||
db_name=hashlib.sha1(site).hexdigest()[:10],
|
||||
mysql_root_password_fragment=mysql_root_password_fragment,
|
||||
admin_password_fragment=admin_password_fragment
|
||||
), cwd=os.path.join(bench_path, 'sites'))
|
||||
|
||||
if len(get_sites(bench_path=bench_path)) == 1:
|
||||
exec_cmd("{frappe} --use {site}".format(frappe=get_frappe(bench_path=bench_path), site=site), cwd=os.path.join(bench_path, 'sites'))
|
||||
|
||||
|
||||
def patch_sites(bench_path='.'):
|
||||
bench.set_frappe_version(bench_path=bench_path)
|
||||
|
||||
|
@ -1,483 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
|
||||
## Utils
|
||||
|
||||
print_msg() {
|
||||
echo "Frappe password: $FRAPPE_USER_PASS"
|
||||
echo "MariaDB root password: $MSQ_PASS"
|
||||
echo "Administrator password: $ADMIN_PASS"
|
||||
}
|
||||
|
||||
get_passwd() {
|
||||
echo `cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1`
|
||||
}
|
||||
|
||||
set_opts () {
|
||||
OPTS=`getopt -o v --long verbose,mysql-root-password:,frappe-user:,bench-branch:,setup-production,skip-install-bench,skip-setup-bench,help -n 'parse-options' -- "$@"`
|
||||
|
||||
if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi
|
||||
|
||||
eval set -- "$OPTS"
|
||||
|
||||
VERBOSE=false
|
||||
HELP=false
|
||||
FRAPPE_USER=false
|
||||
BENCH_BRANCH="master"
|
||||
SETUP_PROD=false
|
||||
INSTALL_BENCH=true
|
||||
SETUP_BENCH=true
|
||||
|
||||
if [ -f ~/frappe_passwords.sh ]; then
|
||||
source ~/frappe_passwords.sh
|
||||
else
|
||||
FRAPPE_USER_PASS=`get_passwd`
|
||||
MSQ_PASS=`get_passwd`
|
||||
ADMIN_PASS=`get_passwd`
|
||||
|
||||
echo "FRAPPE_USER_PASS=$FRAPPE_USER_PASS" > ~/frappe_passwords.sh
|
||||
echo "MSQ_PASS=$MSQ_PASS" >> ~/frappe_passwords.sh
|
||||
echo "ADMIN_PASS=$ADMIN_PASS" >> ~/frappe_passwords.sh
|
||||
fi
|
||||
|
||||
while true; do
|
||||
case "$1" in
|
||||
-v | --verbose ) VERBOSE=true; shift ;;
|
||||
-h | --help ) HELP=true; shift ;;
|
||||
--mysql-root-password ) MSQ_PASS="$2"; shift; shift ;;
|
||||
--frappe-user ) FRAPPE_USER="$2"; shift; shift ;;
|
||||
--setup-production ) SETUP_PROD=true; shift;;
|
||||
--bench-branch ) BENCH_BRANCH="$2"; shift;;
|
||||
--skip-setup-bench ) SETUP_BENCH=false; shift;;
|
||||
--skip-install-bench ) INSTALL_BENCH=false; shift;;
|
||||
-- ) shift; break ;;
|
||||
* ) break ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
get_distro() {
|
||||
ARCH=$(uname -m | sed 's/x86_/amd/;s/i[3-6]86/x86/')
|
||||
|
||||
if [ $ARCH == "amd64" ]; then
|
||||
T_ARCH="x86_64"
|
||||
WK_ARCH="amd64"
|
||||
else
|
||||
T_ARCH="i386"
|
||||
WK_ARCH="i386"
|
||||
fi
|
||||
|
||||
if [ -f /etc/redhat-release ]; then
|
||||
OS="centos"
|
||||
OS_VER=`cat /etc/redhat-release | sed 's/Linux\ //g' | cut -d" " -f3 | cut -d. -f1`
|
||||
|
||||
elif [ -f /etc/lsb-release ]; then
|
||||
. /etc/lsb-release
|
||||
OS=$DISTRIB_ID
|
||||
OS_VER=$DISTRIB_CODENAME
|
||||
|
||||
elif [ -f /etc/debian_version ]; then
|
||||
. /etc/os-release
|
||||
OS="debian" # XXX or Ubuntu??
|
||||
OS_VER=$VERSION_ID
|
||||
fi
|
||||
|
||||
export OS=$OS
|
||||
export OS_VER=$OS_VER
|
||||
export ARCH=$ARCH
|
||||
export T_ARCH=$T_ARCH
|
||||
export WK_ARCH=$WK_ARCH
|
||||
echo Installing for $OS $OS_VER $ARCH
|
||||
echo "In case you encounter an error, you can post on https://discuss.frappe.io"
|
||||
echo
|
||||
}
|
||||
|
||||
run_cmd() {
|
||||
if $VERBOSE; then
|
||||
"$@"
|
||||
else
|
||||
# $@
|
||||
"$@" > /tmp/cmdoutput.txt 2>&1 || (cat /tmp/cmdoutput.txt && exit 1)
|
||||
fi
|
||||
}
|
||||
|
||||
## add repos
|
||||
|
||||
add_centos6_mariadb_repo() {
|
||||
echo "
|
||||
[mariadb]
|
||||
name = MariaDB
|
||||
baseurl = http://yum.mariadb.org/10.0/centos$OS_VER-$ARCH
|
||||
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
|
||||
gpgcheck=1
|
||||
" > /etc/yum.repos.d/mariadb.repo
|
||||
}
|
||||
|
||||
|
||||
add_ubuntu_mariadb_repo() {
|
||||
run_cmd sudo apt-get update
|
||||
run_cmd sudo apt-get install -y software-properties-common python-software-properties
|
||||
run_cmd sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
|
||||
run_cmd sudo add-apt-repository "deb http://ams2.mirrors.digitalocean.com/mariadb/repo/10.0/ubuntu $OS_VER main"
|
||||
}
|
||||
|
||||
add_debian_mariadb_repo() {
|
||||
if [ $OS_VER == "7" ]; then
|
||||
CODENAME="wheezy"
|
||||
elif [ $OS_VER == "6" ]; then
|
||||
CODENAME="squeeze"
|
||||
elif [ $OS_VER == "8" ]; then
|
||||
CODENAME="jessie"
|
||||
else
|
||||
echo Unsupported Debian Version
|
||||
exit 1
|
||||
fi
|
||||
run_cmd sudo apt-get update
|
||||
run_cmd sudo apt-get install -y software-properties-common python-software-properties
|
||||
run_cmd sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
|
||||
$repo_test=$(apt-cache search --names-only 'mariadb-server')
|
||||
if [ -z "$repo_test" ]; then
|
||||
run_cmd sudo add-apt-repository "deb http://ams2.mirrors.digitalocean.com/mariadb/repo/10.0/debian $CODENAME main"
|
||||
fi
|
||||
}
|
||||
|
||||
add_ius_repo() {
|
||||
if [ $OS_VER -eq "6" ]; then
|
||||
wget http://dl.iuscommunity.org/pub/ius/stable/CentOS/$OS_VER/$T_ARCH/epel-release-6-5.noarch.rpm
|
||||
wget http://dl.iuscommunity.org/pub/ius/stable/CentOS/$OS_VER/$T_ARCH/ius-release-1.0-14.ius.centos6.noarch.rpm
|
||||
rpm --quiet -q epel-release || rpm -Uvh epel-release-6-5.noarch.rpm
|
||||
rpm --quiet -q ius-release || rpm -Uvh ius-release-1.0-14.ius.centos6.noarch.rpm
|
||||
fi
|
||||
}
|
||||
|
||||
add_epel_centos7() {
|
||||
yum install -y epel-release
|
||||
}
|
||||
|
||||
add_maria_db_repo() {
|
||||
if [ "$OS" == "Ubuntu" ] && [ $OS_VER == "utopic" ]; then
|
||||
return
|
||||
elif [ "$OS" == "centos" ]; then
|
||||
echo Adding centos mariadb repo
|
||||
add_centos6_mariadb_repo
|
||||
|
||||
elif [ "$OS" == "debian" ]; then
|
||||
echo Adding debian mariadb repo
|
||||
add_debian_mariadb_repo
|
||||
|
||||
elif [ "$OS" == "Ubuntu" ]; then
|
||||
echo Adding ubuntu mariadb repo
|
||||
add_ubuntu_mariadb_repo
|
||||
else
|
||||
echo Unsupported Distribution
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
## install
|
||||
|
||||
install_packages() {
|
||||
if [ $OS == "centos" ]; then
|
||||
run_cmd sudo yum install wget -y
|
||||
run_cmd sudo yum groupinstall -y "Development tools"
|
||||
if [ $OS_VER == "6" ]; then
|
||||
run_cmd add_ius_repo
|
||||
run_cmd sudo yum install -y git MariaDB-server MariaDB-client MariaDB-compat python-setuptools nginx \
|
||||
zlib-devel bzip2-devel openssl-devel postfix python27-devel python27 \
|
||||
libxml2 libxml2-devel libxslt libxslt-devel redis MariaDB-devel libXrender libXext \
|
||||
python27-setuptools cronie sudo which xorg-x11-fonts-Type1 xorg-x11-fonts-75dpi nodejs npm \
|
||||
libtiff-devel libjpeg-devel libzip-devel freetype-devel lcms2-devel libwebp-devel tcl-devel tk-devel
|
||||
elif [ $OS_VER == "7" ]; then
|
||||
run_cmd add_epel_centos7
|
||||
run_cmd sudo yum install -y git mariadb-server mariadb-devel python-setuptools nginx \
|
||||
zlib-devel bzip2-devel openssl-devel postfix python-devel \
|
||||
libxml2 libxml2-devel libxslt libxslt-devel redis libXrender libXext \
|
||||
supervisor cronie sudo which xorg-x11-fonts-75dpi xorg-x11-fonts-Type1 nodejs npm \
|
||||
libtiff-devel libjpeg-devel libzip-devel freetype-devel lcms2-devel libwebp-devel tcl-devel tk-devel
|
||||
fi
|
||||
|
||||
echo "Installing wkhtmltopdf"
|
||||
install_wkhtmltopdf_centos
|
||||
run_cmd easy_install-2.7 -U pip
|
||||
|
||||
|
||||
elif [ $OS == "debian" ] || [ $OS == "Ubuntu" ]; then
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
setup_debconf
|
||||
run_cmd bash -c "curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash -"
|
||||
run_cmd sudo apt-get update
|
||||
run_cmd sudo apt-get install -y python-dev python-setuptools build-essential python-mysqldb git \
|
||||
ntp vim screen htop mariadb-server mariadb-common libmariadbclient-dev \
|
||||
libxslt1.1 libxslt1-dev redis-server libssl-dev libcrypto++-dev postfix nginx \
|
||||
supervisor python-pip fontconfig libxrender1 libxext6 xfonts-75dpi xfonts-base nodejs
|
||||
|
||||
if [ $OS_VER == "precise" ]; then
|
||||
run_cmd sudo apt-get install -y libtiff4-dev libjpeg8-dev zlib1g-dev libfreetype6-dev \
|
||||
liblcms2-dev libwebp-dev tcl8.5-dev tk8.5-dev python-tk
|
||||
elif [ $OS_VER == "8" ]; then
|
||||
run_cmd sudo apt-get install -y libtiff5-dev libjpeg62-turbo-dev zlib1g-dev libfreetype6-dev \
|
||||
liblcms2-dev libwebp-dev tcl8.5-dev tk8.5-dev python-tk npm
|
||||
else
|
||||
run_cmd sudo apt-get install -y libtiff5-dev libjpeg8-dev zlib1g-dev libfreetype6-dev \
|
||||
liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python-tk
|
||||
fi
|
||||
|
||||
echo "Installing wkhtmltopdf"
|
||||
install_wkhtmltopdf_deb
|
||||
|
||||
else
|
||||
echo Unsupported Distribution
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
install_wkhtmltopdf_centos () {
|
||||
|
||||
if [[ $OS == "centos" && $OS_VER == "7" && $T_ARCH == "i386" ]]; then
|
||||
echo "Cannot install wkhtmltodpdf. Skipping..."
|
||||
return 0
|
||||
fi
|
||||
RPM="wkhtmltox-0.12.2.1_linux-$OS$OS_VER-$WK_ARCH.rpm"
|
||||
run_cmd wget http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/$RPM
|
||||
rpm --quiet -q wkhtmltox || run_cmd rpm -Uvh $RPM
|
||||
}
|
||||
|
||||
install_wkhtmltopdf_deb () {
|
||||
WK_VER=$OS_VER
|
||||
|
||||
if [[ $OS_VER == "utopic" || $OS_VER == "vivid" || $OS_VER == "wily" ]]; then
|
||||
echo "Installing wkhtmltox package for trusty (Ubuntu 14.4) even if you are using $OS_VER."
|
||||
WK_VER="trusty"
|
||||
fi
|
||||
if [[ $OS == "debian" && $OS_VER == "7" ]]; then
|
||||
WK_VER="wheezy"
|
||||
elif [[ $OS == "debian" && $OS_VER == "8" ]]; then
|
||||
WK_VER="jessie"
|
||||
fi
|
||||
|
||||
run_cmd wget http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-$WK_VER-$WK_ARCH.deb
|
||||
run_cmd dpkg -i wkhtmltox-0.12.2.1_linux-$WK_VER-$WK_ARCH.deb
|
||||
}
|
||||
|
||||
|
||||
install_supervisor_centos6() {
|
||||
run_cmd easy_install supervisor
|
||||
curl -Ss https://raw.githubusercontent.com/pdvyas/supervisor-initscripts/master/redhat-init-jkoppe > /etc/init.d/supervisord
|
||||
curl -Ss https://raw.githubusercontent.com/pdvyas/supervisor-initscripts/master/redhat-sysconfig-jkoppe > /etc/sysconfig/supervisord
|
||||
curl -Ss https://raw.githubusercontent.com/pdvyas/supervisor-initscripts/master/supervisord.conf > /etc/supervisord.conf
|
||||
run_cmd mkdir /etc/supervisor.d
|
||||
run_cmd chmod +x /etc/init.d/supervisord
|
||||
bash -c "service supervisord start || true"
|
||||
}
|
||||
|
||||
### config
|
||||
|
||||
get_mariadb_password() {
|
||||
get_password "MariaDB root" MSQ_PASS
|
||||
}
|
||||
|
||||
get_site_admin_password() {
|
||||
get_password "Admin password" ADMIN_PASS
|
||||
}
|
||||
|
||||
get_password() {
|
||||
if [ -z "$2" ]; then
|
||||
read -t 1 -n 10000 discard || true
|
||||
echo
|
||||
read -p "Enter $1 password to set:" -s TMP_PASS1
|
||||
echo
|
||||
read -p "Re enter $1 password to set:" -s TMP_PASS2
|
||||
echo
|
||||
if [ $TMP_PASS1 == $TMP_PASS2 ]; then
|
||||
export $2=$TMP_PASS1
|
||||
else
|
||||
echo Passwords do not match
|
||||
get_password $1 $2
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
configure_mariadb_centos() {
|
||||
# Required only for CentOS, Ubuntu and Debian will show dpkg configure screen to set the password
|
||||
if [ $OS == "centos" ]; then
|
||||
mysqladmin -u root password $MSQ_PASS
|
||||
fi
|
||||
}
|
||||
|
||||
start_services_centos6() {
|
||||
run_cmd service nginx start
|
||||
run_cmd service mysql start
|
||||
run_cmd service redis start
|
||||
}
|
||||
|
||||
configure_services_centos6() {
|
||||
run_cmd chkconfig --add supervisord
|
||||
run_cmd chkconfig redis on
|
||||
run_cmd chkconfig mysql on
|
||||
run_cmd chkconfig nginx on
|
||||
run_cmd chkconfig supervisord on
|
||||
}
|
||||
|
||||
configure_services_centos7() {
|
||||
run_cmd systemctl enable nginx
|
||||
run_cmd systemctl enable mysql
|
||||
run_cmd systemctl enable redis
|
||||
run_cmd systemctl enable supervisord
|
||||
}
|
||||
|
||||
start_services_centos7() {
|
||||
run_cmd systemctl start nginx
|
||||
run_cmd systemctl start mysql
|
||||
run_cmd systemctl start redis
|
||||
run_cmd systemctl start supervisord
|
||||
}
|
||||
|
||||
configure_mariadb() {
|
||||
config="
|
||||
[mysqld]
|
||||
innodb-file-format=barracuda
|
||||
innodb-file-per-table=1
|
||||
innodb-large-prefix=1
|
||||
character-set-client-handshake = FALSE
|
||||
character-set-server = utf8mb4
|
||||
collation-server = utf8mb4_unicode_ci
|
||||
|
||||
[mysql]
|
||||
default-character-set = utf8mb4
|
||||
"
|
||||
deb_cnf_path="/etc/mysql/conf.d/barracuda.cnf"
|
||||
centos_cnf_path="/etc/my.cnf.d/barracuda.cnf"
|
||||
|
||||
if [ $OS == "centos" ]; then
|
||||
|
||||
echo "$config" > $centos_cnf_path
|
||||
if [ $OS_VER == "6" ]; then
|
||||
run_cmd sudo service mysql restart
|
||||
elif [ $OS_VER == "7" ]; then
|
||||
run_cmd sudo systemctl restart mysql
|
||||
fi
|
||||
|
||||
elif [ $OS == "debian" ] || [ $OS == "Ubuntu" ]; then
|
||||
echo "$config" > $deb_cnf_path
|
||||
sudo service mysql restart
|
||||
fi
|
||||
}
|
||||
|
||||
setup_debconf() {
|
||||
debconf-set-selections <<< "postfix postfix/mailname string `hostname`"
|
||||
debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Internet Site'"
|
||||
debconf-set-selections <<< "mariadb-server-5.5 mysql-server/root_password password $MSQ_PASS"
|
||||
debconf-set-selections <<< "mariadb-server-5.5 mysql-server/root_password_again password $MSQ_PASS"
|
||||
}
|
||||
|
||||
install_bench() {
|
||||
run_cmd sudo su $FRAPPE_USER -c "cd /home/$FRAPPE_USER && git clone https://github.com/frappe/bench --branch $BENCH_BRANCH bench-repo"
|
||||
if hash pip-2.7 &> /dev/null; then
|
||||
PIP="pip-2.7"
|
||||
elif hash pip2.7 &> /dev/null; then
|
||||
PIP="pip2.7"
|
||||
elif hash pip2 &> /dev/null; then
|
||||
PIP="pip2"
|
||||
elif hash pip &> /dev/null; then
|
||||
PIP="pip"
|
||||
else
|
||||
echo PIP not installed
|
||||
exit 1
|
||||
fi
|
||||
|
||||
run_cmd sudo $PIP install --upgrade pip
|
||||
run_cmd sudo $PIP install -e /home/$FRAPPE_USER/bench-repo
|
||||
}
|
||||
|
||||
setup_bench() {
|
||||
echo Installing frappe-bench
|
||||
FRAPPE_BRANCH="develop"
|
||||
ERPNEXT_APPS_JSON="https://raw.githubusercontent.com/frappe/bench/master/install_scripts/erpnext-apps.json"
|
||||
if $SETUP_PROD; then
|
||||
FRAPPE_BRANCH="master"
|
||||
ERPNEXT_APPS_JSON="https://raw.githubusercontent.com/frappe/bench/master/install_scripts/erpnext-apps-master.json"
|
||||
fi
|
||||
|
||||
run_cmd sudo su $FRAPPE_USER -c "cd /home/$FRAPPE_USER && bench init frappe-bench --frappe-branch $FRAPPE_BRANCH --apps_path $ERPNEXT_APPS_JSON"
|
||||
echo Setting up first site
|
||||
echo /home/$FRAPPE_USER/frappe-bench > /etc/frappe_bench_dir
|
||||
run_cmd sudo su $FRAPPE_USER -c "cd /home/$FRAPPE_USER/frappe-bench && bench new-site site1.local --mariadb-root-password $MSQ_PASS --admin-password $ADMIN_PASS"
|
||||
run_cmd sudo su $FRAPPE_USER -c "cd /home/$FRAPPE_USER/frappe-bench && bench install-app erpnext"
|
||||
run_cmd bash -c "cd /home/$FRAPPE_USER/frappe-bench && bench setup sudoers $FRAPPE_USER"
|
||||
if $SETUP_PROD; then
|
||||
run_cmd bash -c "cd /home/$FRAPPE_USER/frappe-bench && bench setup production $FRAPPE_USER"
|
||||
fi
|
||||
chown $FRAPPE_USER /home/$FRAPPE_USER/frappe-bench/logs/*
|
||||
}
|
||||
|
||||
add_user() {
|
||||
# Check if script is running as root and is not running as sudo. We want to skip
|
||||
# this step if the user is already running this script with sudo as a non root
|
||||
# user
|
||||
if [ "$FRAPPE_USER" == "false" ]; then
|
||||
if [[ $SUDO_UID -eq 0 ]] && [[ $EUID -eq 0 ]]; then
|
||||
export FRAPPE_USER="frappe"
|
||||
else
|
||||
export FRAPPE_USER="$SUDO_USER"
|
||||
fi
|
||||
fi
|
||||
|
||||
USER_EXISTS=`bash -c "id $FRAPPE_USER > /dev/null 2>&1 && echo true || (echo false && exit 0)"`
|
||||
|
||||
if [ $USER_EXISTS == "false" ]; then
|
||||
useradd -m -d /home/$FRAPPE_USER -s $SHELL $FRAPPE_USER
|
||||
echo $FRAPPE_USER:$FRAPPE_USER_PASS | chpasswd
|
||||
chmod o+x /home/$FRAPPE_USER
|
||||
chmod o+r /home/$FRAPPE_USER
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
set_opts $@
|
||||
get_distro
|
||||
add_maria_db_repo
|
||||
echo Installing packages for $OS\. This might take time...
|
||||
install_packages
|
||||
if [ $OS == "centos" ]; then
|
||||
if [ $OS_VER == "6" ]; then
|
||||
echo "Installing supervisor"
|
||||
install_supervisor_centos6
|
||||
echo "Configuring CentOS services"
|
||||
configure_services_centos6
|
||||
echo "Starting services"
|
||||
start_services_centos6
|
||||
elif [ $OS_VER == "7" ]; then
|
||||
echo "Configuring CentOS services"
|
||||
configure_services_centos7
|
||||
echo "Starting services"
|
||||
start_services_centos7
|
||||
fi
|
||||
configure_mariadb_centos
|
||||
fi
|
||||
configure_mariadb
|
||||
echo "Adding frappe user"
|
||||
add_user
|
||||
|
||||
if $INSTALL_BENCH; then
|
||||
install_bench
|
||||
if $SETUP_BENCH; then
|
||||
setup_bench
|
||||
fi
|
||||
fi
|
||||
|
||||
echo
|
||||
RUNNING=""
|
||||
if $SETUP_PROD; then
|
||||
RUNNING=" and is running on port 80"
|
||||
fi
|
||||
echo "Frappe/ERPNext is installed successfully$RUNNING."
|
||||
print_msg > ~/frappe_passwords.txt
|
||||
print_msg
|
||||
echo
|
||||
echo "The passwords are also stored at ~/frappe_passwords.txt"
|
||||
echo "You can remove this file after making a note of the passwords."
|
||||
}
|
||||
|
||||
main $@
|
@ -5,16 +5,6 @@
|
||||
- Ubuntu 14.04, 16.04
|
||||
- CentOS 7
|
||||
|
||||
## Directory Structure
|
||||
TODO
|
||||
|
||||
## Notes for maintainers
|
||||
- For MariaDB playbooks refer https://github.com/PCextreme/ansible-role-mariadb
|
||||
- Any changes made in relation to a role should be dont inside the role and not outside it
|
||||
|
||||
# TODO:
|
||||
1. Planned Platform
|
||||
- Arch Linux
|
||||
- Fedora
|
||||
- RedHat
|
||||
2. Consider reffering to https://github.com/geerlingguy/ansible-role-mysql.git for MariaDB playbook
|
@ -33,4 +33,6 @@
|
||||
recurse: yes
|
||||
when: ansible_distribution == 'Ubuntu' or ansible_distribution == 'CentOS' or ansible_distribution == 'Debian'
|
||||
|
||||
- name: Change default shell to bash
|
||||
shell: "chsh {{ frappe_user }} -s $(which bash)"
|
||||
...
|
@ -59,7 +59,7 @@ def install_bench(args):
|
||||
})
|
||||
|
||||
success = run_os_command({
|
||||
'pip': "sudo pip install ansible==2.5.0"
|
||||
'pip': "sudo pip install ansible"
|
||||
})
|
||||
|
||||
if not success:
|
||||
@ -124,7 +124,7 @@ def install_bench(args):
|
||||
shutil.rmtree(tmp_bench_repo)
|
||||
|
||||
def check_distribution_compatibility():
|
||||
supported_dists = {'ubuntu': [14, 15, 16], 'debian': [7, 8, 9],
|
||||
supported_dists = {'ubuntu': [14, 15, 16], 'debian': [8, 9],
|
||||
'centos': [7], 'macos': [10.9, 10.10, 10.11, 10.12]}
|
||||
|
||||
dist_name, dist_version = get_distribution_info()
|
||||
@ -271,7 +271,7 @@ def get_passwords(args):
|
||||
mysql_root_password = getpass.unix_getpass(prompt='Please enter mysql root password: ')
|
||||
conf_mysql_passwd = getpass.unix_getpass(prompt='Re-enter mysql root password: ')
|
||||
|
||||
if mysql_root_password != conf_mysql_passwd:
|
||||
if mysql_root_password != conf_mysql_passwd or mysql_root_password == '':
|
||||
mysql_root_password = ''
|
||||
continue
|
||||
|
||||
@ -280,7 +280,7 @@ def get_passwords(args):
|
||||
admin_password = getpass.unix_getpass(prompt='Please enter the default Administrator user password: ')
|
||||
conf_admin_passswd = getpass.unix_getpass(prompt='Re-enter Administrator password: ')
|
||||
|
||||
if admin_password != conf_admin_passswd:
|
||||
if admin_password != conf_admin_passswd or admin_password == '':
|
||||
admin_password = ''
|
||||
continue
|
||||
|
||||
|
@ -63,7 +63,7 @@
|
||||
creates: "{{ bench_path }}/config/redis_socketio.conf"
|
||||
chdir: "{{ bench_path }}"
|
||||
|
||||
# Setup an ERPNext site called site1.local
|
||||
# Setup an ERPNext site
|
||||
- include_tasks: setup_erpnext.yml
|
||||
when: not run_travis
|
||||
|
||||
|
@ -10,18 +10,18 @@
|
||||
chdir: "{{ bench_path }}"
|
||||
when: not app.stat.exists
|
||||
|
||||
- name: Check whether a site called site1.local exists
|
||||
stat: path="{{ bench_path }}/sites/site1.local"
|
||||
- name: Check whether the site already exists
|
||||
stat: path="{{ bench_path }}/sites/{{ site }}"
|
||||
register: site_folder
|
||||
|
||||
- name: Create a new site
|
||||
command: bench new-site site1.local --admin-password {{ admin_password }} --mariadb-root-password {{ mysql_root_password }}
|
||||
command: "bench new-site {{ site }} --admin-password {{ admin_password }} --mariadb-root-password {{ mysql_root_password }}"
|
||||
args:
|
||||
chdir: "{{ bench_path }}"
|
||||
when: not site_folder.stat.exists
|
||||
|
||||
- name: Install ERPNext to default site
|
||||
command: bench --site site1.local install-app erpnext
|
||||
command: "bench --site {{ site }} install-app erpnext"
|
||||
args:
|
||||
chdir: "{{ bench_path }}"
|
||||
...
|
@ -5,7 +5,10 @@ innodb-large-prefix=1
|
||||
character-set-client-handshake = FALSE
|
||||
character-set-server = utf8mb4
|
||||
collation-server = utf8mb4_unicode_ci
|
||||
max_allowed_packet=64M
|
||||
max_allowed_packet=256M
|
||||
|
||||
[mysql]
|
||||
default-character-set = utf8mb4
|
||||
|
||||
[mysqldump]
|
||||
max_allowed_packet=256M
|
||||
|
@ -11,7 +11,7 @@ key-buffer-size = 32M
|
||||
myisam-recover = FORCE,BACKUP
|
||||
|
||||
# SAFETY #
|
||||
max-allowed-packet = 64M
|
||||
max-allowed-packet = 256M
|
||||
max-connect-errors = 1000000
|
||||
innodb = FORCE
|
||||
|
||||
@ -49,7 +49,7 @@ innodb-large-prefix = 1
|
||||
collation-server = utf8mb4_unicode_ci
|
||||
character-set-server = utf8mb4
|
||||
character-set-client-handshake = FALSE
|
||||
max_allowed_packet = 64M
|
||||
max_allowed_packet = 256M
|
||||
|
||||
# LOGGING #
|
||||
log-error = /var/lib/mysql/mysql-error.log
|
||||
@ -59,3 +59,6 @@ slow-query-log-file = /var/lib/mysql/mysql-slow.log
|
||||
|
||||
[mysql]
|
||||
default-character-set = utf8mb4
|
||||
|
||||
[mysqldump]
|
||||
max_allowed_packet=256M
|
20
playbooks/roles/nodejs/tasks/debian_family.yml
Normal file
20
playbooks/roles/nodejs/tasks/debian_family.yml
Normal file
@ -0,0 +1,20 @@
|
||||
---
|
||||
- name: Add apt key for node repo
|
||||
apt_key:
|
||||
url: https://keyserver.ubuntu.com/pks/lookup?op=get&fingerprint=on&search=0x1655A0AB68576280
|
||||
id: "68576280"
|
||||
state: present
|
||||
|
||||
- name: Add repo
|
||||
apt_repository:
|
||||
repo: "deb [arch=amd64,i386] https://deb.nodesource.com/node_8.x {{ ansible_distribution_release }} main"
|
||||
state: present
|
||||
register: node_repo
|
||||
|
||||
- name: Install nodejs 8.x
|
||||
apt:
|
||||
name: nodejs
|
||||
state: present
|
||||
update_cache: yes
|
||||
force: yes
|
||||
...
|
@ -1,44 +1,14 @@
|
||||
---
|
||||
- name: Import Node source RPM key
|
||||
rpm_key:
|
||||
key: https://rpm.nodesource.com/pub/el/NODESOURCE-GPG-SIGNING-KEY-EL
|
||||
state: present
|
||||
when: ansible_os_family == 'RedHat'
|
||||
# Install's prerequisites, like fonts, image libraries, vim, screen, python-dev and gcc
|
||||
|
||||
- name: Add Node Repo for RedHat
|
||||
yum:
|
||||
name: 'https://rpm.nodesource.com/pub_6.x/el/{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/nodesource-release-el{{ ansible_distribution_major_version }}-1.noarch.rpm'
|
||||
state: present
|
||||
update_cache: yes
|
||||
when: ansible_os_family == 'RedHat'
|
||||
- include_tasks: debian_family.yml
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
- name: Install node v6
|
||||
yum: name=nodejs state=present
|
||||
when: ansible_os_family == 'RedHat'
|
||||
|
||||
- name: Add apt key for node repo
|
||||
apt_key:
|
||||
url: https://keyserver.ubuntu.com/pks/lookup?op=get&fingerprint=on&search=0x1655A0AB68576280
|
||||
id: "68576280"
|
||||
state: present
|
||||
when: ansible_os_family == 'Debian' or ansible_distribution == 'Ubuntu'
|
||||
|
||||
- name: Add repo
|
||||
apt_repository:
|
||||
repo: "deb [arch=amd64,i386] https://deb.nodesource.com/node_6.x {{ ansible_distribution_release }} main"
|
||||
state: present
|
||||
register: node_repo
|
||||
when: ansible_os_family == 'Debian' or ansible_distribution == 'Ubuntu'
|
||||
|
||||
- name: Install nodejs 6.x
|
||||
apt:
|
||||
name: nodejs
|
||||
state: present
|
||||
update_cache: yes
|
||||
force: yes
|
||||
when: ansible_os_family == 'Debian' or ansible_distribution == 'Ubuntu'
|
||||
- include_tasks: redhat_family.yml
|
||||
when: ansible_os_family == "RedHat"
|
||||
|
||||
- name: Install yarn
|
||||
command: npm install -g yarn
|
||||
become: yes
|
||||
become_user: root
|
||||
become_user: root
|
||||
...
|
18
playbooks/roles/nodejs/tasks/redhat_family.yml
Normal file
18
playbooks/roles/nodejs/tasks/redhat_family.yml
Normal file
@ -0,0 +1,18 @@
|
||||
---
|
||||
- name: Import Node source RPM key
|
||||
rpm_key:
|
||||
key: https://rpm.nodesource.com/pub/el/NODESOURCE-GPG-SIGNING-KEY-EL
|
||||
state: present
|
||||
when: ansible_os_family == 'RedHat'
|
||||
|
||||
- name: Add Node Repo for RedHat
|
||||
yum:
|
||||
name: 'https://rpm.nodesource.com/pub_8.x/el/{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/nodesource-release-el{{ ansible_distribution_major_version }}-1.noarch.rpm'
|
||||
state: present
|
||||
update_cache: yes
|
||||
when: ansible_os_family == 'RedHat'
|
||||
|
||||
- name: Install node v8
|
||||
yum: name=nodejs state=present
|
||||
when: ansible_os_family == 'RedHat'
|
||||
...
|
@ -17,6 +17,8 @@
|
||||
- xfonts-base
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
# wkhtmltopdf has been locked down to 0.12.3 intentionally since 0.12.4 has problems.
|
||||
# I you want to upgrade try it on multiple platforms and then decide
|
||||
- name: download wkthmltox linux
|
||||
get_url: url=https://github.com/frappe/wkhtmltopdf/raw/master/wkhtmltox-0.12.3_linux-generic-{{ "amd64" if ansible_architecture == "x86_64" else "i386"}}.tar.xz dest=/tmp/wkhtmltox.tar.xz
|
||||
|
||||
|
@ -5,22 +5,22 @@
|
||||
become: yes
|
||||
become_user: root
|
||||
roles:
|
||||
- { role: common, tags: "common" }
|
||||
- { role: locale, tags: "locale" }
|
||||
- { role: swap, tags: "swap", when: production }
|
||||
- { role: logwatch, tags: "logwatch", when: production }
|
||||
- { role: bash_screen_wall, tags: "bash_screen_wall", when: production }
|
||||
- { role: frappe_selinux, tags: "frappe_selinux", when: production }
|
||||
- { role: dns_caching, tags: "dns_caching", when: production }
|
||||
- { role: ntpd, tags: "ntpd", when: production }
|
||||
- { role: mariadb, tags: "mariadb" }
|
||||
- { role: wkhtmltopdf, tags: "wkhtmltopdf" }
|
||||
- { role: nodejs, tags: "nodejs" }
|
||||
- { role: psutil, tags: "psutil" }
|
||||
- { role: redis, tags: "redis" }
|
||||
- { role: supervisor, tags: "supervisor", when: production }
|
||||
- { role: nginx, tags: "nginx", when: production }
|
||||
- { role: fail2ban, tags: "fail2ban", when: production }
|
||||
- { role: common, tags: common }
|
||||
- { role: locale, tags: locale }
|
||||
- { role: swap, tags: swap, when: production }
|
||||
- { role: logwatch, tags: logwatch, when: production }
|
||||
- { role: bash_screen_wall, tags: bash_screen_wall, when: production }
|
||||
- { role: frappe_selinux, tags: frappe_selinux, when: production }
|
||||
- { role: dns_caching, tags: dns_caching, when: production }
|
||||
- { role: ntpd, tags: ntpd, when: production }
|
||||
- { role: mariadb, tags: mariadb }
|
||||
- { role: wkhtmltopdf, tags: wkhtmltopdf }
|
||||
- { role: nodejs, tags: nodejs }
|
||||
- { role: psutil, tags: psutil }
|
||||
- { role: redis, tags: redis }
|
||||
- { role: supervisor, tags: supervisor, when: production }
|
||||
- { role: nginx, tags: nginx, when: production }
|
||||
- { role: fail2ban, tags: fail2ban, when: production }
|
||||
tasks:
|
||||
- name: Set hostname
|
||||
hostname: name='{{ hostname }}'
|
||||
|
26
vm/Readme.md
26
vm/Readme.md
@ -1,18 +1,18 @@
|
||||
### ERPNext VM Builder
|
||||
## ERPNext VM Builder
|
||||
|
||||
|
||||
#### Steps to build a VM Image
|
||||
### Steps to build a VM Image
|
||||
|
||||
* `python build.py` builds a new VM
|
||||
* `python build.py` builds a new Production VM, a Dev VM and a Dev Vagrant Box
|
||||
|
||||
|
||||
#### Requirements
|
||||
### Requirements
|
||||
|
||||
* Bench should be installed.
|
||||
* Bench should be installed
|
||||
* Ansible should be installed
|
||||
|
||||
|
||||
#### How it works
|
||||
### How it works
|
||||
|
||||
Apart from the above the rest is handled by bench:
|
||||
|
||||
@ -21,23 +21,17 @@ Apart from the above the rest is handled by bench:
|
||||
- packer
|
||||
* Cleanup
|
||||
- Clean the required directories
|
||||
* Generate the erpnext_develop.json and the erpnext_production.json
|
||||
- Figure out the latest ubuntu iso available, get it's link and the checksum and generate the json files
|
||||
* Build the VM using packer
|
||||
- Packer downloads the mentioned Ubuntu iso, boots a virtual machine and preceeds the preseed.cfg file into it in order to setup a clean Ubuntu OS
|
||||
- Then packer uses ssh to enter the virtual machine to execute the required commands
|
||||
- `scripts/debian_family/install_ansible.sh` sets up ansible on the vm.
|
||||
- Depending on the VM being built, the `install_erpnext_develop.sh` or the `install_erpnext_production.sh` is executed
|
||||
- Depending on the VM being built, the `vm-develop.json` or the `vm-production.json` is used
|
||||
- `scripts/set_message.sh` sets welcome message (with update instructions) in the vm.
|
||||
- `scripts/cleanup.sh` writes zero to all the free space in the disk, it shrinks the disk image
|
||||
- `scripts/cleanup.sh` writes zeros to all the free space in the disk, it shrinks the disk image
|
||||
* Set the correct permissions for the built Vagrant and Virtual Appliance Images
|
||||
* Cleanup
|
||||
- Delete the generated files from the required directories
|
||||
* restart nginx
|
||||
|
||||
The requirements for this to run are Packer and Virtualbox. imports the base image in a virtual machine and boots it. It runs the following
|
||||
* Restart nginx
|
||||
|
||||
|
||||
#### For a build server
|
||||
|
||||
Running the `build.py` script builds a vm and puts it in `~/public`. It also writes a `latest.json` file in `~/public` with filename of the latest build and its md5sum.
|
||||
Running the `build.py` script builds the VMs and puts them in `~/Public`. It also creates the md5 hashes for the same, and puts them in the same folder.
|
||||
|
Loading…
Reference in New Issue
Block a user