I am using an ansible playbook to deploy a php web application in aws. The deployment is repeated many times, with a different environment, for each customer. The different scenarios range from single server deployments to full deployments using elastic load balancers, and use varying code repositories based on product type.
To allow a human to deploy this app repetitively and adjust the deployment type and environment, I am running
--extra-vars "@deployment_vars_file.yml" and copying and filling this vars file on a per-deployment basis, instead of putting the variables in
group_vars/all.yml, so that I can keep a copy of the variable space I set for each deployment, and avoid overwriting (or .template suffixing)
group_vars/all.yml and multiple roles'
vars/main.yml files, for each deployment. I rarely rely on variable precedence, since the role and play variables inherit (are constructed out of) my deployment vars file variables.
My roles are already run conditionally at the play level, and I have a handle on how to run tasks/blocks/roles/plays conditionally, depending on the environment type that is defined in the
I need to define many other variables, dynamically (during the playbook run), conditionally (based on the values of variables in my
--extra-vars file), with as little work as possible (i.e., in one place), at the beginning of the playbook. My roles'
vars/main.yml files, as well as
vars: play keywords, will inherit these other variables, (in addition to directly inheriting some of the
--extra-vars variables). The values of these other variables need to persist at the playbook level, not just within each play. I don't want to have to do this in multiple locations with the same lines of code.
How can I do this, and what is the most simple way?