fkeles

create-steering-policy.sh

Jan 18th, 2026
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.23 KB | Software | 0 0
  1. # create answers.json
  2. cat > answers.json <<EOF
  3. [
  4.   {
  5.     "name": "server-primary",
  6.     "rtype": "A",
  7.     "rdata": "${PRIMARY}",
  8.     "pool": "primary"
  9.   },
  10.   {
  11.     "name": "server-secondary",
  12.     "rtype": "A",
  13.     "rdata": "${SECONDARY}",
  14.     "pool": "secondary"
  15.   }
  16. ]
  17. EOF
  18.  
  19. # create rules.json
  20. cat > rules.json <<'EOF'
  21. [
  22.   {
  23.     "ruleType": "FILTER",
  24.     "defaultAnswerData": [
  25.       {
  26.         "answerCondition": "answer.isDisabled != true",
  27.         "shouldKeep": true
  28.       }
  29.     ]
  30.   },
  31.   { "ruleType": "HEALTH" },
  32.   {
  33.     "ruleType": "PRIORITY",
  34.     "defaultAnswerData": [
  35.       { "answerCondition": "answer.pool == 'primary'",   "value": 1  },
  36.       { "answerCondition": "answer.pool == 'secondary'", "value": 99 }
  37.     ]
  38.   },
  39.   { "ruleType": "LIMIT", "defaultCount": 1 }
  40. ]
  41. EOF
  42.  
  43. # create failover steering policy
  44. STEERING_POLICY_ID=$(
  45.   oci dns steering-policy create \
  46.     --compartment-id "$COMPARTMENT_ID" \
  47.     --display-name "DNS-Failover-Policy" \
  48.     --template FAILOVER \
  49.     --ttl 30 \
  50.     --health-check-monitor-id "$MONITOR_ID" \
  51.     --answers file://answers.json \
  52.     --rules file://rules.json \
  53.     --query 'data.id' \
  54.     --raw-output
  55. )
  56. echo "Steering Policy OCID: $STEERING_POLICY_ID"
Advertisement
Add Comment
Please, Sign In to add comment