nginx.confhttp { proxy_cache_path /data/nginx/cache levels=1:2 keys_zone=STATIC:10m inactive=24h max_size=1g; server { location / { proxy_pass http://1.2.3.4; proxy_set_header Host $host; proxy_buffering on;…
inventory file
[servers]
master ansible_ssh_host=172.18.23.69
node1 ansible_ssh_host=172.18.23.70
node2 ansible_ssh_host=172.18.23.71
node3 ansible_ssh_host=172.18.23.72
templates/etc/hosts.j2
{% for item in ansible_play_batch %}
{{ hostvars[item].ansible_ssh_host }} {{ item }}.example.com
{% endfor %}
playbook task
- hosts: servers
gather_facts: False
tasks:
- name: update /etc/hosts file
become: true
blockinfile:
dest: /etc/hosts
content: "{{ lookup('template', 'templates/etc/hosts.j2') }}"
state: present