2
0
mirror of https://github.com/frappe/bench.git synced 2025-01-06 23:44:03 +00:00

Merge branch 'master' into trav_fix

This commit is contained in:
Ameya Shenoy 2018-07-03 14:34:02 +05:30 committed by GitHub
commit a5de7d4af6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
54 changed files with 749 additions and 141 deletions

68
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@ -0,0 +1,68 @@
---
name: Bug report
about: Create a report to help us improve
---
Issue: Bug report
Our project, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.
**Do the checklist before filing an issue:**
- [ ] Have a usage question? Ask your question on [Discuss Forum](https://discuss.erpnext.com). We use [Discuss Forum](https://discuss.erpnext.com) for usage question and GitHub for bugs.
- [ ] Can you replicate the issue?
- [ ] Is this something you can debug and fix? Send a pull request! Bug fixes and documentation fixes are welcome
**Describe the bug** :chart_with_downwards_trend:
A clear and concise description of what the bug is.
**To Reproduce** :page_with_curl:
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior** :chart_with_upwards_trend:
A clear and concise description of what you expected to happen.
**Screenshots** :crystal_ball:
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):** :cyclone:
- OS:
- [ ] Linux
- [ ] macOS
- [ ] Windows
- [ ] Others? Please mention:
- Browser:
- [ ] Safari
- [ ] Chrome
- [ ] Firefox
- [ ] Other? Please mention:
**Smartphone (please complete the following information):** :iphone: :computer:
- Device:
- [ ] iPhone
- [ ] Android
- Browser:
- [ ] Safari
- [ ] Chrome
- [ ] Firefox
- [ ] Other? Please mention:
**Version Information**
- Which branch are you on?
- [ ] `master` :star2:
- [ ] `develop` :fire:
- Frappe Version:
- ERPNext Version:
**Additional context** :page_facing_up:
Add any other context about the problem here.
**Possible Solution** :bookmark_tabs:
Any idea what might be causing the issue. Or if you have a proposed solution to the problem,
**Please don't be intimidated by the long list of options you've fill. Try to fill out as much as you can. Remember, the more the information the easier it is for us to replicate and fix the issue** :grin:

View File

@ -0,0 +1,21 @@
---
name: Feature request
about: Suggest an idea for this project
---
Issue: Feature Request
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

28
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@ -0,0 +1,28 @@
Pull-Request
- [ ] Have you followed the guidelines in our Contributing document?
- [ ] Have you checked to ensure there aren't other open [Pull Requests](../pulls) for the same update/change?
- [ ] Have you lint your code locally prior to submission?
- [ ] Have you successfully run tests with your changes locally?
- [ ] Does your commit message have an explanation for your changes and why you'd like us to include them?
- [ ] Docs have been added / updated
- [ ] Tests for the changes have been added (for bug fixes / features)
- [ ] Did you modify the existing test cases? If yes, why?
---
What type of a PR is this?
- [ ] Changes to Existing Features
- [ ] New Feature Submissions
- [ ] Bug Fix
- [ ] Breaking Change
---
- Motivation and Context (What existing problem does the pull request solve):
- Related Issue:
- Screenshots (if applicable, remember, a picture tells a thousand words):
**Please don't be intimidated by the long list of options you've fill. Try to fill out as much as you can. Remember, the more the information the easier it is for us to test and get your pull request merged** :grin:

View File

@ -1,6 +1,5 @@
language: python
dist: trusty
sudo: required
python:
- "2.7"

View File

@ -4,4 +4,4 @@ recursive-include bench *.conf
recursive-include bench *.py
recursive-include bench *.txt
recursive-include bench *.json
recursive-include bench/templates *
recursive-include bench/config/templates *

View File

