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

Merge branch 'staging' into v5.x

This commit is contained in:
Ankush Menat 2023-10-21 11:32:41 +05:30
commit 0122ef17bf
10 changed files with 42 additions and 28 deletions

View File

@ -25,9 +25,10 @@ def install_prerequisites():
@click.command(
"mariadb", help="Install and setup MariaDB of specified version and root password"
)
@click.option("--mysql_root_password", "--mysql-root-password", default="")
@click.option("--mysql_root_password", "--mysql-root-password",
"--mariadb_root_password", "--mariadb-root-password", default="")
@click.option("--version", default="10.3")
def install_maridb(mysql_root_password, version):
def install_mariadb(mysql_root_password, version):
if mysql_root_password:
extra_vars.update(
{
@ -111,7 +112,7 @@ def install_failtoban(**kwargs):
install.add_command(install_prerequisites)
install.add_command(install_maridb)
install.add_command(install_mariadb)
install.add_command(install_wkhtmltopdf)
install.add_command(install_nodejs)
install.add_command(install_psutil)

View File

@ -358,7 +358,7 @@ def sync_domains(domain=None, site=None):
@click.command("role", help="Install dependencies via ansible roles")
@click.argument("role")
@click.option("--admin_emails", default="")
@click.option("--mysql_root_password")
@click.option("--mysql_root_password", "--mariadb_root_password")
@click.option("--container", is_flag=True, default=False)
def setup_roles(role, **kwargs):
extra_vars = {"production": True}

View File

@ -83,7 +83,7 @@ def update_config_for_frappe(config, bench_path):
for key in ("redis_cache", "redis_queue", "redis_socketio"):
if key not in config:
config[key] = f"redis://localhost:{ports[key]}"
config[key] = f"redis://127.0.0.1:{ports[key]}"
for key in ("webserver_port", "socketio_port", "file_watcher_port"):
if key not in config:

View File

@ -39,7 +39,7 @@ server {
}
location @webserver {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Frappe-Site-Name {{ bench_manager_site_name }};
proxy_set_header Host {{ bench_manager_site_name }};

View File

@ -13,7 +13,7 @@ Debain 9
## Post install
Run `mysql_secure_installation`
Run `mariadb-secure-installation`
## Requirements
@ -39,7 +39,7 @@ Configuration filename:
mysql_conf_file: settings.cnf
```
### Experimental unattended mysql_secure_installation
### Experimental unattended mariadb-secure-installation
```
ansible-playbook release.yml --extra-vars "mysql_secure_installation=true mysql_root_password=your_very_secret_password"

View File

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

View File

@ -16,7 +16,7 @@
group: root
mode: 0644
when: mysql_conf_tpl != 'change_me' and ansible_distribution != 'Debian'
notify: restart mysql
notify: restart mariadb
- include_tasks: debian.yml
when: ansible_distribution == 'Debian'
@ -29,7 +29,7 @@
group: root
mode: 0644
when: mysql_conf_tpl != 'change_me' and ansible_distribution == 'Debian'
notify: restart mysql
notify: restart mariadb
- name: Add additional conf for MariaDB 10.2 in mariadb.conf.d
blockinfile:
@ -59,7 +59,7 @@
- name: Start and enable service
service:
name: mysql
name: mariadb
state: started
enabled: yes

View File

@ -19,28 +19,28 @@
- ::1
- name: Reload privilege tables
command: 'mysql -ne "{{ item }}"'
command: 'mariadb -ne "{{ item }}"'
with_items:
- FLUSH PRIVILEGES
changed_when: False
when: run_travis is not defined
- name: Remove anonymous users
command: 'mysql -ne "{{ item }}"'
command: 'mariadb -ne "{{ item }}"'
with_items:
- DELETE FROM mysql.user WHERE User=''
changed_when: False
when: run_travis is not defined
- name: Disallow root login remotely
command: 'mysql -ne "{{ item }}"'
command: 'mariadb -ne "{{ item }}"'
with_items:
- DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1')
changed_when: False
when: run_travis is not defined
- name: Remove test database and access to it
command: 'mysql -ne "{{ item }}"'
command: 'mariadb -ne "{{ item }}"'
with_items:
- DROP DATABASE IF EXISTS test
- DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%'
@ -48,7 +48,7 @@
when: run_travis is not defined
- name: Reload privilege tables
command: 'mysql -ne "{{ item }}"'
command: 'mariadb -ne "{{ item }}"'
with_items:
- FLUSH PRIVILEGES
changed_when: False

View File

@ -54,9 +54,9 @@ class TestBenchInit(TestBenchBase):
"webserver_port": 8000,
"socketio_port": 9000,
"file_watcher_port": 6787,
"redis_queue": "redis://localhost:11000",
"redis_socketio": "redis://localhost:13000",
"redis_cache": "redis://localhost:13000",
"redis_queue": "redis://127.0.0.1:11000",
"redis_socketio": "redis://127.0.0.1:13000",
"redis_cache": "redis://127.0.0.1:13000",
},
)
@ -66,9 +66,9 @@ class TestBenchInit(TestBenchBase):
"webserver_port": 8001,
"socketio_port": 9001,
"file_watcher_port": 6788,
"redis_queue": "redis://localhost:11001",
"redis_socketio": "redis://localhost:13001",
"redis_cache": "redis://localhost:13001",
"redis_queue": "redis://127.0.0.1:11001",
"redis_socketio": "redis://127.0.0.1:13001",
"redis_cache": "redis://127.0.0.1:13001",
},
)

