Skip to content

Doc/systems#56

Merged
AitingLee merged 3 commits into
mainfrom
doc/systems
May 9, 2026
Merged

Doc/systems#56
AitingLee merged 3 commits into
mainfrom
doc/systems

Conversation

@AitingLee
Copy link
Copy Markdown
Collaborator

No description provided.

eliappo and others added 3 commits May 8, 2026 11:25
…resource

Previously, each manager VM was defined as a separate, named Terraform
resource (manager1_prod, manager2_prod, etc.). Adding or removing a manager
required manually duplicating or deleting entire resource blocks and updating
the Ansible inventory, env file, null_resource depends_on, and triggers in
multiple places.

This change introduces a single manager_count variable in both the production
and staging configurations. A single digitalocean_droplet resource with
count = var.manager_count replaces the hardcoded resources. All downstream
resources (Ansible inventory, .env file, null_resource depends_on) now use
Terraform's splat expressions and template for-loops to dynamically adapt to
however many managers are configured.

Key changes:
- Added manager_count variable (default: 2) with a validation rule enforcing
  an even number >= 2. This is required because db_prod/db_stage already acts
  as the swarm leader (a manager), so total managers = manager_count + 1 must
  be odd for Docker Swarm Raft quorum.
- Replaced manager1/manager2 droplet resources with a single
  digitalocean_droplet.manager_{prod,stage} resource using count.
- Ansible inventory now uses a %{ for } template loop to emit one line per
  manager, so it stays correct regardless of manager_count.
- .env file uses the same loop to emit MANAGER1_IP, MANAGER2_IP, ... entries
  dynamically. Staging nip.io domain and URLs continue to use manager[0].
- Added triggers to null_resource.run_ansible_{prod,stage} so that Ansible
  is re-run whenever a manager IP changes or a new manager is added. Previously
  triggers were absent, meaning Ansible would only ever run on first apply.
- All depends_on references updated from the old per-resource names to the
  new array-style reference (digitalocean_droplet.manager_{prod,stage}).

To scale managers: set manager_count = 4 (or any even number >= 2) in
terraform.tfvars or pass -var="manager_count=4" at apply time.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@AitingLee AitingLee merged commit c188583 into main May 9, 2026
2 of 3 checks passed
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 9, 2026

@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

✅ Tests passed and image built!
Tag: test-doc-systems-94cd0c5

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.

2 participants