how to write playbook for this scenario

What did you try yourself yet?