ansible-template-render
A tool for rendering Ansible template files locally without applying changes to remote hosts.
Overview
ansible-template-render allows you to preview configuration files that would be generated by Ansible playbooks without actually deploying them to the target servers. This is useful for verifying configuration templates before deployment.
Features
- Generate configuration files from Ansible templates locally
- Process playbooks with dependencies
- Respect variable precedence in Ansible
- Render templates with the same variable context that would be used in actual deployment
- Support both static and dynamic inventory
- Option to generate files without executing Ansible
Prerequisites
Ansible
Usage
ansible-template-render run [-i INV] PLAYBOOK [-- ANSIBLE_ARGS...]
ansible-template-render generate [-i INV] PLAYBOOK [-- ANSIBLE_ARGS...]
ansible-template-render version
run — render templates by invoking ansible-playbook
generate — produce the modified Ansible files without executing
- Arguments after
-- are passed through to ansible-playbook
How It Works
- The tool analyzes the specified playbook to find template tasks
- It creates a temporary directory with a modified version of the playbook and roles
- Template tasks are modified to:
- Add
delegate_to: localhost and run_once: true
- Add a
render_config tag
- Redirect output to the local
output directory
- Ansible is executed with only the
render_config tag enabled
- The resulting files are generated in the
output directory
Examples
An example project is available in the example/ directory:
$ ansible-template-render run -i inventory site.yml
Pass extra flags to ansible-playbook:
$ ansible-template-render run -i inventory site.yml -- --diff
Generate without executing:
$ ansible-template-render generate -i inventory site.yml
License
This project is licensed under the MIT License.