Tailor ansible roles to environment <p>I have a number of environments, that require a bunch of text files to be tailored in order for things like mule to speak to the right endpoints.</p> <p>For this environment, this works:</p> <pre><code>ansible-playbook test03.yml </code></pre> <p>The only difference between an environment (from ansible's perspective) is the information held in ./roles/esb/vars/main.yml.</p> <p>I've considered using svn to keep a vars/main.yml for each environment, so each time I need to configure an environment I check out roles and then vars/main.yml for that environment, before I run the command above.</p> <p>To me, not an elegant solution. How can I do this better?</p> <p>Directory structure</p> <pre><code>./test03.yml ./roles/esb/vars/main.yml ./roles/esb/tasks/main.yml ./roles/esb/templates/trp.properties.j2 </code></pre> <p>./test03.yml</p> <pre><code>--- - hosts: test03-esb gather_facts: no roles: - esb </code></pre> <p>./roles/esb/vars/main.yml</p> <pre><code>--- jndiProviderUrl: 'jnp://mqendpoint.company.com:1099' trp_endpoint_estask: 'http://tmfendpoint.company.com:8080/tmf/estask' trp_endpoint_builderQ: 'jnp://mqendpoint.company.com:1099' </code></pre> <p>./roles/esb/tasks/main.yml</p> <pre><code>--- - name: replace variables in templates template: src=trp.properties.j2 dest=/path/to/mule/deploy/conf/trp.properties </code></pre> <p>./roles/esb/templates/trp.properties.j2</p> <pre><code>trp.endpoint.estask={{ trp_endpoint_estask }} trp.endpoint.builderQ={{ trp_endpoint_builderQ }} </code></pre>