You must generate a config containing a random password once and then keep it stable on later runs.
IntermediateScenarioVariables, Facts and Templates
Answer
Situation read → Idempotent random data.
What I'd do →
app_secret: "{{ lookup('ansible.builtin.password', '/secure/creds/' ~ inventory_hostname ~ '.txt length=32 chars=ascii_letters,digits') }}"
Why → The password lookup creates the file on the first call and reads it back later, so the value stays the same. It runs on the controller, so protect that directory.
Interview tip → Better for production: generate in a secrets manager and look it up.
More on Variables, Facts and Templates
A variable you set in `group_vars` is being overridden and you do not know where. How do you find the source?IntermediateYou need different values per environment without copying playbooks.BeginnerYou must render an Nginx config with one `server` block per site from a list.IntermediateA template needs the IPs of all hosts in the `db` group, for example for a replication config.IntermediateNothing should be rendered unless a mandatory variable is supplied.BeginnerPer-host values, like `server_id` for MySQL, must be unique and stable.Intermediate