#Ansible

Below is an Ansible template file I use for generating a hosts file. 127.0.0.1 localhost.localdomain localhost {% for item in play_hosts %} {% set hostname = item.replace("_", "-") %} {% if 'ansible_eth0' in hostvars[item] %} {{ hostvars[item]['ansible_eth0']['ipv4']['address'] }} {{ hostname | regex_replace('^sgmc-[a-z]*-', '') }} {{ hostname }} {{ hostname + '.domain.com' }} {% endif %} {% endfor %} The first part of the host loop... [Read More]