Example 6
hosts.yml
centos:
hosts:
provisioner:
ansible_connection: local
centos1:
ansible_host: '192.168.77.22'
ubuntu:
hosts:
ubuntu1:
ansible_host: '192.168.77.23'
playbook.yml
- hosts: all
tasks:
- name: Jinja2 filters
debug:
msg: >
...min...
{{ [1, 2, 3] | min }}
...max...
{{ [1, 2, 3] | max }}
...unique...
{{ [1, 1, 1, 2, 2 ,3] | unique }}
...random..
{{ [1, 2, 3, 4, 5] | random }}
Tip
Jinja2
comes with multiple built-in filters that help with a variety of common templating patterns.
Execute the following command
ansible-playbook playbook.yml