mirror of
https://github.com/frappe/bench.git
synced 2025-01-08 00:04:38 +00:00
Merge branch 'master' into multi_fixes
This commit is contained in:
commit
38601eabf8
68
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
68
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal 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:
|
||||||
|
|
21
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
21
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal 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
28
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal 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:
|
||||||
|
|
@ -1,7 +1,5 @@
|
|||||||
language: python
|
language: python
|
||||||
dist: trusty
|
dist: trusty
|
||||||
group: deprecated-2017Q2
|
|
||||||
sudo: required
|
|
||||||
|
|
||||||
python:
|
python:
|
||||||
- "2.7"
|
- "2.7"
|
||||||
|
@ -144,8 +144,12 @@ For production:
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Bench Manager
|
|
||||||
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, in the form of a frappe website.
|
## 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
|
$ bench setup manager
|
||||||
|
30
bench/app.py
30
bench/app.py
@ -75,7 +75,7 @@ def add_to_excluded_apps_txt(app, bench_path='.'):
|
|||||||
if app == 'frappe':
|
if app == 'frappe':
|
||||||
raise ValueError('Frappe app cannot be excludeed from update')
|
raise ValueError('Frappe app cannot be excludeed from update')
|
||||||
if app not in os.listdir('apps'):
|
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)
|
apps = get_excluded_apps(bench_path=bench_path)
|
||||||
if app not in apps:
|
if app not in apps:
|
||||||
apps.append(app)
|
apps.append(app)
|
||||||
@ -91,7 +91,8 @@ def remove_from_excluded_apps_txt(app, bench_path='.'):
|
|||||||
apps.remove(app)
|
apps.remove(app)
|
||||||
return write_excluded_apps_txt(apps, bench_path=bench_path)
|
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
|
# from bench.utils import check_url
|
||||||
try:
|
try:
|
||||||
from urlparse import urljoin
|
from urlparse import urljoin
|
||||||
@ -133,13 +134,24 @@ def get_app(git_url, branch=None, bench_path='.', build_asset_files=True, verbos
|
|||||||
print('installing', app_name)
|
print('installing', app_name)
|
||||||
install_app(app=app_name, bench_path=bench_path, verbose=verbose)
|
install_app(app=app_name, bench_path=bench_path, verbose=verbose)
|
||||||
|
|
||||||
if build_asset_files:
|
if postprocess:
|
||||||
build_assets(bench_path=bench_path)
|
# get apps for docs
|
||||||
conf = get_config(bench_path=bench_path)
|
if repo_name=='frappe':
|
||||||
if conf.get('restart_supervisor_on_update'):
|
get_app('https://github.com/frappe/frappe_io', bench_path = bench_path,
|
||||||
restart_supervisor_processes(bench_path=bench_path)
|
branch= 'master', postprocess = False)
|
||||||
if conf.get('restart_systemd_on_update'):
|
|
||||||
restart_systemd_processes(bench_path=bench_path)
|
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='.'):
|
def new_app(app, bench_path='.'):
|
||||||
# For backwards compatibility
|
# For backwards compatibility
|
||||||
|
@ -48,7 +48,7 @@ def check_uid():
|
|||||||
|
|
||||||
def cmd_requires_root():
|
def cmd_requires_root():
|
||||||
if len(sys.argv) > 2 and sys.argv[2] in ('production', 'sudoers', 'lets-encrypt', 'fonts',
|
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
|
return True
|
||||||
if len(sys.argv) >= 2 and sys.argv[1] in ('patch', 'renew-lets-encrypt', 'disable-production',
|
if len(sys.argv) >= 2 and sys.argv[1] in ('patch', 'renew-lets-encrypt', 'disable-production',
|
||||||
'install'):
|
'install'):
|
||||||
|
@ -128,6 +128,16 @@ def setup_letsencrypt(site, custom_domain, non_interactive):
|
|||||||
setup_letsencrypt(site, custom_domain, bench_path='.', interactive=not 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')
|
@click.command('procfile')
|
||||||
def setup_procfile():
|
def setup_procfile():
|
||||||
"Setup Procfile for bench start"
|
"Setup Procfile for bench start"
|
||||||
@ -279,6 +289,7 @@ setup.add_command(reload_nginx)
|
|||||||
setup.add_command(setup_supervisor)
|
setup.add_command(setup_supervisor)
|
||||||
setup.add_command(setup_redis)
|
setup.add_command(setup_redis)
|
||||||
setup.add_command(setup_letsencrypt)
|
setup.add_command(setup_letsencrypt)
|
||||||
|
setup.add_command(setup_wildcard_ssl)
|
||||||
setup.add_command(setup_production)
|
setup.add_command(setup_production)
|
||||||
setup.add_command(setup_auto_update)
|
setup.add_command(setup_auto_update)
|
||||||
setup.add_command(setup_backups)
|
setup.add_command(setup_backups)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import bench, os, click, errno
|
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.site_config import update_site_config, remove_domain, get_domains
|
||||||
from bench.config.nginx import make_nginx_conf
|
from bench.config.nginx import make_nginx_conf
|
||||||
from bench.config.production_setup import service
|
from bench.config.production_setup import service
|
||||||
@ -116,3 +116,59 @@ def renew_certs():
|
|||||||
service('nginx', 'stop')
|
service('nginx', 'stop')
|
||||||
exec_cmd("{path} renew".format(path=get_certbot_path()))
|
exec_cmd("{path} renew".format(path=get_certbot_path()))
|
||||||
service('nginx', 'start')
|
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')
|
||||||
|
|
@ -215,7 +215,6 @@ def get_error_pages():
|
|||||||
|
|
||||||
def get_limit_conn_shared_memory():
|
def get_limit_conn_shared_memory():
|
||||||
"""Allocate 2 percent of total virtual memory as shared memory for nginx limit_conn_zone"""
|
"""Allocate 2 percent of total virtual memory as shared memory for nginx limit_conn_zone"""
|
||||||
import psutil
|
total_vm = (os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES')) / (1024 * 1024) # in MB
|
||||||
total_vm = (psutil.virtual_memory().total) / (1024 * 1024) # in MB
|
|
||||||
|
|
||||||
return int(0.02 * total_vm)
|
return int(0.02 * total_vm)
|
||||||
|
@ -67,9 +67,7 @@ def get_redis_version():
|
|||||||
return float('{major}.{minor}'.format(major=version.major, minor=version.minor))
|
return float('{major}.{minor}'.format(major=version.major, minor=version.minor))
|
||||||
|
|
||||||
def get_max_redis_memory():
|
def get_max_redis_memory():
|
||||||
import psutil
|
total_virtual_mem = os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES')/(pow(1024, 2))
|
||||||
|
|
||||||
total_virtual_mem = psutil.virtual_memory().total/(pow(1024, 2))
|
|
||||||
max_memory = int(total_virtual_mem * 0.05) # Max memory for redis is 5% of virtual memory
|
max_memory = int(total_virtual_mem * 0.05) # Max memory for redis is 5% of virtual memory
|
||||||
|
|
||||||
if max_memory < 50:
|
if max_memory < 50:
|
||||||
|
@ -8,7 +8,7 @@ def execute(bench_path):
|
|||||||
|
|
||||||
|
|
||||||
if node_exec:
|
if node_exec:
|
||||||
result = subprocess.check_output([node_exec, '-v'])
|
result = subprocess.check_output([node_exec, '-v']).decode()
|
||||||
else:
|
else:
|
||||||
click.echo('''
|
click.echo('''
|
||||||
No node executable was found on your machine.
|
No node executable was found on your machine.
|
||||||
|
@ -59,6 +59,7 @@ def confirm_testing():
|
|||||||
print('')
|
print('')
|
||||||
print('')
|
print('')
|
||||||
click.confirm('Is manual testing done?', abort = True)
|
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):
|
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']
|
assert bump_type in ['minor', 'major', 'patch', 'stable', 'prerelease']
|
||||||
|
@ -94,6 +94,11 @@ def init(path, apps_path=None, no_procfile=False, no_backups=False,
|
|||||||
setup_backups(bench_path=path)
|
setup_backups(bench_path=path)
|
||||||
if not no_auto_update:
|
if not no_auto_update:
|
||||||
setup_auto_update(bench_path=path)
|
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):
|
def clone_apps_from(bench_path, clone_from, update_app=True):
|
||||||
from .app import install_app
|
from .app import install_app
|
||||||
@ -142,7 +147,8 @@ def exec_cmd(cmd, cwd='.'):
|
|||||||
|
|
||||||
logger.info(cmd)
|
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:
|
if async:
|
||||||
return_code = print_output(p)
|
return_code = print_output(p)
|
||||||
@ -381,7 +387,7 @@ def restart_supervisor_processes(bench_path='.', web_workers=False):
|
|||||||
else:
|
else:
|
||||||
supervisor_status = subprocess.check_output(['sudo', 'supervisorctl', 'status'], cwd=bench_path)
|
supervisor_status = subprocess.check_output(['sudo', 'supervisorctl', 'status'], cwd=bench_path)
|
||||||
supervisor_status = safe_decode(supervisor_status)
|
supervisor_status = safe_decode(supervisor_status)
|
||||||
|
|
||||||
if web_workers and '{bench_name}-web:'.format(bench_name=bench_name) in 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)
|
group = '{bench_name}-web: '.format(bench_name=bench_name)
|
||||||
|
|
||||||
@ -415,7 +421,7 @@ def update_requirements(bench_path='.'):
|
|||||||
print('Updating Python libraries...')
|
print('Updating Python libraries...')
|
||||||
pip = os.path.join(bench_path, 'env', 'bin', 'pip')
|
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))
|
exec_cmd("{pip} install --upgrade pip==9.0.3".format(pip=pip))
|
||||||
|
|
||||||
apps_dir = os.path.join(bench_path, 'apps')
|
apps_dir = os.path.join(bench_path, 'apps')
|
||||||
|
@ -36,7 +36,7 @@ def install_bench(args):
|
|||||||
# secure pip installation
|
# secure pip installation
|
||||||
if find_executable('pip'):
|
if find_executable('pip'):
|
||||||
run_os_command({
|
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:
|
else:
|
||||||
@ -51,11 +51,11 @@ def install_bench(args):
|
|||||||
|
|
||||||
if success:
|
if success:
|
||||||
run_os_command({
|
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({
|
success = run_os_command({
|
||||||
'pip': "sudo pip install ansible"
|
'pip': "sudo pip install --upgrade urllib3 requests cryptography ansible"
|
||||||
})
|
})
|
||||||
|
|
||||||
if not success:
|
if not success:
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
register: site_folder
|
register: site_folder
|
||||||
|
|
||||||
- name: Create a new site
|
- 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:
|
args:
|
||||||
chdir: "{{ bench_path }}"
|
chdir: "{{ bench_path }}"
|
||||||
when: not site_folder.stat.exists
|
when: not site_folder.stat.exists
|
||||||
|
@ -7,6 +7,8 @@ Installs MariaDB
|
|||||||
```
|
```
|
||||||
CentOS 6 & 7
|
CentOS 6 & 7
|
||||||
Ubuntu 14.04
|
Ubuntu 14.04
|
||||||
|
Ubuntu 16.04
|
||||||
|
Debain 9
|
||||||
```
|
```
|
||||||
|
|
||||||
## Post install
|
## Post install
|
||||||
@ -22,7 +24,7 @@ None
|
|||||||
MariaDB version:
|
MariaDB version:
|
||||||
|
|
||||||
```
|
```
|
||||||
mariadb_version: 10.0
|
mariadb_version: 10.2
|
||||||
```
|
```
|
||||||
|
|
||||||
Configuration template:
|
Configuration template:
|
||||||
@ -52,13 +54,10 @@ None
|
|||||||
```
|
```
|
||||||
- hosts: servers
|
- hosts: servers
|
||||||
roles:
|
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)
|
|
||||||
|
@ -5,4 +5,3 @@ mysql_conf_tpl: change_me
|
|||||||
mysql_conf_file: settings.cnf
|
mysql_conf_file: settings.cnf
|
||||||
|
|
||||||
mysql_secure_installation: false
|
mysql_secure_installation: false
|
||||||
...
|
|
@ -1,4 +1,3 @@
|
|||||||
---
|
---
|
||||||
- name: restart mysql
|
- name: restart mysql
|
||||||
service: name=mysql state=restarted
|
service: name=mysql state=restarted
|
||||||
...
|
|
@ -6,5 +6,8 @@
|
|||||||
yum: name={{ item }} enablerepo=mariadb state=present
|
yum: name={{ item }} enablerepo=mariadb state=present
|
||||||
with_items:
|
with_items:
|
||||||
- MariaDB-server
|
- 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
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
---
|
---
|
||||||
|
- include: centos.yml
|
||||||
|
when: ansible_distribution == 'CentOS' and ansible_distribution_major_version|int >= 6
|
||||||
|
|
||||||
- include_tasks: centos.yml
|
- include: ubuntu-trusty.yml
|
||||||
when: ansible_distribution == 'CentOS'
|
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '14.04'
|
||||||
|
|
||||||
- include_tasks: ubuntu.yml
|
- include: ubuntu-xenial.yml
|
||||||
when: ansible_distribution == 'Ubuntu'
|
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '16.04'
|
||||||
|
|
||||||
- name: Add configuration
|
- name: Add configuration
|
||||||
template: src={{ mysql_conf_tpl }} dest={{ mysql_conf_dir[ansible_distribution] }}/{{ mysql_conf_file }} owner=root group=root mode=0644
|
template: src={{ mysql_conf_tpl }} dest={{ mysql_conf_dir[ansible_distribution] }}/{{ mysql_conf_file }} owner=root group=root mode=0644
|
||||||
|
@ -1,33 +1,22 @@
|
|||||||
---
|
---
|
||||||
# Set root password
|
|
||||||
# UPDATE mysql.user SET Password=PASSWORD('mysecret') WHERE User='root';
|
|
||||||
# FLUSH PRIVILEGES;
|
|
||||||
|
|
||||||
- debug:
|
- debug:
|
||||||
msg: "{{ mysql_root_password }}"
|
msg: "{{ mysql_root_password }}"
|
||||||
|
|
||||||
- name: Set root Password
|
# create root .my.cnf config file
|
||||||
mysql_user: name=root host={{ item }} password={{ mysql_root_password }} state=present
|
|
||||||
with_items:
|
|
||||||
- localhost
|
|
||||||
ignore_errors: yes
|
|
||||||
|
|
||||||
- name: Add .my.cnf
|
- name: Add .my.cnf
|
||||||
template: src=my.cnf.j2 dest=/root/.my.cnf owner=root group=root mode=0600
|
template: src=my.cnf.j2 dest=/root/.my.cnf owner=root group=root mode=0600
|
||||||
|
|
||||||
- name: display .my.cnf
|
# Set root password
|
||||||
command: cat /root/.my.cnf
|
# UPDATE mysql.user SET Password=PASSWORD('mysecret') WHERE User='root';
|
||||||
register: details
|
# FLUSH PRIVILEGES;
|
||||||
|
|
||||||
- debug:
|
|
||||||
msg: "{{ details.stdout_lines }}"
|
|
||||||
|
|
||||||
- name: Set root Password
|
- 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:
|
with_items:
|
||||||
|
- localhost
|
||||||
- 127.0.0.1
|
- 127.0.0.1
|
||||||
- ::1
|
- ::1
|
||||||
when: run_travis is not defined
|
|
||||||
|
|
||||||
- name: Reload privilege tables
|
- name: Reload privilege tables
|
||||||
command: 'mysql -ne "{{ item }}"'
|
command: 'mysql -ne "{{ item }}"'
|
||||||
@ -53,7 +42,7 @@
|
|||||||
- name: Remove test database and access to it
|
- name: Remove test database and access to it
|
||||||
command: 'mysql -ne "{{ item }}"'
|
command: 'mysql -ne "{{ item }}"'
|
||||||
with_items:
|
with_items:
|
||||||
- DROP DATABASE if exists test
|
- DROP DATABASE IF EXISTS test
|
||||||
- DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%'
|
- DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%'
|
||||||
changed_when: False
|
changed_when: False
|
||||||
when: run_travis is not defined
|
when: run_travis is not defined
|
||||||
@ -64,20 +53,3 @@
|
|||||||
- FLUSH PRIVILEGES
|
- FLUSH PRIVILEGES
|
||||||
changed_when: False
|
changed_when: False
|
||||||
when: run_travis is not defined
|
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'
|
|
||||||
...
|
|
||||||
|
@ -6,12 +6,6 @@
|
|||||||
- name: Add repo key
|
- name: Add repo key
|
||||||
apt_key: id=1BB943DB url=http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xCBCB082A1BB943DB state=present
|
apt_key: id=1BB943DB url=http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xCBCB082A1BB943DB state=present
|
||||||
register: mariadb_key
|
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
|
- name: Update apt cache
|
||||||
apt: update_cache=yes
|
apt: update_cache=yes
|
||||||
@ -25,5 +19,9 @@
|
|||||||
apt: pkg={{ item }} state=present
|
apt: pkg={{ item }} state=present
|
||||||
with_items:
|
with_items:
|
||||||
- mariadb-server
|
- 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
|
27
playbooks/roles/mariadb/tasks/ubuntu-xenial.yml
Normal file
27
playbooks/roles/mariadb/tasks/ubuntu-xenial.yml
Normal 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
|
@ -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/
|
# http://mariadb.org/mariadb/repositories/
|
||||||
[mariadb]
|
[mariadb]
|
||||||
name = MariaDB
|
name = MariaDB
|
||||||
|
@ -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/
|
# http://mariadb.org/mariadb/repositories/
|
||||||
deb http://ams2.mirrors.digitalocean.com/mariadb/repo/{{ mariadb_version }}/ubuntu {{ ansible_distribution_release | lower }} main
|
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
|
deb-src http://ams2.mirrors.digitalocean.com/mariadb/repo/{{ mariadb_version }}/ubuntu {{ ansible_distribution_release | lower }} main
|
||||||
|
@ -3,7 +3,6 @@ mysql_conf_dir:
|
|||||||
"CentOS": /etc/my.cnf.d
|
"CentOS": /etc/my.cnf.d
|
||||||
"Ubuntu": /etc/mysql/conf.d
|
"Ubuntu": /etc/mysql/conf.d
|
||||||
"Debian": /etc/mysql/conf.d
|
"Debian": /etc/mysql/conf.d
|
||||||
"MacOSX": /usr/local/etc/my.cnf.d
|
|
||||||
mysql_conf_tpl: files/mariadb_config.cnf
|
mysql_conf_tpl: files/mariadb_config.cnf
|
||||||
mysql_secure_installation: True
|
mysql_secure_installation: True
|
||||||
...
|
...
|
||||||
|
3
playbooks/roles/nodejs/defaults/main.yml
Normal file
3
playbooks/roles/nodejs/defaults/main.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
node_version: 8
|
||||||
|
...
|
@ -1,17 +1,5 @@
|
|||||||
---
|
---
|
||||||
- name: Add apt key for node repo
|
- name: Install nodejs {{ node_version }}
|
||||||
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:
|
apt:
|
||||||
name: nodejs
|
name: nodejs
|
||||||
state: present
|
state: present
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
---
|
---
|
||||||
# Install's prerequisites, like fonts, image libraries, vim, screen, python-dev and gcc
|
# 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
|
- include_tasks: debian_family.yml
|
||||||
when: ansible_os_family == 'Debian'
|
when: ansible_os_family == 'Debian'
|
||||||
|
|
||||||
|
@ -1,18 +1,5 @@
|
|||||||
---
|
---
|
||||||
- name: Import Node source RPM key
|
- name: Install node v{{ node_version }}
|
||||||
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
|
yum: name=nodejs state=present
|
||||||
when: ansible_os_family == 'RedHat'
|
when: ansible_os_family == 'RedHat'
|
||||||
...
|
...
|
@ -7,6 +7,7 @@
|
|||||||
roles:
|
roles:
|
||||||
- { role: common, tags: common }
|
- { role: common, tags: common }
|
||||||
- { role: locale, tags: locale }
|
- { role: locale, tags: locale }
|
||||||
|
- { role: nodejs, tags: nodejs }
|
||||||
- { role: swap, tags: swap, when: production }
|
- { role: swap, tags: swap, when: production }
|
||||||
- { role: logwatch, tags: logwatch, when: production }
|
- { role: logwatch, tags: logwatch, when: production }
|
||||||
- { role: bash_screen_wall, tags: bash_screen_wall, when: production }
|
- { role: bash_screen_wall, tags: bash_screen_wall, when: production }
|
||||||
@ -15,7 +16,6 @@
|
|||||||
- { role: ntpd, tags: ntpd, when: production }
|
- { role: ntpd, tags: ntpd, when: production }
|
||||||
- { role: mariadb, tags: mariadb }
|
- { role: mariadb, tags: mariadb }
|
||||||
- { role: wkhtmltopdf, tags: wkhtmltopdf }
|
- { role: wkhtmltopdf, tags: wkhtmltopdf }
|
||||||
- { role: nodejs, tags: nodejs }
|
|
||||||
- { role: psutil, tags: psutil }
|
- { role: psutil, tags: psutil }
|
||||||
- { role: redis, tags: redis }
|
- { role: redis, tags: redis }
|
||||||
- { role: supervisor, tags: supervisor, when: production }
|
- { role: supervisor, tags: supervisor, when: production }
|
||||||
|
@ -3,7 +3,6 @@ jinja2
|
|||||||
virtualenv
|
virtualenv
|
||||||
requests
|
requests
|
||||||
honcho
|
honcho
|
||||||
psutil
|
|
||||||
python-crontab
|
python-crontab
|
||||||
semantic_version
|
semantic_version
|
||||||
GitPython==0.3.2.1
|
GitPython==0.3.2.1
|
||||||
|
Loading…
Reference in New Issue
Block a user