[Bug]: DigitalOcean ansible playbook deploys masked MongoDB password (********) with doctl >= 2.0.0
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
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
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:
doctl db list -o jsonprovidesprivate_connection.uridoctl databases user reset <id> doadmin -o jsonprovides[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
passwordfield 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
- Install doctl >= 2.0.0.
- Run
ansible-playbook do_setup.yml ...against a project whose MongoDB database already exists. - Look at
chart/<project_name>-values.yaml:db_urlcontains:********@. kubectl get podsshows the backend inInit:CrashLoopBackOff. Its logs showpymongo.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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from webrecorder/browsertrix
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
webrecorder/browsertrix#3823 ·
Maintainers usually reply within 1 day
-
enhancement idea
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
webrecorder/browsertrix#3715 ·
Maintainers usually reply within 1 day
-
bug front end
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
webrecorder/browsertrix#3708 ·
Maintainers usually reply within 1 day
-
back end
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
webrecorder/browsertrix#3626 ·
Maintainers usually reply within 1 day
-
GitHub RedirectOpenenhancement idea
Difficulty 1/5 Under an hour Newbie friendliness 64/100
webrecorder/browsertrix#3285 ·
Maintainers usually reply within 1 day
All issues in webrecorder/browsertrix
Similar issues
-
bug documentation
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Potential Bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Comfy-Org/ComfyUI_frontend#23773 ·
Maintainers usually reply within 1 day
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 85/100
lingdojo/kana-dojo#34301 · 1 comment · 5 reactions ·
Maintainers usually reply within 1 day
-
code-quality refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
github/gh-aw-firewall#11797 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
code-yeongyu/senpi#7007 ·
Maintainers usually reply within 1 day