-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
Parent Epic
Part of #232 - Percona Server Puppet Integration
Migrated from infrahouse/terraform-aws-percona-server#30
Description
Implement Puppet logic to register instances with the appropriate NLB target group based on role.
Registration Rules
| Role | Target Group |
|---|---|
| Master | Write TG |
| Replica | Read TG |
Puppet Implementation
class percona::target_group_registration {
$role = $facts['percona_role'] # 'master' or 'replica'
$write_tg = $facts['percona_write_tg_arn']
$read_tg = $facts['percona_read_tg_arn']
$instance_id = $facts['ec2_instance_id']
if $role == 'master' {
exec { 'register-write-tg':
command => "aws elbv2 register-targets --target-group-arn ${write_tg} --targets Id=${instance_id}",
unless => "aws elbv2 describe-target-health --target-group-arn ${write_tg} | grep ${instance_id}",
}
} else {
exec { 'register-read-tg':
command => "aws elbv2 register-targets --target-group-arn ${read_tg} --targets Id=${instance_id}",
unless => "aws elbv2 describe-target-health --target-group-arn ${read_tg} | grep ${instance_id}",
}
}
}Role Determination
Role is determined during bootstrap:
- Try to acquire master lock
- If won and no existing master -> become master
- Otherwise -> become replica
Events Handled by Puppet
| Event | Action |
|---|---|
| Initial master boot | Register to write TG |
| Initial replica boot | Register to read TG |
| Replica dies (replacement) | Register to read TG |
Note: Failover registration handled by Orchestrator hooks, not Puppet
Acceptance Criteria
- Master registered to write TG
- Replicas registered to read TG
- Registration idempotent
- Health checks pass after registration