Skip to content

Instantly share code, notes, and snippets.

@Kaezon
Last active November 1, 2022 19:29
Show Gist options
  • Save Kaezon/574b7cc428bc06b908925e2c2d12ddfd to your computer and use it in GitHub Desktop.
Save Kaezon/574b7cc428bc06b908925e2c2d12ddfd to your computer and use it in GitHub Desktop.
AWX Operator - Debug Template
# This play will render a specified template file and output it
#
# Note: Templates which include other templates will require this playbook to be place in their respective
# template directories due to the use of relative paths in those templates.
# Note: You will also likely need to include appropriate default vars files for the template with the '-e' directive
# Note: Depending on the template, you may still need to add some extra vars to satisfy the template's needs.
#
# Invokation example:
# ansible-playbook debug-template.yaml -e template_path=/opt/ansible/roles/installer/templates/configmaps/config.yaml.j2 -e @/opt/ansible/roles/installer/defaults/main.yml
---
- name: Debug Play
hosts: localhost
connection: local
vars_files:
- /opt/ansible/roles/backup/vars/main.yml
- /opt/ansible/roles/installer/vars/main.yml
- /opt/ansible/roles/restore/vars/main.yml
- /opt/ansible/playbooks/debug-vars.yaml
tasks:
- name: Render template
vars:
rendered_template: "{{lookup('template', template_path)}}"
ansible.builtin.debug:
msg: "{{ rendered_template.split('\n') }}"
---
ansible_operator_meta:
name: awx
namespace: awx
service_type: nodeport
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment