[Bug]: DigitalOcean ansible playbook deploys masked MongoDB password (********) with doctl >= 2.0.0

Open Beginner friendly
#3,815 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@axllent is already working on this.

Since Nov 18, 2026.

  • #3819 by @axllent — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
ansible, mongodb
Domain
databases, devops

Research direction

Start with ansible/roles/digital_ocean/setup/tasks/main.yml and inspect the two doctl tasks that read the database URI and reset the user password. Run the playbook with doctl 2.x against an existing database and check the generated values file for ******** in db_url. Done means the password is unmasked in the generated URL and the playbook catches a masked value before deployment.

Written by the indexing model from the issue text.

Description

bug
Browsertrix Version

v1.26.6 (but any really)

Browsertrix Host

Self-Hosted

What did you expect to happen? What happened instead?

Description

With doctl v2.0.0 or newer, ansible-playbook do_setup.yml writes a mongo_auth.db_url into the generated values file that contains the literal string ******** as the password. The backend init container then fails MongoDB authentication and crash-loops, so the API never comes up.

Cause

doctl v2.0.0 (release notes, digitalocean/doctl#1966) masks database passwords, including passwords inside connection URIs, in all command output, unless --show is passed or a CI environment variable (such as CI) is set.

ansible/roles/digital_ocean/setup/tasks/main.yml relies on two doctl outputs:

  1. doctl db list -o json provides private_connection.uri
  2. doctl databases user reset <id> doadmin -o json provides [0].password

It then builds db_url with replace(":@", ":<password>@"), which assumes the URI has an empty password. With doctl 2.x:

  • the URI is returned as mongodb+srv://doadmin:********@..., so :@ never matches and the masked URI is used unchanged
  • the reset output's password field is also ********

Because the playbook resets the doadmin password on every run against an existing database, an affected run also invalidates the previously working password. An existing deployment therefore loses database access as soon as the new values are applied.

Versions

  • doctl: v2.4.0 and v2.5.0 (masking was introduced in v2.0.0)

Suggested fix

The least invasive option, which works with both doctl 1.x and 2.x, is to set CI on the two doctl tasks so doctl returns unmasked values:

- name: d_ocean | db | test for existing mongodb
  ansible.builtin.command: doctl db list -o json
  environment:
    CI: "true"
  ...

- name: d_ocean | db | reset db user password
  ansible.builtin.command: doctl databases user reset {{ db_uuid }} doadmin -o json
  environment:
    CI: "true"
  ...

A more explicit alternative is to pass --show to the reset command and replace any password in the URI rather than only an empty one, for example:

db_url: "{{ ... json_query('[0].private_connection.uri') | regex_replace('^(mongodb(\\+srv)?://[^:]+:)[^@]*@', '\\1' ~ password ~ '@') }}"

--show doesn't exist in doctl 1.x, though, so this would need a minimum doctl version.

It would also help to fail the play if the final db_url still contains ********, so this kind of breakage is caught before deploy rather than at runtime.

Reproduction instructions
  1. Install doctl >= 2.0.0.
  2. Run ansible-playbook do_setup.yml ... against a project whose MongoDB database already exists.
  3. Look at chart/<project_name>-values.yaml: db_url contains :********@.
  4. kubectl get pods shows the backend in Init:CrashLoopBackOff. Its logs show pymongo.errors.OperationFailure: Authentication failed. (code 18).
Screenshots / Video

No response

Environment

No response

Additional details

No response

Dominant language
TypeScript
Stars
502
Forks
83
Avg merge
2d 14h
Merged PRs (30d)
32

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from webrecorder/browsertrix

All issues in webrecorder/browsertrix

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.