A failover procedure with three WP-CLI steps, and the one that has to run before the database is writable.
# on the promoted host, in order:
wp config set DB_HOST "$NEW_PRIMARY" --type=constant
wp cache flush
wp option update siteurl "https://$DOMAIN"
# and the ordering that matters: the cache flush must
# come after the database points at the new primary
# and before anything reads a cached option, or the
# old host's siteurl is served from a warm cache.
Three commands and an ordering constraint that is not obvious, which is what a runbook is for. The step that catches people is that wp itself needs a working database connection, so the configuration change has to be a file edit rather than an option update.