working template example
This commit is contained in:
parent
4536536f24
commit
33162a0084
13
playbooks/fun_with_templates.yml
Normal file
13
playbooks/fun_with_templates.yml
Normal file
@ -0,0 +1,13 @@
|
||||
---
|
||||
- name: template functionality tests
|
||||
hosts: all
|
||||
become: yes
|
||||
tasks:
|
||||
- name: say hello
|
||||
debug:
|
||||
var: hostvars[inventory_hostname]['ansible_facts']['default_ipv4']['address']
|
||||
- name: create /etc/hosts.test
|
||||
template:
|
||||
src: ../templates/hosts.j2
|
||||
dest: /etc/hosts.test
|
||||
mode: '0644'
|
3
templates/hosts.j2
Normal file
3
templates/hosts.j2
Normal file
@ -0,0 +1,3 @@
|
||||
{% for host in groups['all'] %}
|
||||
{{ hostvars[host]['ansible_facts']['default_ipv4']['address'] }}
|
||||
{% endfor %}
|
Loading…
Reference in New Issue
Block a user