[ADD] configure: odoo-config generation step on target host#43
Conversation
20fd2bf to
9b367fe
Compare
|
|
||
| if not conf_exists or recreate: | ||
| typer.secho(f"\n{CONFIGURE_STEPS['config']}…", fg="green") | ||
| version = opts.get("version") or typer.prompt("Target Odoo version", default="19.0") |
There was a problem hiding this comment.
can you run odoo-addons-path --verbose in project codebase to capture the detected odoo version instead of prompting it?
There was a problem hiding this comment.
Please also consider the case that instance_path doesn't exist, for example, run with dry-run for non-existent instance_path.
| overrides: dict[str, Any] = { | ||
| "db_user": instance_name, | ||
| "report.url": f"http://{instance_name}:8069", | ||
| "http_interface": instance_name, |
There was a problem hiding this comment.
can you generate a strong admin_passwd by default to make sure we never have admin
| if conf_exists: | ||
| executor.run(f"mv {conf_path} {conf_path}.bak", dry_run=dry_run) | ||
| executor.run( | ||
| f"odoo-config create --version {shlex.quote(str(version))} -c {conf_path} {override_args}", |
There was a problem hiding this comment.
we should be abl to define --preset based on the instance name (e.g. staging)
hailangvn
left a comment
There was a problem hiding this comment.
Code review OK. LGTM. Thank you.
|
Thank you. The PR has been updated. |
| * `-p, --port INTEGER`: SSH port on the remote host. | ||
| * `--repo-subdir TEXT`: Subdirectory within the repo to use as the service root (for monorepos). | ||
| * `--repo-branch TEXT`: Git branch to clone and track (defaults to the repository's default branch). | ||
| * `--recreate / --no-recreate`: Re-create venv in case it exists. This is useful when you want to update the venv. \[default: no-recreate\] |
There was a problem hiding this comment.
not only venv: also unit, config
There was a problem hiding this comment.
Thank you. The PR has been updated to address this comment and another one.
| # before the command runs); the remote executor degrades to a non-zero ExecutorError. | ||
| try: | ||
| detected = executor.capture( | ||
| "odoo-addons-path --verbose | awk -F': ' '/^Odoo version:/ {print $2; exit}'", |
There was a problem hiding this comment.
fyi we also have --format json
There was a problem hiding this comment.
btw, I think it would be worth if odoo-addons-path could detect the odoo edition: CE or EE (with a naive low io heuristic such as having the addons directory "enterprise" or "odoo-enterprise")
because some elements of the config will differ, e.g. database.expiration* in integration/staging environments
could you please create a PR on odoo-addons-path for that?
There was a problem hiding this comment.
btw, I think it would be worth if
odoo-addons-pathcould detect the odoo edition: CE or EE (with a naive low io heuristic such as having the addons directory "enterprise" or "odoo-enterprise") because some elements of the config will differ, e.g.database.expiration*in integration/staging environments could you please create a PR on odoo-addons-path for that?
Hello Nils,
About this request, could you please confirm the scope below?
- Add a
get_odoo_edition()heuristic: returnsEEif a resolved addons path is
namedenterprise/odoo-enterprise, otherwiseCE. - Expose it as
odoo_edition(values CE/EE) in the JSON output, plus an Odoo
edition: line in the verbose text.
Thanks!
New "config" step in `deploy configure` (odoo only): generate config/odoo.conf by running odoo-config on the target host, mirroring the "unit" step (warn if it exists, regenerate on --recreate after backing up to .bak). Defaults passed as overrides: db_user, report.url, http_interface; the deploy.yml `config:` block overrides them. Target Odoo version comes from the `version:` key, else prompts (default 19.0). Forge-ID: 68011
| "db_user": instance_name, | ||
| "report.url": f"http://{instance_name}:8069", | ||
| "http_interface": instance_name, | ||
| "admin_passwd": secrets.token_urlsafe(24), |
There was a problem hiding this comment.
Should we add a warning for user to change password to not surprise the person about this setting?
There was a problem hiding this comment.
let's discuss about it on the private side: https://gitlab.trobz.com/packages/deploy.py-tms/-/issues/1
4c841d5 to
32e1ce6
Compare
- Derive odoo-config --preset from the dash-separated instance type (production/staging/integration); demo/hotfix/test/training get none. Override via the deploy.yml `preset:` key. - Detect the Odoo version from `odoo-addons-path --verbose` in the codebase instead of prompting; prompt only as a fallback. - Generate a strong admin_passwd by default so the config never ships `admin`. Forge-ID: 68011
32e1ce6 to
b34b3d2
Compare
Surface the Odoo edition in `--format json` (new `odoo_edition` key) and in the `--verbose` text output. Inferred name-based from the resolved addons_path: EE when an `enterprise`/`odoo-enterprise` dir is present, otherwise CE, and None when no addons resolve. Follow-up of trobz/deploy.py#43 (comment) Forge-ID: 68011
What
deploy configurenow generates the Odoo config on the target host viaodoo-config, instead of leavingconfig/odoo.confto be written by hand.Contents
configstep (odoo only), runs beforeunit. Mirrors theunitstep: warns if the config exists, regenerates only when absent or--recreate(backs up to.bakfirst).odoo-config create --version <v> -c config/server.conf <overrides>.db_user,report.url,http_interface(= instance name); thedeploy.ymlconfig:block overrides them.version:key, else prompts (default19.0).Forge-ID: 68011