🔐Rotate Azure Entra ID OAuth2 Client Secret Runbook

Purpose:
When the Azure Entra ID application’s client secret expires, operators must re‑run the OAuth2 provisioning workflow. This regenerates a new secret and injects it into the reverse proxy’s OAuth2 configuration via the entra_id_oauth2 role.

Related Documentation:
See Configure An Inventory For Entra ID OAuth2 for inventory prerequisites and variable definitions.


1. Preconditions

Before executing the rotation workflow, confirm:

If any of these need updating, refer to the Configure An Inventory For Entra ID OAuth2 runbook.


2. Why This Rotation Is Required

The OAuth2 client secret stored in Entra ID has a fixed lifetime.
When it expires:

The entra_id_oauth2 role regenerates a new client secret using the Azure CLI and injects it into the site’s rproxy_setup_sites entry. The updated secret is then consumed by the oauth2_proxy_setup role.


3. Execute the Secret Rotation Workflow

Run the following command from your automation control node:

INV=inventory/services/inventory.ini
ansible-playbook -k -u ansible -i $INV playbooks/oauth2_proxy/deploy_oauth2_proxy.yml

This playbook:

Refer to the Configure An Inventory For Entra ID OAuth2 runbook for inventory structure and variable definitions.

This process ensures the new secret is fully deployed and active.


4. Post‑Rotation Validation

Perform the following checks:

🔎 Inventory Validation

ansible-inventory -i $INV --graph oauth2_proxy

Confirm the protected site appears under the oauth2_proxy group.

🌐 Functional Validation

🧩 Service Validation

On the proxy host:

systemctl status oauth2-proxy@<server_name>.service

Confirm the service is running without errors.


5. Troubleshooting

If issues occur after rotation, cross‑check the guidance in the Configure An Inventory For Entra ID OAuth2 runbook:


6. Summary

This runbook provides the operational steps to rotate an expired Azure Entra ID OAuth2 client secret using your existing Ansible automation. The deploy_oauth2_proxy.yml playbook handles secret regeneration, injection, and service reconfiguration end‑to‑end.