diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..aa3a104e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -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: + diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000..e09e5e95 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -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. + + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..8e2bd857 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -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: + diff --git a/.travis.yml b/.travis.yml index e4b562b7..ae45db62 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,5 @@ language: python dist: trusty -group: deprecated-2017Q2 -sudo: required python: - "2.7" diff --git a/README.md b/README.md index f10cbe90..e2cb1275 100755 --- a/README.md +++ b/README.md @@ -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 diff --git a/bench/app.py b/bench/app.py index 28e35342..93bc359f 100755 --- a/bench/app.py +++ b/bench/app.py @@ -75,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) @@ -91,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 @@ -133,13 +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 conf.get('restart_systemd_on_update'): - restart_systemd_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 diff --git a/bench/cli.py b/bench/cli.py index e6ad9984..c314d90a 100755 --- a/bench/cli.py +++ b/bench/cli.py @@ -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'): diff --git a/bench/commands/setup.py b/bench/commands/setup.py index 1fe014e8..d88ee80f 100755 --- a/bench/commands/setup.py +++ b/bench/commands/setup.py @@ -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" @@ -279,6 +289,7 @@ 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) diff --git a/bench/config/lets_encrypt.py b/bench/config/lets_encrypt.py index c6dceb16..4ec0f851 100755 --- a/bench/config/lets_encrypt.py +++ b/bench/config/lets_encrypt.py @@ -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') + \ No newline at end of file diff --git a/bench/config/nginx.py b/bench/config/nginx.py index d3ba4c97..6bbfa9ad 100644 --- a/bench/config/nginx.py +++ b/bench/config/nginx.py @@ -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) diff --git a/bench/config/redis.py b/bench/config/redis.py index fe102135..6a32927e 100644 --- a/bench/config/redis.py +++ b/bench/config/redis.py @@ -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: diff --git a/bench/patches/v4/update_node.py b/bench/patches/v4/update_node.py index b6bab199..ffbe280c 100644 --- a/bench/patches/v4/update_node.py +++ b/bench/patches/v4/update_node.py @@ -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. diff --git a/bench/release.py b/bench/release.py index 6025d4a7..f0c0a65f 100755 --- a/bench/release.py +++ b/bench/release.py @@ -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'] diff --git a/bench/utils.py b/bench/utils.py index 7b079d35..7aedfd0f 100755 --- a/bench/utils.py +++ b/bench/utils.py @@ -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) @@ -415,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') diff --git a/playbooks/install.py b/playbooks/install.py index 529e473a..67ab5672 100644 --- a/playbooks/install.py +++ b/playbooks/install.py @@ -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: diff --git a/playbooks/roles/bench/tasks/setup_erpnext.yml b/playbooks/roles/bench/tasks/setup_erpnext.yml index 2e49219c..5dee30b3 100644 --- a/playbooks/roles/bench/tasks/setup_erpnext.yml +++ b/playbooks/roles/bench/tasks/setup_erpnext.yml @@ -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 diff --git a/playbooks/roles/mariadb/README.md b/playbooks/roles/mariadb/README.md index bc872db5..72e42382 100644 --- a/playbooks/roles/mariadb/README.md +++ b/playbooks/roles/mariadb/README.md @@ -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) diff --git a/playbooks/roles/mariadb/defaults/main.yml b/playbooks/roles/mariadb/defaults/main.yml index fce5bc00..78831c10 100644 --- a/playbooks/roles/mariadb/defaults/main.yml +++ b/playbooks/roles/mariadb/defaults/main.yml @@ -5,4 +5,3 @@ mysql_conf_tpl: change_me mysql_conf_file: settings.cnf mysql_secure_installation: false -... \ No newline at end of file diff --git a/playbooks/roles/mariadb/handlers/main.yml b/playbooks/roles/mariadb/handlers/main.yml index 7072dbd9..3755d8ce 100644 --- a/playbooks/roles/mariadb/handlers/main.yml +++ b/playbooks/roles/mariadb/handlers/main.yml @@ -1,4 +1,3 @@ --- - name: restart mysql service: name=mysql state=restarted -... \ No newline at end of file diff --git a/playbooks/roles/mariadb/tasks/centos.yml b/playbooks/roles/mariadb/tasks/centos.yml index 2b5ced27..c069aacd 100644 --- a/playbooks/roles/mariadb/tasks/centos.yml +++ b/playbooks/roles/mariadb/tasks/centos.yml @@ -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 diff --git a/playbooks/roles/mariadb/tasks/main.yml b/playbooks/roles/mariadb/tasks/main.yml index 8d3e6ea0..6802e7ad 100644 --- a/playbooks/roles/mariadb/tasks/main.yml +++ b/playbooks/roles/mariadb/tasks/main.yml @@ -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 diff --git a/playbooks/roles/mariadb/tasks/mysql_secure_installation.yml b/playbooks/roles/mariadb/tasks/mysql_secure_installation.yml index 621ab4b0..27d1ca80 100644 --- a/playbooks/roles/mariadb/tasks/mysql_secure_installation.yml +++ b/playbooks/roles/mariadb/tasks/mysql_secure_installation.yml @@ -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' -... diff --git a/playbooks/roles/mariadb/tasks/ubuntu.yml b/playbooks/roles/mariadb/tasks/ubuntu-trusty.yml similarity index 63% rename from playbooks/roles/mariadb/tasks/ubuntu.yml rename to playbooks/roles/mariadb/tasks/ubuntu-trusty.yml index 5abec54b..56cd0b66 100644 --- a/playbooks/roles/mariadb/tasks/ubuntu.yml +++ b/playbooks/roles/mariadb/tasks/ubuntu-trusty.yml @@ -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 diff --git a/playbooks/roles/mariadb/tasks/ubuntu-xenial.yml b/playbooks/roles/mariadb/tasks/ubuntu-xenial.yml new file mode 100644 index 00000000..8e834ee8 --- /dev/null +++ b/playbooks/roles/mariadb/tasks/ubuntu-xenial.yml @@ -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 diff --git a/playbooks/roles/mariadb/templates/mariadb_centos.repo.j2 b/playbooks/roles/mariadb/templates/mariadb_centos.repo.j2 index 0a025305..64738cc1 100644 --- a/playbooks/roles/mariadb/templates/mariadb_centos.repo.j2 +++ b/playbooks/roles/mariadb/templates/mariadb_centos.repo.j2 @@ -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 diff --git a/playbooks/roles/mariadb/templates/mariadb_ubuntu.list.j2 b/playbooks/roles/mariadb/templates/mariadb_ubuntu.list.j2 index dca4e70b..981b4d6b 100644 --- a/playbooks/roles/mariadb/templates/mariadb_ubuntu.list.j2 +++ b/playbooks/roles/mariadb/templates/mariadb_ubuntu.list.j2 @@ -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 diff --git a/playbooks/roles/mariadb/vars/main.yml b/playbooks/roles/mariadb/vars/main.yml index b7bf4bcf..df81b3b7 100644 --- a/playbooks/roles/mariadb/vars/main.yml +++ b/playbooks/roles/mariadb/vars/main.yml @@ -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 -... \ No newline at end of file +... diff --git a/playbooks/roles/nodejs/defaults/main.yml b/playbooks/roles/nodejs/defaults/main.yml new file mode 100644 index 00000000..f991faa1 --- /dev/null +++ b/playbooks/roles/nodejs/defaults/main.yml @@ -0,0 +1,3 @@ +--- +node_version: 8 +... \ No newline at end of file diff --git a/playbooks/roles/nodejs/tasks/debian_family.yml b/playbooks/roles/nodejs/tasks/debian_family.yml index c64bac55..a9930529 100644 --- a/playbooks/roles/nodejs/tasks/debian_family.yml +++ b/playbooks/roles/nodejs/tasks/debian_family.yml @@ -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 diff --git a/playbooks/roles/nodejs/tasks/main.yml b/playbooks/roles/nodejs/tasks/main.yml index 85379727..6ff013d7 100644 --- a/playbooks/roles/nodejs/tasks/main.yml +++ b/playbooks/roles/nodejs/tasks/main.yml @@ -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' diff --git a/playbooks/roles/nodejs/tasks/redhat_family.yml b/playbooks/roles/nodejs/tasks/redhat_family.yml index 15af3846..1c3d8fb1 100644 --- a/playbooks/roles/nodejs/tasks/redhat_family.yml +++ b/playbooks/roles/nodejs/tasks/redhat_family.yml @@ -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' ... \ No newline at end of file diff --git a/playbooks/site.yml b/playbooks/site.yml index 839620ee..ca7cb51a 100644 --- a/playbooks/site.yml +++ b/playbooks/site.yml @@ -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 } diff --git a/requirements.txt b/requirements.txt index 4365cc1d..9b2c5b30 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,6 @@ jinja2 virtualenv requests honcho -psutil python-crontab semantic_version GitPython==0.3.2.1