Skip to content

[ADD] configure: odoo-config generation step on target host#43

Merged
nilshamerlinck merged 2 commits into
trobz:mainfrom
dzungtran89:feat/configure-odoo-config
Jun 22, 2026
Merged

[ADD] configure: odoo-config generation step on target host#43
nilshamerlinck merged 2 commits into
trobz:mainfrom
dzungtran89:feat/configure-odoo-config

Conversation

@dzungtran89

@dzungtran89 dzungtran89 commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

What

deploy configure now generates the Odoo config on the target host via odoo-config, instead of leaving config/odoo.conf to be written by hand.

Contents

  • New config step (odoo only), runs before unit. Mirrors the unit step: warns if the config exists, regenerates only when absent or --recreate (backs up to .bak first).
  • Generates via odoo-config create --version <v> -c config/server.conf <overrides>.
  • Default overrides: db_user, report.url, http_interface (= instance name); the deploy.yml config: block overrides them.
  • Version from the version: key, else prompts (default 19.0).
  • Tests + regenerated CLI reference doc.

Forge-ID: 68011

@dzungtran89 dzungtran89 force-pushed the feat/configure-odoo-config branch 3 times, most recently from 20fd2bf to 9b367fe Compare June 19, 2026 07:52
Comment thread trobz_deploy/command/configure.py Outdated

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")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you run odoo-addons-path --verbose in project codebase to capture the detected odoo version instead of prompting it?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you generate a strong admin_passwd by default to make sure we never have admin

Comment thread trobz_deploy/command/configure.py Outdated
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}",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should be abl to define --preset based on the instance name (e.g. staging)

@dzungtran89 dzungtran89 marked this pull request as draft June 19, 2026 09:52

@hailangvn hailangvn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review OK. LGTM. Thank you.

@dzungtran89 dzungtran89 marked this pull request as ready for review June 22, 2026 03:22
@dzungtran89

Copy link
Copy Markdown
Contributor Author

Thank you. The PR has been updated.

Comment thread site-docs/docs/cli-reference.md Outdated
* `-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&#x27;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\]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not only venv: also unit, config

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. The PR has been updated to address this comment and another one.

Comment thread trobz_deploy/command/configure.py Outdated
# 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}'",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi we also have --format json

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Hello Nils,

About this request, could you please confirm the scope below?

  1. Add a get_odoo_edition() heuristic: returns EE if a resolved addons path is
    named enterprise/odoo-enterprise, otherwise CE.
  2. Expose it as odoo_edition (values CE/EE) in the JSON output, plus an Odoo
    edition: line in the verbose text.

Thanks!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

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),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a warning for user to change password to not surprise the person about this setting?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's discuss about it on the private side: https://gitlab.trobz.com/packages/deploy.py-tms/-/issues/1

- 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
@dzungtran89 dzungtran89 force-pushed the feat/configure-odoo-config branch from 32e1ce6 to b34b3d2 Compare June 22, 2026 05:21
nilshamerlinck pushed a commit to trobz/odoo-addons-path that referenced this pull request Jun 22, 2026
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
@nilshamerlinck nilshamerlinck merged commit 214329e into trobz:main Jun 22, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants