How do you test a Jinja2 expression quickly from the command line?
BeginnerProductionRapid-Fire Commands
Answer
ansible localhost -m ansible.builtin.debug \
-a "msg={{ ['a','b','c'] | map('upper') | join(',') }}"
ansible localhost -e '{"ports":[80,443]}' -m ansible.builtin.debug \
-a "msg={{ ports | map('string') | join(' ') }}"
Much faster than editing a template and running a whole play to see what a filter chain produces.
More on Rapid-Fire Commands
How do you see which hosts a playbook would run against, without running it?BeginnerHow do you list the tasks and tags a playbook contains?BeginnerHow do you inspect the inventory structure and a host's variables?BeginnerHow do you restart a service on a group with an ad-hoc command?BeginnerHow do you resume a playbook from a specific task or step through it?BeginnerHow do you re-run a playbook only on the hosts that failed?Intermediate