View File

@ -1,6 +1,7 @@
#!/usr/bin/env python3
import argparse
import fileinput
import logging
import os
import platform
@ -114,7 +115,10 @@ def check_repo_exists() -> bool:
return os.path.exists(os.path.join(os.getcwd(), "frappe_docker"))
def setup_prod(project: str, sites, email: str, version: str = None) -> None:
def setup_prod(project: str, sites, email: str, version: str = None, image = None) -> None:
if len(sites) == 0:
sites = ["site1.localhost"]
if check_repo_exists():
compose_file_name = os.path.join(os.path.expanduser("~"), f"{project}-compose.yml")
docker_repo_path = os.path.join(os.getcwd(), "frappe_docker")
@ -171,6 +175,14 @@ def setup_prod(project: str, sites, email: str, version: str = None) -> None:
logging.error("Docker Compose generation failed", exc_info=True)
cprint("\nGenerating Compose File failed\n")
sys.exit(1)
# Use custom image
if image:
for line in fileinput.input(compose_file_name, inplace=True):
if "image: frappe/erpnext" in line:
line = line.replace("image: frappe/erpnext", f"image: {image}")
sys.stdout.write(line)
try:
# Starting with generated compose file
subprocess.run(
@ -199,7 +211,7 @@ def setup_prod(project: str, sites, email: str, version: str = None) -> None:
else:
install_docker()
clone_frappe_docker_repo()
setup_prod(project, sites, email, version) # Recursive
setup_prod(project, sites, email, version, image) # Recursive
def setup_dev_instance(project: str):
@ -316,11 +328,12 @@ if __name__ == "__main__":
"-s",
"--sitename",
help="Site Name(s) for your production bench",
default=["site1.localhost"],
default=[],
action="append",
dest="sites",
)
parser.add_argument("-n", "--project", help="Project Name", default="frappe")
parser.add_argument("-i", "--image", help="Full Image Name")
parser.add_argument(
"--email", help="Add email for the SSL.", required="--prod" in sys.argv
)
@ -338,6 +351,6 @@ if __name__ == "__main__":
if "example.com" in args.email:
cprint("Emails with example.com not acceptable", level=1)
sys.exit(1)
setup_prod(args.project, args.sites, args.email, args.version)
setup_prod(args.project, args.sites, args.email, args.version, args.image)
else:
parser.print_help()