@ -144,6 +144,22 @@ For production:
---
## Bench Manger (GUI for Bench)
Bench Manager is a graphical user interface to emulate the functionalities of Frappé Bench. Like the command line utility it helps you install apps, manage multiple sites, update apps and much more.
### Installation
```
$ bench setup manager
```
What all it does:
1. Create new site bench-manager.local
2. Gets the `bench_manager` app from https://github.com/frappe/bench_manager if it doesn't exist already
3. Installs the bench_manager app on the site bench-manager.local
## Docker Install - For Developers (beta)
1. For developer setup, you can also use the official [Frappé Docker](https://github.com/frappe/frappe_docker/).

View File

@ -1,6 +1,7 @@
import os
from .utils import (exec_cmd, get_frappe, check_git_for_shallow_clone, build_assets,
restart_supervisor_processes, get_cmd_output, run_frappe_cmd, CommandFailedError)
restart_supervisor_processes, get_cmd_output, run_frappe_cmd, CommandFailedError,
restart_systemd_processes)
from .config.common_site_config import get_config
import logging
@ -74,7 +75,7 @@ def add_to_excluded_apps_txt(app, bench_path='.'):
if app == 'frappe':
raise ValueError('Frappe app cannot be excludeed from update')
if app not in os.listdir('apps'):
raise ValueError('The app {} does not exist'.format(app))
raise ValueError('The app {} does not exist'.format(app))
apps = get_excluded_apps(bench_path=bench_path)
if app not in apps:
apps.append(app)
@ -90,7 +91,8 @@ def remove_from_excluded_apps_txt(app, bench_path='.'):
apps.remove(app)
return write_excluded_apps_txt(apps, bench_path=bench_path)
def get_app(git_url, branch=None, bench_path='.', build_asset_files=True, verbose=False):
def get_app(git_url, branch=None, bench_path='.', build_asset_files=True, verbose=False,
postprocess = True):
# from bench.utils import check_url
try:
from urlparse import urljoin
@ -132,11 +134,24 @@ def get_app(git_url, branch=None, bench_path='.', build_asset_files=True, verbos
print('installing', app_name)
install_app(app=app_name, bench_path=bench_path, verbose=verbose)
if build_asset_files:
build_assets(bench_path=bench_path)
conf = get_config(bench_path=bench_path)
if conf.get('restart_supervisor_on_update'):
restart_supervisor_processes(bench_path=bench_path)
if postprocess:
# get apps for docs
if repo_name=='frappe':
get_app('https://github.com/frappe/frappe_io', bench_path = bench_path,
branch= 'master', postprocess = False)
if repo_name=='erpnext':
get_app('https://github.com/erpnext/foundation', bench_path = bench_path,
branch= 'master', postprocess = False)
if build_asset_files:
build_assets(bench_path=bench_path)
conf = get_config(bench_path=bench_path)
if conf.get('restart_supervisor_on_update'):
restart_supervisor_processes(bench_path=bench_path)
if conf.get('restart_systemd_on_update'):
restart_systemd_processes(bench_path=bench_path)
def new_app(app, bench_path='.'):
# For backwards compatibility
@ -187,7 +202,8 @@ def remove_app(app, bench_path='.'):
run_frappe_cmd("build", bench_path=bench_path)
if get_config(bench_path).get('restart_supervisor_on_update'):
restart_supervisor_processes(bench_path=bench_path)
if get_config(bench_path).get('restart_systemd_on_update'):
restart_systemd_processes(bench_path=bench_path)
def pull_all_apps(bench_path='.', reset=False):
'''Check all apps if there no local changes, pull'''
@ -218,14 +234,19 @@ Here are your choices:
wait for them to be merged in the core.'''.format(app))
sys.exit(1)
excluded_apps = get_excluded_apps()
for app in get_apps(bench_path=bench_path):
excluded_apps = get_excluded_apps()
if app in excluded_apps:
print("Skipping pull for app {}".format(app))
continue
app_dir = get_repo_dir(app, bench_path=bench_path)
if os.path.exists(os.path.join(app_dir, '.git')):
remote = get_remote(app)
if not remote:
# remote is False, i.e. remote doesn't exist, add the app to excluded_apps.txt
add_to_excluded_apps_txt(app, bench_path=bench_path)
print("Skipping pull for app {}, since remote doesn't exist, and adding it to excluded apps".format(app))
continue
logger.info('pulling {0}'.format(app))
if reset:
exec_cmd("git fetch --all", cwd=app_dir)
@ -272,12 +293,13 @@ def get_remote(app, bench_path='.'):
stderr=subprocess.STDOUT)
contents = contents.decode('utf-8')
if re.findall('upstream[\s]+', contents):
remote = 'upstream'
return 'upstream'
elif not contents:
# if contents is an empty string => remote doesn't exist
return False
else:
# get the first remote
remote = contents.splitlines()[0].split()[0]
return remote
return contents.splitlines()[0].split()[0]
def use_rq(bench_path):
bench_path = os.path.abspath(bench_path)

View File

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

View File

@ -23,6 +23,12 @@ def config_restart_supervisor_on_update(state):
state = True if state == 'on' else False
update_config({'restart_supervisor_on_update': state})
@click.command('restart_systemd_on_update')
@click.argument('state', type=click.Choice(['on', 'off']))
def config_restart_systemd_on_update(state):
"Enable/Disable auto restart of systemd units"
state = True if state == 'on' else False
update_config({'restart_systemd_on_update': state})
@click.command('update_bench_on_update')
@click.argument('state', type=click.Choice(['on', 'off']))
@ -112,6 +118,7 @@ def remove_common_config(keys):
config.add_command(config_auto_update)
config.add_command(config_update_bench_on_update)
config.add_command(config_restart_supervisor_on_update)
config.add_command(config_restart_systemd_on_update)
config.add_command(config_dns_multitenant)
config.add_command(config_serve_default_site)
config.add_command(config_http_timeout)

View File

@ -128,6 +128,16 @@ def setup_letsencrypt(site, custom_domain, non_interactive):
setup_letsencrypt(site, custom_domain, bench_path='.', interactive=not non_interactive)
@click.command('wildcard-ssl')
@click.argument('domain')
@click.option('--email')
@click.option('--exclude-base-domain', default=False, is_flag=True, help="SSL Certificate not applicable for base domain")
def setup_wildcard_ssl(domain, email, exclude_base_domain):
''' Setup wildcard ssl certificate '''
from bench.config.lets_encrypt import setup_wildcard_ssl
setup_wildcard_ssl(domain, email, bench_path='.', exclude_base_domain=exclude_base_domain)
@click.command('procfile')
def setup_procfile():
"Setup Procfile for bench start"
@ -261,12 +271,25 @@ def setup_nginx_proxy_jail(**kwargs):
from bench.utils import run_playbook
run_playbook('roles/fail2ban/tasks/configure_nginx_jail.yml', extra_vars=kwargs)
@click.command('systemd')
@click.option('--user')
@click.option('--yes', help='Yes to regeneration of systemd config files', is_flag=True, default=False)
@click.option('--stop', help='Stop bench services', is_flag=True, default=False)
@click.option('--create-symlinks', help='Create Symlinks', is_flag=True, default=False)
@click.option('--delete-symlinks', help='Delete Symlinks', is_flag=True, default=False)
def setup_systemd(user=None, yes=False, stop=False, create_symlinks=False, delete_symlinks=False):
"generate configs for systemd with an optional user argument"
from bench.config.systemd import generate_systemd_config
generate_systemd_config(bench_path=".", user=user, yes=yes,
stop=stop, create_symlinks=create_symlinks, delete_symlinks=delete_symlinks)
setup.add_command(setup_sudoers)
setup.add_command(setup_nginx)
setup.add_command(reload_nginx)
setup.add_command(setup_supervisor)
setup.add_command(setup_redis)
setup.add_command(setup_letsencrypt)
setup.add_command(setup_wildcard_ssl)
setup.add_command(setup_production)
setup.add_command(setup_auto_update)
setup.add_command(setup_backups)
@ -284,3 +307,4 @@ 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_systemd)

View File

@ -3,7 +3,8 @@ import sys, os
from bench.config.common_site_config import get_config
from bench.app import pull_all_apps, is_version_upgrade
from bench.utils import (update_bench, validate_upgrade, pre_upgrade, post_upgrade, before_update,
update_requirements, update_node_packages, backup_all_sites, patch_sites, build_assets, restart_supervisor_processes)
update_requirements, update_node_packages, backup_all_sites, patch_sites, build_assets,
restart_supervisor_processes, restart_systemd_processes)
from bench import patches
@ -14,11 +15,12 @@ from bench import patches
@click.option('--bench', is_flag=True, help="Update bench")
@click.option('--requirements', is_flag=True, help="Update requirements")
@click.option('--restart-supervisor', is_flag=True, help="restart supervisor processes after update")
@click.option('--restart-systemd', is_flag=True, help="restart systemd units after update")
@click.option('--auto', is_flag=True)
@click.option('--no-backup', is_flag=True)
@click.option('--force', is_flag=True)
@click.option('--reset', is_flag=True, help="Hard resets git branch's to their new states overriding any changes and overriding rebase on pull")
def update(pull=False, patch=False, build=False, bench=False, auto=False, restart_supervisor=False, requirements=False, no_backup=False, force=False, reset=False):
def update(pull=False, patch=False, build=False, bench=False, auto=False, restart_supervisor=False, restart_systemd=False, requirements=False, no_backup=False, force=False, reset=False):
"Update bench"
if not (pull or patch or build or bench or requirements):
@ -55,10 +57,10 @@ def update(pull=False, patch=False, build=False, bench=False, auto=False, restar
print("This would take significant time to migrate and might break custom apps.")
click.confirm('Do you want to continue?', abort=True)
_update(pull, patch, build, bench, auto, restart_supervisor, requirements, no_backup, force=force, reset=reset)
_update(pull, patch, build, bench, auto, restart_supervisor, restart_systemd, requirements, no_backup, force=force, reset=reset)
def _update(pull=False, patch=False, build=False, update_bench=False, auto=False, restart_supervisor=False,
requirements=False, no_backup=False, bench_path='.', force=False, reset=False):
restart_systemd=False, requirements=False, no_backup=False, bench_path='.', force=False, reset=False):
conf = get_config(bench_path=bench_path)
version_upgrade = is_version_upgrade(bench_path=bench_path)
@ -94,6 +96,8 @@ def _update(pull=False, patch=False, build=False, update_bench=False, auto=False
post_upgrade(version_upgrade[1], version_upgrade[2], bench_path=bench_path)
if restart_supervisor or conf.get('restart_supervisor_on_update'):
restart_supervisor_processes(bench_path=bench_path)
if restart_systemd or conf.get('restart_systemd_on_update'):
restart_systemd_processes(bench_path=bench_path)
print("_"*80)
print("Bench: Deployment tool for Frappe and ERPNext (https://erpnext.org).")

View File

@ -13,11 +13,16 @@ def start(no_dev, concurrency):
@click.command('restart')
@click.option('--web', is_flag=True, default=False)
def restart(web):
"Restart supervisor processes"
from bench.utils import restart_supervisor_processes
restart_supervisor_processes(bench_path='.', web_workers=web)
@click.option('--supervisor', is_flag=True, default=False)
@click.option('--systemd', is_flag=True, default=False)
def restart(web, supervisor, systemd):
"Restart supervisor processes or systemd units"
from bench.utils import restart_supervisor_processes, restart_systemd_processes
from bench.config.common_site_config import get_config
if get_config('.').get('restart_supervisor_on_update') or supervisor:
restart_supervisor_processes(bench_path='.', web_workers=web)
if get_config('.').get('restart_systemd_on_update') or systemd:
restart_systemd_processes(bench_path='.', web_workers=web)
@click.command('set-nginx-port')
@click.argument('site')

View File

@ -7,6 +7,7 @@ except ImportError:
default_config = {
'restart_supervisor_on_update': False,
'restart_systemd_on_update': False,
'auto_update': False,
'serve_default_site': True,
'rebase_on_pull': False,

View File

@ -1,5 +1,5 @@
import bench, os, click, errno
from bench.utils import exec_cmd, CommandFailedError
from bench.utils import exec_cmd, CommandFailedError, update_common_site_config
from bench.config.site_config import update_site_config, remove_domain, get_domains
from bench.config.nginx import make_nginx_conf
from bench.config.production_setup import service
@ -116,3 +116,59 @@ def renew_certs():
service('nginx', 'stop')
exec_cmd("{path} renew".format(path=get_certbot_path()))
service('nginx', 'start')
def setup_wildcard_ssl(domain, email, bench_path, exclude_base_domain):
def _get_domains(domain):
domain_list = [domain]
if not domain.startswith('*.'):
# add wildcard caracter to domain if missing
domain_list.append('*.{0}'.format(domain))
else:
# include base domain based on flag
domain_list.append(domain.replace('*.', ''))
if exclude_base_domain:
domain_list.remove(domain.replace('*.', ''))
return domain_list
if not get_config(bench_path).get("dns_multitenant"):
print("You cannot setup SSL without DNS Multitenancy")
return
get_certbot()
domain_list = _get_domains(domain.strip())
email_param = ''
if email:
email_param = '--email {0}'.format(email)
try:
exec_cmd("{path} certonly --manual --preferred-challenges=dns {email_param} \
--server https://acme-v02.api.letsencrypt.org/directory \
--agree-tos -d {domain}".format(path=get_certbot_path(), domain=' -d '.join(domain_list),
email_param=email_param))
except CommandFailedError:
print("There was a problem trying to setup SSL")
return
ssl_path = "/etc/letsencrypt/live/{domain}/".format(domain=domain)
ssl_config = {
"wildcard": {
"domain": domain,
"ssl_certificate": os.path.join(ssl_path, "fullchain.pem"),
"ssl_certificate_key": os.path.join(ssl_path, "privkey.pem")
}
}
update_common_site_config(ssl_config)
setup_crontab()
make_nginx_conf(bench_path)
print("Restrting Nginx service")
service('nginx', 'restart')

View File

@ -215,7 +215,6 @@ def get_error_pages():
def get_limit_conn_shared_memory():
"""Allocate 2 percent of total virtual memory as shared memory for nginx limit_conn_zone"""
import psutil
total_vm = (psutil.virtual_memory().total) / (1024 * 1024) # in MB
total_vm = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES')) / (1024 * 1024) # in MB
return int(0.02 * total_vm)

View File

@ -1,10 +1,18 @@
from bench.utils import get_program, exec_cmd, get_cmd_output, fix_prod_setup_perms, get_bench_name, find_executable, CommandFailedError
from bench.config.supervisor import generate_supervisor_config
from bench.config.systemd import generate_systemd_config
from bench.config.nginx import make_nginx_conf
from bench.config.common_site_config import get_config
import os, subprocess
def setup_production(user, bench_path='.', yes=False):
generate_supervisor_config(bench_path=bench_path, user=user, yes=yes)
if get_config(bench_path).get('restart_supervisor_on_update') and get_config(bench_path).get('restart_systemd_on_update'):
raise Exception("You cannot use supervisor and systemd at the same time. Modify your common_site_config accordingly." )
if get_config(bench_path).get('restart_systemd_on_update'):
generate_systemd_config(bench_path=bench_path, user=user, yes=yes)
else:
generate_supervisor_config(bench_path=bench_path, user=user, yes=yes)
make_nginx_conf(bench_path=bench_path, yes=yes)
fix_prod_setup_perms(bench_path, frappe_user=user)
remove_default_nginx_configs()
@ -12,18 +20,20 @@ def setup_production(user, bench_path='.', yes=False):
bench_name = get_bench_name(bench_path)
nginx_conf = '/etc/nginx/conf.d/{bench_name}.conf'.format(bench_name=bench_name)
supervisor_conf_extn = "ini" if is_centos7() else "conf"
supervisor_conf = os.path.join(get_supervisor_confdir(), '{bench_name}.{extn}'.format(
bench_name=bench_name, extn=supervisor_conf_extn))
if get_config(bench_path).get('restart_supervisor_on_update'):
supervisor_conf_extn = "ini" if is_centos7() else "conf"
supervisor_conf = os.path.join(get_supervisor_confdir(), '{bench_name}.{extn}'.format(
bench_name=bench_name, extn=supervisor_conf_extn))
# Check if symlink exists, If not then create it.
if not os.path.islink(supervisor_conf):
os.symlink(os.path.abspath(os.path.join(bench_path, 'config', 'supervisor.conf')), supervisor_conf)
# Check if symlink exists, If not then create it.
if not os.path.islink(supervisor_conf):
os.symlink(os.path.abspath(os.path.join(bench_path, 'config', 'supervisor.conf')), supervisor_conf)
if not os.path.islink(nginx_conf):
os.symlink(os.path.abspath(os.path.join(bench_path, 'config', 'nginx.conf')), nginx_conf)
reload_supervisor()
if get_config(bench_path).get('restart_supervisor_on_update'):
reload_supervisor()
if os.environ.get('NO_SERVICE_RESTART'):
return
@ -41,8 +51,9 @@ def disable_production(bench_path='.'):
if os.path.islink(supervisor_conf):
os.unlink(supervisor_conf)
exec_cmd('sudo supervisorctl reread')
exec_cmd('sudo supervisorctl update')
if get_config(bench_path).get('restart_supervisor_on_update'):
exec_cmd('sudo supervisorctl reread')
exec_cmd('sudo supervisorctl update')
# nginx
nginx_conf = '/etc/nginx/conf.d/{bench_name}.conf'.format(bench_name=bench_name)

View File

@ -67,9 +67,7 @@ def get_redis_version():
return float('{major}.{minor}'.format(major=version.major, minor=version.minor))
def get_max_redis_memory():
import psutil
total_virtual_mem = psutil.virtual_memory().total/(pow(1024, 2))
total_virtual_mem = os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES')/(pow(1024, 2))
max_memory = int(total_virtual_mem * 0.05) # Max memory for redis is 5% of virtual memory
if max_memory < 50:

View File

@ -42,4 +42,5 @@ def generate_supervisor_config(bench_path, user=None, yes=False):
f.write(config)
update_config({'restart_supervisor_on_update': True}, bench_path=bench_path)
update_config({'restart_systemd_on_update': False}, bench_path=bench_path)

220
bench/config/systemd.py Normal file
View File

@ -0,0 +1,220 @@
import os, getpass, click
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
def generate_systemd_config(bench_path, user=None, yes=False,
stop=False, create_symlinks=False,
delete_symlinks=False):
if not user:
user = getpass.getuser()
config = get_config(bench_path=bench_path)
bench_dir = os.path.abspath(bench_path)
bench_name = get_bench_name(bench_path)
if stop:
exec_cmd('sudo systemctl stop -- $(systemctl show -p Requires {bench_name}.target | cut -d= -f2)'.format(bench_name=bench_name))
return
if create_symlinks:
_create_symlinks(bench_path)
return
if delete_symlinks:
_delete_symlinks(bench_path)
return
number_of_workers = config.get('background_workers') or 1
background_workers = []
for i in range(number_of_workers):
background_workers.append(get_bench_name(bench_path) + "-frappe-default-worker@" + str(i+1) + ".service")
for i in range(number_of_workers):
background_workers.append(get_bench_name(bench_path) + "-frappe-short-worker@" + str(i+1) + ".service")
for i in range(number_of_workers):
background_workers.append(get_bench_name(bench_path) + "-frappe-long-worker@" + str(i+1) + ".service")
bench_info = {
"bench_dir": bench_dir,
"sites_dir": os.path.join(bench_dir, 'sites'),
"user": user,
"frappe_version": get_current_frappe_version(bench_path),
"use_rq": use_rq(bench_path),
"http_timeout": config.get("http_timeout", 120),
"redis_server": find_executable('redis-server'),
"node": find_executable('node') or find_executable('nodejs'),
"redis_cache_config": os.path.join(bench_dir, 'config', 'redis_cache.conf'),
"redis_socketio_config": os.path.join(bench_dir, 'config', 'redis_socketio.conf'),
"redis_queue_config": os.path.join(bench_dir, 'config', 'redis_queue.conf'),
"webserver_port": config.get('webserver_port', 8000),
"gunicorn_workers": config.get('gunicorn_workers', get_gunicorn_workers()["gunicorn_workers"]),
"bench_name": get_bench_name(bench_path),
"worker_target_wants": " ".join(background_workers),
"bench_cmd": find_executable('bench')
}
if not yes:
click.confirm('current systemd configuration will be overwritten. Do you want to continue?',
abort=True)
setup_systemd_directory(bench_path)
setup_main_config(bench_info, bench_path)
setup_workers_config(bench_info, bench_path)
setup_web_config(bench_info, bench_path)
setup_redis_config(bench_info, bench_path)
update_config({'restart_systemd_on_update': True}, bench_path=bench_path)
update_config({'restart_supervisor_on_update': False}, bench_path=bench_path)
def setup_systemd_directory(bench_path):
if not os.path.exists(os.path.join(bench_path, 'config', 'systemd')):
os.makedirs(os.path.join(bench_path, 'config', 'systemd'))
def setup_main_config(bench_info, bench_path):
# Main config
bench_template = bench.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')
with open(bench_config_path, 'w') as f:
f.write(bench_config)
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_config = bench_workers_target_template.render(**bench_info)
bench_default_worker_config = bench_default_worker_template.render(**bench_info)
bench_short_worker_config = bench_short_worker_template.render(**bench_info)
bench_long_worker_config = bench_long_worker_template.render(**bench_info)
bench_schedule_worker_config = bench_schedule_worker_template.render(**bench_info)
bench_workers_target_config_path = os.path.join(bench_path, 'config', 'systemd' , bench_info.get("bench_name") + '-workers.target')
bench_default_worker_config_path = os.path.join(bench_path, 'config', 'systemd' , bench_info.get("bench_name") + '-frappe-default-worker@.service')
bench_short_worker_config_path = os.path.join(bench_path, 'config', 'systemd' , bench_info.get("bench_name") + '-frappe-short-worker@.service')
bench_long_worker_config_path = os.path.join(bench_path, 'config', 'systemd' , bench_info.get("bench_name") + '-frappe-long-worker@.service')
bench_schedule_worker_config_path = os.path.join(bench_path, 'config', 'systemd' , bench_info.get("bench_name") + '-frappe-schedule.service')
with open(bench_workers_target_config_path, 'w') as f:
f.write(bench_workers_target_config)
with open(bench_default_worker_config_path, 'w') as f:
f.write(bench_default_worker_config)
with open(bench_short_worker_config_path, 'w') as f:
f.write(bench_short_worker_config)
with open(bench_long_worker_config_path, 'w') as f:
f.write(bench_long_worker_config)
with open(bench_schedule_worker_config_path, 'w') as f:
f.write(bench_schedule_worker_config)
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_config = bench_web_target_template.render(**bench_info)
bench_web_service_config = bench_web_service_template.render(**bench_info)
bench_node_socketio_config = bench_node_socketio_template.render(**bench_info)
bench_web_target_config_path = os.path.join(bench_path, 'config', 'systemd' , bench_info.get("bench_name") + '-web.target')
bench_web_service_config_path = os.path.join(bench_path, 'config', 'systemd' , bench_info.get("bench_name") + '-frappe-web.service')
bench_node_socketio_config_path = os.path.join(bench_path, 'config', 'systemd' , bench_info.get("bench_name") + '-node-socketio.service')
with open(bench_web_target_config_path, 'w') as f:
f.write(bench_web_target_config)
with open(bench_web_service_config_path, 'w') as f:
f.write(bench_web_service_config)
with open(bench_node_socketio_config_path, 'w') as f:
f.write(bench_node_socketio_config)
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_config = bench_redis_target_template.render(**bench_info)
bench_redis_cache_config = bench_redis_cache_template.render(**bench_info)
bench_redis_queue_config = bench_redis_queue_template.render(**bench_info)
bench_redis_socketio_config = bench_redis_socketio_template.render(**bench_info)
bench_redis_target_config_path = os.path.join(bench_path, 'config', 'systemd' , bench_info.get("bench_name") + '-redis.target')
bench_redis_cache_config_path = os.path.join(bench_path, 'config', 'systemd' , bench_info.get("bench_name") + '-redis-cache.service')
bench_redis_queue_config_path = os.path.join(bench_path, 'config', 'systemd' , bench_info.get("bench_name") + '-redis-queue.service')
bench_redis_socketio_config_path = os.path.join(bench_path, 'config', 'systemd' , bench_info.get("bench_name") + '-redis-socketio.service')
with open(bench_redis_target_config_path, 'w') as f:
f.write(bench_redis_target_config)
with open(bench_redis_cache_config_path, 'w') as f:
f.write(bench_redis_cache_config)
with open(bench_redis_queue_config_path, 'w') as f:
f.write(bench_redis_queue_config)
with open(bench_redis_socketio_config_path, 'w') as f:
f.write(bench_redis_socketio_config)
def _create_symlinks(bench_path):
bench_dir = os.path.abspath(bench_path)
etc_systemd_system = os.path.join('/', 'etc', 'systemd', 'system')
config_path = os.path.join(bench_dir, 'config', 'systemd')
unit_files = get_unit_files(bench_dir)
for unit_file in unit_files:
filename = "".join(unit_file)
exec_cmd('sudo ln -s {config_path}/{unit_file} {etc_systemd_system}/{unit_file_init}'.format(
config_path=config_path,
etc_systemd_system=etc_systemd_system,
unit_file=filename,
unit_file_init="".join(unit_file)
))
exec_cmd('sudo systemctl daemon-reload')
def _delete_symlinks(bench_path):
bench_dir = os.path.abspath(bench_path)
etc_systemd_system = os.path.join('/', 'etc', 'systemd', 'system')
config_path = os.path.join(bench_dir, 'config', 'systemd')
unit_files = get_unit_files(bench_dir)
for unit_file in unit_files:
exec_cmd('sudo rm {etc_systemd_system}/{unit_file_init}'.format(
config_path=config_path,
etc_systemd_system=etc_systemd_system,
unit_file_init="".join(unit_file)
))
exec_cmd('sudo systemctl daemon-reload')
def get_unit_files(bench_path):
bench_name = get_bench_name(bench_path)
unit_files = [
[bench_name, ".target"],
[bench_name+"-workers", ".target"],
[bench_name+"-web", ".target"],
[bench_name+"-redis", ".target"],
[bench_name+"-frappe-default-worker@", ".service"],
[bench_name+"-frappe-short-worker@", ".service"],
[bench_name+"-frappe-long-worker@", ".service"],
[bench_name+"-frappe-schedule", ".service"],
[bench_name+"-frappe-web", ".service"],
[bench_name+"-node-socketio", ".service"],
[bench_name+"-redis-cache", ".service"],
[bench_name+"-redis-queue", ".service"],
[bench_name+"-redis-socketio", ".service"],
]
return unit_files

View File

@ -0,0 +1,12 @@
[Unit]
Description="{{ bench_name }}-frappe-default-worker %I"
PartOf={{ bench_name }}-workers.target
[Service]
User={{ user }}
Group={{ user }}
Restart=always
ExecStart={{ bench_cmd }} worker --queue default
StandardOutput=file:{{ bench_dir }}/logs/worker.log
StandardError=file:{{ bench_dir }}/logs/worker.error.log
WorkingDirectory={{ bench_dir }}

View File

@ -0,0 +1,12 @@
[Unit]
Description="{{ bench_name }}-frappe-short-worker %I"
PartOf={{ bench_name }}-workers.target
[Service]
User={{ user }}
Group={{ user }}
Restart=always
ExecStart={{ bench_cmd }} worker --queue long
StandardOutput=file:{{ bench_dir }}/logs/worker.log
StandardError=file:{{ bench_dir }}/logs/worker.error.log
WorkingDirectory={{ bench_dir }}

View File

@ -0,0 +1,12 @@
[Unit]
Description="{{ bench_name }}-frappe-schedule"
PartOf={{ bench_name }}-workers.target
[Service]
User={{ user }}
Group={{ user }}
Restart=always
ExecStart={{ bench_cmd }} schedule
StandardOutput=file:{{ bench_dir }}/logs/schedule.log
StandardError=file:{{ bench_dir }}/logs/schedule.error.log
WorkingDirectory={{ bench_dir }}

View File

@ -0,0 +1,12 @@
[Unit]
Description="{{ bench_name }}-frappe-short-worker %I"
PartOf={{ bench_name }}-workers.target
[Service]
User={{ user }}
Group={{ user }}
Restart=always
ExecStart={{ bench_cmd }} worker --queue short
StandardOutput=file:{{ bench_dir }}/logs/worker.log
StandardError=file:{{ bench_dir }}/logs/worker.error.log
WorkingDirectory={{ bench_dir }}

View File

@ -0,0 +1,12 @@
[Unit]
Description="{{ bench_name }}-frappe-web"
PartOf={{ bench_name }}-web.target
[Service]
User={{ user }}
Group={{ user }}
Restart=always
ExecStart={{ bench_dir }}/env/bin/gunicorn -b 127.0.0.1:{{ webserver_port }} -w {{ gunicorn_workers }} -t {{ http_timeout }} frappe.app:application --preload
StandardOutput=file:{{ bench_dir }}/logs/web.log
StandardError=file:{{ bench_dir }}/logs/web.error.log
WorkingDirectory={{ sites_dir }}

View File

@ -0,0 +1,13 @@
[Unit]
After={{ bench_name }}-frappe-web.service
Description="{{ bench_name }}-node-socketio"
PartOf={{ bench_name }}-web.target
[Service]
User={{ user }}
Group={{ user }}
Restart=always
ExecStart={{ node }} {{ bench_dir }}/apps/frappe/socketio.js
StandardOutput=file:{{ bench_dir }}/logs/node-socketio.log
StandardError=file:{{ bench_dir }}/logs/node-socketio.error.log
WorkingDirectory={{ bench_dir }}

View File

@ -0,0 +1,12 @@
[Unit]
Description="{{ bench_name }}-redis-cache"
PartOf={{ bench_name }}-redis.target
[Service]
User={{ user }}
Group={{ user }}
Restart=always
ExecStart={{ redis_server }} {{ redis_cache_config }}
StandardOutput=file:{{ bench_dir }}/logs/redis-cache.log
StandardError=file:{{ bench_dir }}/logs/redis-cache.error.log
WorkingDirectory={{ sites_dir }}

View File

@ -0,0 +1,12 @@
[Unit]
Description="{{ bench_name }}-redis-queue"
PartOf={{ bench_name }}-redis.target
[Service]
User={{ user }}
Group={{ user }}
Restart=always
ExecStart={{ redis_server }} {{ redis_queue_config }}
StandardOutput=file:{{ bench_dir }}/logs/redis-queue.log
StandardError=file:{{ bench_dir }}/logs/redis-queue.error.log
WorkingDirectory={{ sites_dir }}

View File

@ -0,0 +1,12 @@
[Unit]
Description="{{ bench_name }}-redis-socketio"
PartOf={{ bench_name }}-redis.target
[Service]
User={{ user }}
Group={{ user }}
Restart=always
ExecStart={{ redis_server }} {{ redis_socketio_config }}
StandardOutput=file:{{ bench_dir }}/logs/redis-socketio.log
StandardError=file:{{ bench_dir }}/logs/redis-socketio.error.log
WorkingDirectory={{ sites_dir }}

View File

@ -0,0 +1,6 @@
[Unit]
After=network.target
Wants={{ bench_name }}-redis-cache.service {{ bench_name }}-redis-queue.service {{ bench_name }}-redis-socketio.service
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,6 @@
[Unit]
After=network.target
Wants={{ bench_name }}-frappe-web.service {{ bench_name }}-node-socketio.service
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,6 @@
[Unit]
After=network.target
Wants={{ worker_target_wants }}
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,6 @@
[Unit]
After=network.target
Requires={{ bench_name }}-web.target {{ bench_name }}-workers.target {{ bench_name }}-redis.target
[Install]
WantedBy=multi-user.target

View File

@ -8,7 +8,7 @@ def execute(bench_path):
if node_exec:
result = subprocess.check_output([node_exec, '-v'])
result = subprocess.check_output([node_exec, '-v']).decode()
else:
click.echo('''
No node executable was found on your machine.

View File

@ -59,6 +59,7 @@ def confirm_testing():
print('')
print('')
click.confirm('Is manual testing done?', abort = True)
click.confirm('Have you added the change log?', abort = True)
def bump(bench_path, app, bump_type, from_branch, to_branch, remote, owner, repo_name=None):
assert bump_type in ['minor', 'major', 'patch', 'stable', 'prerelease']

View File

@ -94,6 +94,11 @@ def init(path, apps_path=None, no_procfile=False, no_backups=False,
setup_backups(bench_path=path)
if not no_auto_update:
setup_auto_update(bench_path=path)
copy_patches_txt(path)
def copy_patches_txt(bench_path):
shutil.copy(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'patches', 'patches.txt'),
os.path.join(bench_path, 'patches.txt'))
def clone_apps_from(bench_path, clone_from, update_app=True):
from .app import install_app
@ -142,7 +147,8 @@ def exec_cmd(cmd, cwd='.'):
logger.info(cmd)
p = subprocess.Popen(cmd, cwd=cwd, shell=True, stdout=stdout, stderr=stderr, universal_newlines=True)
p = subprocess.Popen(cmd, cwd=cwd, shell=True, stdout=stdout, stderr=stderr,
universal_newlines=True)
if async:
return_code = print_output(p)
@ -381,7 +387,7 @@ def restart_supervisor_processes(bench_path='.', web_workers=False):
else:
supervisor_status = subprocess.check_output(['sudo', 'supervisorctl', 'status'], cwd=bench_path)
supervisor_status = safe_decode(supervisor_status)
if web_workers and '{bench_name}-web:'.format(bench_name=bench_name) in supervisor_status:
group = '{bench_name}-web: '.format(bench_name=bench_name)
@ -398,6 +404,13 @@ def restart_supervisor_processes(bench_path='.', web_workers=False):
exec_cmd('sudo supervisorctl restart {group}'.format(group=group), cwd=bench_path)
def restart_systemd_processes(bench_path='.', web_workers=False):
from .config.common_site_config import get_config
conf = get_config(bench_path=bench_path)
bench_name = get_bench_name(bench_path)
exec_cmd('sudo systemctl stop -- $(systemctl show -p Requires {bench_name}.target | cut -d= -f2)'.format(bench_name=bench_name))
exec_cmd('sudo systemctl start -- $(systemctl show -p Requires {bench_name}.target | cut -d= -f2)'.format(bench_name=bench_name))
def set_default_site(site, bench_path='.'):
if not site in get_sites(bench_path=bench_path):
raise Exception("Site not in bench")
@ -408,7 +421,7 @@ def update_requirements(bench_path='.'):
print('Updating Python libraries...')
pip = os.path.join(bench_path, 'env', 'bin', 'pip')
# pip 10 seems to have a few problems associated with it, temporary freeze pip at 9.0.3
# pip 10 seems to have a few problems associated with it, temporary freeze pip at 9.0.3
exec_cmd("{pip} install --upgrade pip==9.0.3".format(pip=pip))
apps_dir = os.path.join(bench_path, 'apps')

View File

@ -36,7 +36,7 @@ def install_bench(args):
# secure pip installation
if find_executable('pip'):
run_os_command({
'pip': 'sudo pip install --upgrade setuptools pip==9.0.3'
'pip': 'sudo pip install --upgrade setuptools urllib3 requests cryptography pip==9.0.3'
})
else:
@ -51,11 +51,11 @@ def install_bench(args):
if success:
run_os_command({
'pip': 'sudo pip install --upgrade pip==9.0.3 setuptools',
'pip': 'sudo pip install --upgrade setuptools urllib3 requests cryptography pip==9.0.3'
})
success = run_os_command({
'pip': "sudo pip install ansible"
'pip': "sudo pip install --upgrade urllib3 requests cryptography ansible"
})
if not success:

View File

@ -15,7 +15,7 @@
register: site_folder
- name: Create a new site
command: "bench new-site {{ site }} --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

View File

@ -7,6 +7,8 @@ Installs MariaDB
```
CentOS 6 & 7
Ubuntu 14.04
Ubuntu 16.04
Debain 9
```
## Post install
@ -22,7 +24,7 @@ None
MariaDB version:
```
mariadb_version: 10.0
mariadb_version: 10.2
```
Configuration template:
@ -52,13 +54,10 @@ None
```
- hosts: servers
roles:
- { role: pcextreme.mariadb }
- { role: mariadb }
```
## License
## Credits
MIT / BSD
- [Attila van der Velde](https://github.com/vdvm)
## Author Information
Created by [Attila van der Velde](https://github.com/vdvm)

View File

@ -5,4 +5,3 @@ mysql_conf_tpl: change_me
mysql_conf_file: settings.cnf
mysql_secure_installation: false
...

View File

@ -1,4 +1,3 @@
---
- name: restart mysql
service: name=mysql state=restarted
...

View File

@ -6,5 +6,8 @@
yum: name={{ item }} enablerepo=mariadb state=present
with_items:
- MariaDB-server
- MySQL-python # required for secure_install
...
- MariaDB-client
- name: Install MySQLdb Python package for secure installations.
yum: name=MySQL-python state=present
when: mysql_secure_installation and mysql_root_password is defined

View File

@ -1,10 +1,12 @@
---
- include: centos.yml
when: ansible_distribution == 'CentOS' and ansible_distribution_major_version|int >= 6
- include_tasks: centos.yml
when: ansible_distribution == 'CentOS'
- include: ubuntu-trusty.yml
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '14.04'
- include_tasks: ubuntu.yml
when: ansible_distribution == 'Ubuntu'
- include: ubuntu-xenial.yml
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '16.04'
- name: Add configuration
template: src={{ mysql_conf_tpl }} dest={{ mysql_conf_dir[ansible_distribution] }}/{{ mysql_conf_file }} owner=root group=root mode=0644

View File

@ -1,33 +1,22 @@
---
# Set root password
# UPDATE mysql.user SET Password=PASSWORD('mysecret') WHERE User='root';
# FLUSH PRIVILEGES;
- debug:
msg: "{{ mysql_root_password }}"
- name: Set root Password
mysql_user: name=root host={{ item }} password={{ mysql_root_password }} state=present
with_items:
- localhost
ignore_errors: yes
# create root .my.cnf config file
- name: Add .my.cnf
template: src=my.cnf.j2 dest=/root/.my.cnf owner=root group=root mode=0600
- name: display .my.cnf
command: cat /root/.my.cnf
register: details
- debug:
msg: "{{ details.stdout_lines }}"
# Set root password
# UPDATE mysql.user SET Password=PASSWORD('mysecret') WHERE User='root';
# FLUSH PRIVILEGES;
- name: Set root Password
mysql_user: name=root host={{ item }} password={{ mysql_root_password }} state=present
mysql_user: login_password={{ mysql_root_password }} check_implicit_admin=yes name=root host={{ item }} password={{ mysql_root_password }} state=present
with_items:
- localhost
- 127.0.0.1
- ::1
when: run_travis is not defined
- name: Reload privilege tables
command: 'mysql -ne "{{ item }}"'
@ -53,7 +42,7 @@
- name: Remove test database and access to it
command: 'mysql -ne "{{ item }}"'
with_items:
- DROP DATABASE if exists test
- DROP DATABASE IF EXISTS test
- DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%'
changed_when: False
when: run_travis is not defined
@ -64,20 +53,3 @@
- FLUSH PRIVILEGES
changed_when: False
when: run_travis is not defined
- name: add launchagents folder mac
file: path=~/Library/LaunchAgents state=directory
when: ansible_distribution == 'MacOSX'
- name: add mysql to mac startup
file: src=/usr/local/opt/mariadb/homebrew.mxcl.mariadb.plist path=~/Library/LaunchAgents/homebrew.mxcl.mariadb.plist state=link force=yes
when: ansible_distribution == 'MacOSX'
- name: stop mysql mac
command: launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mariadb.plist
when: ansible_distribution == 'MacOSX'
- name: start mysql mac
command: launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mariadb.plist
when: ansible_distribution == 'MacOSX'
...

View File

@ -6,12 +6,6 @@
- name: Add repo key
apt_key: id=1BB943DB url=http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xCBCB082A1BB943DB state=present
register: mariadb_key
when: ansible_distribution_version | version_compare('16.04', 'lt')
- name: Add apt key for mariadb for Ubuntu >= 16.04
apt_key: id=C74CD1D8 url=http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xF1656F24C74CD1D8 state=present
register: mariadb_key
when: ansible_distribution_version | version_compare('16.04', 'ge')
- name: Update apt cache
apt: update_cache=yes
@ -25,5 +19,9 @@
apt: pkg={{ item }} state=present
with_items:
- mariadb-server
- python-mysqldb # required to set the MySQL password using ansible
...
- mariadb-client
- libmariadbclient18
- name: Install MySQLdb Python package for secure installations.
apt: pkg=python-mysqldb state=present
when: mysql_secure_installation and mysql_root_password is defined

View File

@ -0,0 +1,27 @@
---
- name: Add repo file
template: src=mariadb_ubuntu.list.j2 dest=/etc/apt/sources.list.d/mariadb.list owner=root group=root mode=0644
register: mariadb_list
- name: Add repo key
apt_key: id=C74CD1D8 url=http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xF1656F24C74CD1D8 state=present
register: mariadb_key
- name: Update apt cache
apt: update_cache=yes
when: mariadb_list.changed == True or mariadb_key.changed == True
- name: Unattended package installation
shell: export DEBIAN_FRONTEND=noninteractive
changed_when: false
- name: Install MariaDB
apt: pkg={{ item }} state=present
with_items:
- mariadb-server
- mariadb-client
- libmariadbclient18
- name: Install MySQLdb Python package for secure installations.
apt: pkg=python-mysqldb state=present
when: mysql_secure_installation and mysql_root_password is defined

View File

@ -1,4 +1,4 @@
# MariaDB {{ mariadb_version }} CentOS {{ ansible_distribution_major_version|int }} repository list
# MariaDB CentOS {{ ansible_distribution_major_version|int }} repository list
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB

View File

@ -1,4 +1,4 @@
# MariaDB {{ mariadb_version }} Ubuntu {{ ansible_distribution_release | title }} repository list
# MariaDB Ubuntu {{ ansible_distribution_release | title }} repository list
# http://mariadb.org/mariadb/repositories/
deb http://ams2.mirrors.digitalocean.com/mariadb/repo/{{ mariadb_version }}/ubuntu {{ ansible_distribution_release | lower }} main
deb-src http://ams2.mirrors.digitalocean.com/mariadb/repo/{{ mariadb_version }}/ubuntu {{ ansible_distribution_release | lower }} main

View File

@ -3,7 +3,6 @@ mysql_conf_dir:
"CentOS": /etc/my.cnf.d
"Ubuntu": /etc/mysql/conf.d
"Debian": /etc/mysql/conf.d
"MacOSX": /usr/local/etc/my.cnf.d
mysql_conf_tpl: files/mariadb_config.cnf
mysql_secure_installation: True
...
...

View File

@ -0,0 +1,3 @@
---
node_version: 8
...

View File

@ -1,17 +1,5 @@
---
- 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
- name: Install nodejs {{ node_version }}
apt:
name: nodejs
state: present

View File

@ -1,6 +1,12 @@
---
# Install's prerequisites, like fonts, image libraries, vim, screen, python-dev and gcc
- name: 'Add Node.js PPA'
tags: 'nodejs'
become: 'yes'
become_method: 'sudo'
shell: "curl --silent --location https://deb.nodesource.com/setup_{{ node_version }}.x | bash -"
- include_tasks: debian_family.yml
when: ansible_os_family == 'Debian'

View File

@ -1,18 +1,5 @@
---
- 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
- name: Install node v{{ node_version }}
yum: name=nodejs state=present
when: ansible_os_family == 'RedHat'
...

View File

@ -7,6 +7,7 @@
roles:
- { role: common, tags: common }
- { role: locale, tags: locale }
- { role: nodejs, tags: nodejs }
- { role: swap, tags: swap, when: production }
- { role: logwatch, tags: logwatch, when: production }
- { role: bash_screen_wall, tags: bash_screen_wall, when: production }
@ -15,7 +16,6 @@
- { 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 }

View File

@ -3,7 +3,6 @@ jinja2
virtualenv
requests
honcho
psutil
python-crontab
semantic_version
GitPython==0.3.2.1